rougier / freetype-gl

OpenGL text using one vertex buffer, one texture and FreeType
Other
1.64k stars 264 forks source link

What deps are actually required and why? #204

Closed Lord-Kamina closed 5 years ago

Lord-Kamina commented 5 years ago

Sorry if this is answered in detail somewhere.

You see, I'm looking for an alternative to what we're currently doing over at Performous which is essentially rasterizing text with pangocairo and then uploading it to an OpenGL texture. It works but is very inefficient and while it looks ok... it looks JUST ok.

I've recently learned about SDF (I'm very much a newbie to both c++ and OpenGL and game developing in general, I'm actually a physician 😅) so anyway... I was thinking of maybe poaching just your SDF implementations and integrating them into our code. We haven't even tried to atlas fonts (although I've been doing research into atlasing and batching in general) because we deal with unicode text in potentially every language.

Then I realized if freetype-gl normally atlases fonts; well, that might kill two birds with one stone for us. My only concern at this point before I delve into playing with it are dependencies. I understand obviously that freetype, harfbuzz and fontconfig are used (and probably what each does)

But what about glfw3 and glew? I'm not really familiar with glfw3 but from reading a short description it seemed to me like it might be an alternative to SDL2? Is it deeply integrated in the code or could freetype-gl maybe be made to work with sdl2 instead?

And about glew... we use libepoxy instead; would it be possible to use freetype-gl against epoxy instead?

rougier commented 5 years ago

In a nutshell:

So mostly, only freetype is required. But, if you don't want too much dependencies, you might want to have a look at stb_truetype.h which is a single header file to parse and raserize fonts. With some effort, you can have SDF as well.

Also, you can perfectly replace GLFW with SDL2. For libepoxy, I don't know it so I can't answer your question.

Lord-Kamina commented 5 years ago

Thank you very much for the answer!

We already depend on freetype, harfbuzz and fontconfig so those three at least won't be an issue.

I'll give freetype-gl a try then, hopefully it'll fit what we need!