render: Fix OpenGL draw state cache for various points of texture binding.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 04 Feb 2019 18:55:39 -0500
changeset 1259210722106b650
parent 12591 66cd8731c3b1
child 12593 307b9da13612
render: Fix OpenGL draw state cache for various points of texture binding.
src/render/opengl/SDL_render_gl.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Mon Feb 04 09:11:07 2019 +0100
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon Feb 04 18:55:39 2019 -0500
     1.3 @@ -443,6 +443,8 @@
     1.4  
     1.5      GL_ActivateRenderer(renderer);
     1.6  
     1.7 +    renderdata->drawstate.texture = NULL;  /* we trash this state. */
     1.8 +
     1.9      if (texture->access == SDL_TEXTUREACCESS_TARGET &&
    1.10          !renderdata->GL_EXT_framebuffer_object_supported) {
    1.11          return SDL_SetError("Render targets not supported by OpenGL");
    1.12 @@ -641,6 +643,8 @@
    1.13  
    1.14      GL_ActivateRenderer(renderer);
    1.15  
    1.16 +    renderdata->drawstate.texture = NULL;  /* we trash this state. */
    1.17 +
    1.18      renderdata->glEnable(textype);
    1.19      renderdata->glBindTexture(textype, data->texture);
    1.20      renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    1.21 @@ -702,6 +706,8 @@
    1.22  
    1.23      GL_ActivateRenderer(renderer);
    1.24  
    1.25 +    renderdata->drawstate.texture = NULL;  /* we trash this state. */
    1.26 +
    1.27      renderdata->glEnable(textype);
    1.28      renderdata->glBindTexture(textype, data->texture);
    1.29      renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    1.30 @@ -1469,6 +1475,9 @@
    1.31      }
    1.32      data->glBindTexture(textype, texturedata->texture);
    1.33  
    1.34 +    data->drawstate.texturing = SDL_TRUE;
    1.35 +    data->drawstate.texture = texture;
    1.36 +
    1.37      if(texw) *texw = (float)texturedata->texw;
    1.38      if(texh) *texh = (float)texturedata->texh;
    1.39  
    1.40 @@ -1496,6 +1505,9 @@
    1.41  
    1.42      data->glDisable(textype);
    1.43  
    1.44 +    data->drawstate.texturing = SDL_FALSE;
    1.45 +    data->drawstate.texture = NULL;
    1.46 +
    1.47      return 0;
    1.48  }
    1.49