Goddammit 3.2 is so complex.
The reason I want 3.2 is because I'm not convinced Legacy OpenGL will
be well-supported in the future. 3.2 is about as far back as I can go
without breaking forward-compatibility (it was the first version to
introduce the Core Profile).
I'd replace it with a custom matrix, but I get the feeling the
overhead of uploading a 4x4 matrix every quad is higher than just
manipulating the vertexes CPU-side
Saves us having to do a bunch of extra legwork (setting up the blank
default texture, setting the colour modifier to white, etc.), and
should improve performance.
While I was at it, I made the colour modifier a uniform, so it only
has to be set once per quad, rather than once per vertex.
This replaces the glBegin/glEnd stuff. Even though vertex arrays
aren't removed from newer OpenGL versions like glBegin/glEnd are,
they *are* deprecated, so I want to switch to VBOs eventually.
I wonder if I could use SDL2's SDL_GL_GetProcAddress,
SDL_GL_ExtensionSupported, and SDL_GL_LoadLibrary functions to bypass
needing GLEW? Then again, I'd like to remove the dependency on SDL2
at some point as well...
This fixes the Texture backend bug that made the program take forever
to shut down:
The problem was that the font system would try to load a glyph that's
0 pixels wide/tall (likely the space character), which SDL2 didn't
like, so it would fail to allocate the texture, causing
Backend_CreateSurface, and by extension Backend_CreateGlyph, to
return a NULL. Later, upon shutdown, the font system would pass this
NULL to Backend_FreeGlyph, causing NULL pointer dereferences that
make the program take forever to shut down.
Personally, I think passing NULLs to the backend is valid behaviour,
so I've added a bunch of sanity checks to make sure they're never
dereferenced.
Hard mode. Wound up debugging a weird issue for about half an hour.
Turns out you don't need to reset the matrix when you switch
framebuffer target? I don't really know how that works.
Anyway, yay font rendering is in the OpenGL backend now.
Getting kinda messy, having to maintain two different ways of
drawing - colour-key and alpha-blending. In the enhanced branch,
which uses alpha-blending for everything, these can be merged.
I'm noticing a huge delay in shutdown time. There's probably a bug
in here.
Yay 100% hardware-acceleration. Yes, I know 2.1 is outdated and
crappy, but it was the easiest one to write. I'll probably make an
OpenGL 3.0 Core renderer at some point.
Anyway, font rendering isn't here yet, because I plan to overhaul it.