Trivial simple OpenGl working example

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jul 9 19:15:44 UTC 2021


On Fri, Jul 09, 2021 at 05:11:06AM +0000, Виталий Фадеев via Digitalmars-d-learn wrote:
[...]
> I using CPU Pentium B970 It is old CPU, but even it contains a
> graphics accelerator.
> Mesa DRI Intel(R) HD Graphics 2000 (SNB GT1), has 4 conveers on GPU.
> Smartphones also contains GPU.
> Because OpenGL has high priority.
[...]
> What about text rendering ?

Generally, text rendering on OpenGL is a huge pain to implement. This is
not specific to D, but to OpenGL in general, because OpenGL itself does
not have direct support for text rendering at all.  The usual route is
to use an existing text-rendering library like FreeType to rasterize
your text, then upload it as a texture to the GPU and render it as a
quad.

If you want to do a more modern approach, you could use signed distance
fields, but that requires some deep knowledge of how shaders work unless
you can find an off-the-shelf library that does it for you. You may
still end up needing FreeType or equivalent anyway, to get the SDFs in
the first place.

Here's something to start you off, if you don't already have an approach
in mind:

	https://learnopengl.com/In-Practice/Text-Rendering


T

-- 
Chance favours the prepared mind. -- Louis Pasteur


More information about the Digitalmars-d-learn mailing list