From 64f2a78279e01e4178e7af4700e0240406c51221 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 10 Aug 2019 19:23:29 +0100 Subject: [PATCH] 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. --- src/Backends/Rendering/OpenGL3.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index a1052a85..76d03099 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -224,18 +224,6 @@ static GLuint CompileShader(const char *vertex_shader_source, const char *fragme 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 @@ static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backen 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 @@ static void ColourFillCommon(Backend_Surface *surface, const RECT *rect, unsigne 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 @@ static void DrawGlyphCommon(Backend_Surface *surface, Backend_Glyph *glyph, long } // 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);