rswinkle / PortableGL

An implementation of OpenGL 3.x-ish in clean C
MIT License
1.04k stars 49 forks source link

Supported Vector Font Libraries? #15

Closed khatharr closed 1 year ago

khatharr commented 1 year ago

First of all, you're doing the net.gods' own work here, sir. Thank you for this project.

I'm wondering if you've had success using a font library such as freetype with this, and if so I'd greatly appreciate any information about which one(s) and how it went. I'm just trying to write something to render a background image with a calendar drawn on top of it and dump it into a png, so PortableGL looks perfect so long as I can draw text without reinventing the wheel.

Edit Actually, now that I'm looking directly at FreeType for the first time in a decade or so, it looks like it's independent from the renderer, so I'm in business. Sorry to bug you, and thanks again for the project. 😁

rswinkle commented 1 year ago

Yeah, That was what I was going to say (just saw the email with your original comment). Basically any of the font rendering libraries, Freetype, stb_truetype, even SDL_ttf, I think they all support at least 2 methods. The first is creating a single texture atlas of all the characters/graphemes you might use and then you render them individually as quads (or 2 triangles) with the library giving you the necessary information (cached uv's for each character, screen space coordinates for each quad in a given string at run time). The second, you can create complete pre-rendered textures of all the specific strings you want and apply all of those textures however you want, but most equivalently, on an appropriately sized rectangle. There are pros and cons to each and sometimes you might even mix both approaches in a single application.

I'll go ahead and close this but good luck with your project and let me know if you have any questions or run into any issues. I've been really busy with the regular life/day job/other projects the last couple months but I do hope spend some serious time on PortableGL in the coming months.