shithub: cstory

Download patch

ref: 64f2a78279e01e4178e7af4700e0240406c51221
parent: fc0653e5aaefc94f4c610cfb5d4370cd0db6b039
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Aug 10 15:23:29 EDT 2019

OpenGL: Remove SetFramebufferTarget

It's causing state conflicts in the enhanced branch. Also, with the
new vertex batching, state changes are minimised, so this function
is redundant.

--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -224,18 +224,6 @@
 	return program_id;
 }
 
-static void SetFramebufferTarget(Backend_Surface *surface)
-{
-	static Backend_Surface *last_framebuffer_target;
-
-	if (surface != last_framebuffer_target)
-	{
-		last_framebuffer_target = surface;
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
-		glViewport(0, 0, surface->width, surface->height);
-	}
-}
-
 static VertexBufferSlot* GetVertexBufferSlot(void)
 {
 	static unsigned long max_slots = 0;
@@ -522,7 +510,8 @@
 		last_destination_surface = destination_surface;
 
 		// Point our framebuffer to the destination texture
-		SetFramebufferTarget(destination_surface);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, destination_surface->texture_id, 0);
+		glViewport(0, 0, destination_surface->width, destination_surface->height);
 
 		// Switch to colour-key shader if we have to
 		glUseProgram(colour_key ? program_texture_colour_key : program_texture);
@@ -610,7 +599,8 @@
 		last_blue = blue;
 
 		// Point our framebuffer to the destination texture
-		SetFramebufferTarget(surface);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
+		glViewport(0, 0, surface->width, surface->height);
 
 		glUseProgram(program_colour_fill);
 
@@ -774,7 +764,8 @@
 		}
 
 		// Point our framebuffer to the destination texture
-		SetFramebufferTarget(surface);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
+		glViewport(0, 0, surface->width, surface->height);
 
 		glEnable(GL_BLEND);