Some minor OpenGL cleanup
This commit is contained in:
parent
7146288e94
commit
d5ceed4f97
1 changed files with 9 additions and 11 deletions
|
@ -205,14 +205,15 @@ static GLuint CompileShader(const char *vertex_shader_source, const char *fragme
|
||||||
return program_id;
|
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;
|
last_framebuffer_target = surface;
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
|
||||||
|
glViewport(0, 0, surface->width, surface->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,8 +430,7 @@ static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backen
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Point our framebuffer to the destination texture
|
// Point our framebuffer to the destination texture
|
||||||
SetFramebufferTarget(destination_surface->texture_id);
|
SetFramebufferTarget(destination_surface);
|
||||||
glViewport(0, 0, destination_surface->width, destination_surface->height);
|
|
||||||
|
|
||||||
// Switch to colour-key shader if we have to
|
// Switch to colour-key shader if we have to
|
||||||
glUseProgram(colour_key ? program_texture_colour_key : program_texture);
|
glUseProgram(colour_key ? program_texture_colour_key : program_texture);
|
||||||
|
@ -495,8 +495,7 @@ static void ColourFillCommon(Backend_Surface *surface, const RECT *rect, unsigne
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Point our framebuffer to the destination texture
|
// Point our framebuffer to the destination texture
|
||||||
SetFramebufferTarget(surface->texture_id);
|
SetFramebufferTarget(surface);
|
||||||
glViewport(0, 0, surface->width, surface->height);
|
|
||||||
|
|
||||||
glUseProgram(program_colour_fill);
|
glUseProgram(program_colour_fill);
|
||||||
|
|
||||||
|
@ -620,8 +619,7 @@ static void DrawGlyphCommon(Backend_Surface *surface, Backend_Glyph *glyph, long
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Point our framebuffer to the destination texture
|
// Point our framebuffer to the destination texture
|
||||||
SetFramebufferTarget(surface->texture_id);
|
SetFramebufferTarget(surface);
|
||||||
glViewport(0, 0, surface->width, surface->height);
|
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue