shithub: cstory

Download patch

ref: 706aff0c8c9f6c518b88cb8d1ca875a0e7d05544
parent: 607bbfcef85c488dfefef1ce30a3e614b4adb6e1
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Jul 31 19:43:08 EDT 2019

Remove more redundant OpenGL code

--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -548,6 +548,13 @@
 
 static void DrawGlyphCommon(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
+	if (glyph == NULL || surface == NULL)
+		return;
+
+	// Point our framebuffer to the destination texture
+	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
+	glViewport(0, 0, surface->width, surface->height);
+
 	glUseProgram(program_glyph);
 
 	// Enable texture coordinates, since this uses textures
@@ -586,25 +593,11 @@
 
 void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
-	if (glyph == NULL || surface == NULL)
-		return;
-
-	// Point our framebuffer to the destination texture
-	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
-	glViewport(0, 0, surface->width, surface->height);
-
 	DrawGlyphCommon(surface, glyph, x, y, colours);
 }
 
 void Backend_DrawGlyphToScreen(Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
-	if (glyph == NULL)
-		return;
-
-	// Point our framebuffer to the screen texture
-	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer_surface.texture_id, 0);
-	glViewport(0, 0, framebuffer_surface.width, framebuffer_surface.height);
-
 	DrawGlyphCommon(&framebuffer_surface, glyph, x, y, colours);
 }