Fixed bug 4453 - GLES / GLES2: first white renderer clear cmd is drawn as black
authorSylvain Becker <sylvain.becker@gmail.com>
Sat, 12 Jan 2019 13:34:03 +0100
changeset 12531af47ff0de5ab
parent 12530 63abc8d1ca3a
child 12532 8db358c7a09a
Fixed bug 4453 - GLES / GLES2: first white renderer clear cmd is drawn as black
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles/SDL_render_gles.c	Fri Jan 11 21:52:43 2019 +0100
     1.2 +++ b/src/render/opengles/SDL_render_gles.c	Sat Jan 12 13:34:03 2019 +0100
     1.3 @@ -26,8 +26,8 @@
     1.4  #include "SDL_opengles.h"
     1.5  #include "../SDL_sysrender.h"
     1.6  
     1.7 -/* To prevent unnecessary window recreation, 
     1.8 - * these should match the defaults selected in SDL_GL_ResetAttributes 
     1.9 +/* To prevent unnecessary window recreation,
    1.10 + * these should match the defaults selected in SDL_GL_ResetAttributes
    1.11   */
    1.12  
    1.13  #define RENDERER_CONTEXT_MAJOR 1
    1.14 @@ -170,7 +170,7 @@
    1.15  #define SDL_PROC_OES(ret,func,params) \
    1.16      do { \
    1.17          data->func = SDL_GL_GetProcAddress(#func); \
    1.18 -    } while ( 0 );    
    1.19 +    } while ( 0 );
    1.20  #endif /* __SDL_NOGETPROCADDR__ */
    1.21  
    1.22  #include "SDL_glesfuncs.h"
    1.23 @@ -351,7 +351,7 @@
    1.24          }
    1.25      }
    1.26  
    1.27 -    
    1.28 +
    1.29      if (texture->access == SDL_TEXTUREACCESS_TARGET) {
    1.30          if (!renderdata->GL_OES_framebuffer_object_supported) {
    1.31              SDL_free(data);
    1.32 @@ -361,7 +361,7 @@
    1.33      } else {
    1.34          data->fbo = NULL;
    1.35      }
    1.36 -    
    1.37 +
    1.38  
    1.39      renderdata->glGetError();
    1.40      renderdata->glEnable(GL_TEXTURE_2D);
    1.41 @@ -397,7 +397,7 @@
    1.42          SDL_free(data);
    1.43          return GLES_SetError("glTexImage2D()", result);
    1.44      }
    1.45 -    
    1.46 +
    1.47      texture->driverdata = data;
    1.48      return 0;
    1.49  }
    1.50 @@ -1210,6 +1210,8 @@
    1.51      data->glEnableClientState(GL_VERTEX_ARRAY);
    1.52      data->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    1.53  
    1.54 +    data->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    1.55 +
    1.56      data->drawstate.blend = SDL_BLENDMODE_INVALID;
    1.57      data->drawstate.color = 0xFFFFFFFF;
    1.58      data->drawstate.clear_color = 0xFFFFFFFF;
     2.1 --- a/src/render/opengles2/SDL_render_gles2.c	Fri Jan 11 21:52:43 2019 +0100
     2.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sat Jan 12 13:34:03 2019 +0100
     2.3 @@ -30,7 +30,7 @@
     2.4  #include "SDL_shaders_gles2.h"
     2.5  
     2.6  /* To prevent unnecessary window recreation,
     2.7 - * these should match the defaults selected in SDL_GL_ResetAttributes 
     2.8 + * these should match the defaults selected in SDL_GL_ResetAttributes
     2.9   */
    2.10  #define RENDERER_CONTEXT_MAJOR 2
    2.11  #define RENDERER_CONTEXT_MINOR 0
    2.12 @@ -2076,6 +2076,7 @@
    2.13      renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES;
    2.14  #endif
    2.15  
    2.16 +    /* Set up parameters for rendering */
    2.17      data->glActiveTexture(GL_TEXTURE0);
    2.18      data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
    2.19      data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    2.20 @@ -2083,6 +2084,8 @@
    2.21      data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
    2.22      data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
    2.23  
    2.24 +    data->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    2.25 +
    2.26      data->drawstate.blend = SDL_BLENDMODE_INVALID;
    2.27      data->drawstate.color = 0xFFFFFFFF;
    2.28      data->drawstate.clear_color = 0xFFFFFFFF;