ref: 514d9f873912054e083b927fcf731637a3a4d0c0
parent: d84f64a5a9cece9e6f5842f589db0604be537f4b
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Feb 1 19:21:28 EST 2020
Document the OpenGL renderer a bit more This makes it easier to find things
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -254,6 +254,10 @@
printf("OpenGL debug: %s\n", message);
}
*/
+// ====================
+// Shader compilation
+// ====================
+
static GLuint CompileShader(const char *vertex_shader_source, const char *fragment_shader_source)
{
GLint shader_status;
@@ -307,6 +311,10 @@
return program_id;
}
+// ====================
+// Vertex buffer management
+// ====================
+
static VertexBufferSlot* GetVertexBufferSlot(unsigned int slots_needed)
{
if (current_vertex_buffer_slot + slots_needed > local_vertex_buffer_size)
@@ -354,6 +362,10 @@
current_vertex_buffer_slot = 0;
}
+// ====================
+// Glyph-batching
+// ====================
+
// Blit the glyphs in the batch
static void GlyphBatch_Draw(spritebatch_sprite_t *sprites, int count, int texture_w, int texture_h, void *udata)
{
@@ -492,6 +504,10 @@
glDeleteTextures(1, (GLuint*)&texture_id);
}
+// ====================
+// Render-backend initialisation
+// ====================
+
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
{
#ifdef USE_OPENGLES2
@@ -753,6 +769,10 @@
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
}
+// ====================
+// Surface management
+// ====================
+
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
{
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
@@ -832,6 +852,10 @@
glBindTexture(GL_TEXTURE_2D, previously_bound_texture);
}
+// ====================
+// Drawing
+// ====================
+
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
{
static Backend_Surface *last_source_surface;
@@ -968,6 +992,10 @@
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
}
+// ====================
+// Glyph management
+// ====================
+
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
{
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
@@ -1026,6 +1054,10 @@
spritebatch_defrag(&glyph_batcher);
spritebatch_flush(&glyph_batcher);
}
+
+// ====================
+// Misc.
+// ====================
void Backend_HandleRenderTargetLoss(void)
{
--
⑨