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.
Also fixed the SDL_Window not being freed. This commit's a bit of a
blob, since I made a bunch of tweaks to Draw.cpp while adding the new
renderer. Don't worry though, I'll add the hardware accelerated code
back again soon. In fact, I've got an idea on how to make it even
faster, while still being able to survive render target losses.
Hopefully this software renderer will come in handy for the Wii U
port: its SDL2 port's hardware acceleration is broken, and the
SDL_Surface API is too slow.