Skip to content
Permalink
Browse files

render: Fix OpenGL draw state cache for various points of texture bin…

…ding.
  • Loading branch information
icculus committed Feb 4, 2019
1 parent 670f3d3 commit 40a52ceef7bbafb9b89115a471503cd161d13baf
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/render/opengl/SDL_render_gl.c
@@ -443,6 +443,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)

GL_ActivateRenderer(renderer);

renderdata->drawstate.texture = NULL; /* we trash this state. */

if (texture->access == SDL_TEXTUREACCESS_TARGET &&
!renderdata->GL_EXT_framebuffer_object_supported) {
return SDL_SetError("Render targets not supported by OpenGL");
@@ -641,6 +643,8 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,

GL_ActivateRenderer(renderer);

renderdata->drawstate.texture = NULL; /* we trash this state. */

renderdata->glEnable(textype);
renderdata->glBindTexture(textype, data->texture);
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -702,6 +706,8 @@ GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,

GL_ActivateRenderer(renderer);

renderdata->drawstate.texture = NULL; /* we trash this state. */

renderdata->glEnable(textype);
renderdata->glBindTexture(textype, data->texture);
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -1469,6 +1475,9 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
}
data->glBindTexture(textype, texturedata->texture);

data->drawstate.texturing = SDL_TRUE;
data->drawstate.texture = texture;

if(texw) *texw = (float)texturedata->texw;
if(texh) *texh = (float)texturedata->texh;

@@ -1496,6 +1505,9 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)

data->glDisable(textype);

data->drawstate.texturing = SDL_FALSE;
data->drawstate.texture = NULL;

return 0;
}

0 comments on commit 40a52ce

Please sign in to comment.