shithub: cstory

Download patch

ref: d5ceed4f97c5b0b13027f3e0212502c8831cd506
parent: 7146288e9490c8ebb9ed29beba67df02f66be1a3
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Aug 9 16:04:46 EDT 2019

Some minor OpenGL cleanup

--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -205,14 +205,15 @@
 	return program_id;
 }
 
-static void SetFramebufferTarget(GLuint texture_id)
+static void SetFramebufferTarget(Backend_Surface *surface)
 {
-	static GLuint last_framebuffer_target;
+	static Backend_Surface *last_framebuffer_target;
 
-	if (texture_id != last_framebuffer_target)
+	if (surface != last_framebuffer_target)
 	{
-		last_framebuffer_target = texture_id;
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
+		last_framebuffer_target = surface;
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
+		glViewport(0, 0, surface->width, surface->height);
 	}
 }
 
@@ -429,8 +430,7 @@
 		return;
 
 	// Point our framebuffer to the destination texture
-	SetFramebufferTarget(destination_surface->texture_id);
-	glViewport(0, 0, destination_surface->width, destination_surface->height);
+	SetFramebufferTarget(destination_surface);
 
 	// Switch to colour-key shader if we have to
 	glUseProgram(colour_key ? program_texture_colour_key : program_texture);
@@ -495,8 +495,7 @@
 		return;
 
 	// Point our framebuffer to the destination texture
-	SetFramebufferTarget(surface->texture_id);
-	glViewport(0, 0, surface->width, surface->height);
+	SetFramebufferTarget(surface);
 
 	glUseProgram(program_colour_fill);
 
@@ -620,8 +619,7 @@
 		return;
 
 	// Point our framebuffer to the destination texture
-	SetFramebufferTarget(surface->texture_id);
-	glViewport(0, 0, surface->width, surface->height);
+	SetFramebufferTarget(surface);
 
 	glEnable(GL_BLEND);