Implemented OpenGL ES RenderClear()
authorSam Lantinga <slouken@libsdl.org>
Thu, 17 Feb 2011 02:23:48 -0800
changeset 53335d3a2cd4e8c9
parent 5332 ae8b6fb1feaf
child 5335 2bb1233924f1
Implemented OpenGL ES RenderClear()
src/render/SDL_render.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/SDL_render.c	Thu Feb 17 02:18:41 2011 -0800
     1.2 +++ b/src/render/SDL_render.c	Thu Feb 17 02:23:48 2011 -0800
     1.3 @@ -848,21 +848,6 @@
     1.4  {
     1.5      CHECK_RENDERER_MAGIC(renderer, -1);
     1.6  
     1.7 -    if (!renderer->RenderClear) {
     1.8 -        SDL_BlendMode blendMode = renderer->blendMode;
     1.9 -        int status;
    1.10 -
    1.11 -        if (blendMode >= SDL_BLENDMODE_BLEND) {
    1.12 -            SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
    1.13 -        }
    1.14 -
    1.15 -        status = SDL_RenderFillRect(renderer, NULL);
    1.16 -
    1.17 -        if (blendMode >= SDL_BLENDMODE_BLEND) {
    1.18 -            SDL_SetRenderDrawBlendMode(renderer, blendMode);
    1.19 -        }
    1.20 -        return status;
    1.21 -    }
    1.22      return renderer->RenderClear(renderer);
    1.23  }
    1.24  
     2.1 --- a/src/render/opengles/SDL_render_gles.c	Thu Feb 17 02:18:41 2011 -0800
     2.2 +++ b/src/render/opengles/SDL_render_gles.c	Thu Feb 17 02:23:48 2011 -0800
     2.3 @@ -54,6 +54,7 @@
     2.4  static void GLES_UnlockTexture(SDL_Renderer * renderer,
     2.5                                 SDL_Texture * texture);
     2.6  static int GLES_UpdateViewport(SDL_Renderer * renderer);
     2.7 +static int GLES_RenderClear(SDL_Renderer * renderer);
     2.8  static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
     2.9                                   const SDL_Point * points, int count);
    2.10  static int GLES_RenderDrawLines(SDL_Renderer * renderer,
    2.11 @@ -180,6 +181,7 @@
    2.12      renderer->LockTexture = GLES_LockTexture;
    2.13      renderer->UnlockTexture = GLES_UnlockTexture;
    2.14      renderer->UpdateViewport = GLES_UpdateViewport;
    2.15 +    renderer->RenderClear = GLES_RenderClear;
    2.16      renderer->RenderDrawPoints = GLES_RenderDrawPoints;
    2.17      renderer->RenderDrawLines = GLES_RenderDrawLines;
    2.18      renderer->RenderFillRects = GLES_RenderFillRects;
    2.19 @@ -451,6 +453,21 @@
    2.20      return 0;
    2.21  }
    2.22  
    2.23 +static int
    2.24 +GLES_RenderClear(SDL_Renderer * renderer)
    2.25 +{
    2.26 +    GLES_ActivateRenderer(renderer);
    2.27 +
    2.28 +    glClearColor((GLfloat) renderer->r * inv255f,
    2.29 +                 (GLfloat) renderer->g * inv255f,
    2.30 +                 (GLfloat) renderer->b * inv255f,
    2.31 +                 (GLfloat) renderer->a * inv255f);
    2.32 +
    2.33 +    glClear(GL_COLOR_BUFFER_BIT);
    2.34 +
    2.35 +    return 0;
    2.36 +}
    2.37 +
    2.38  static void
    2.39  GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
    2.40  {
     3.1 --- a/src/render/opengles2/SDL_render_gles2.c	Thu Feb 17 02:18:41 2011 -0800
     3.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Thu Feb 17 02:23:48 2011 -0800
     3.3 @@ -770,19 +770,19 @@
     3.4                              const SDL_Rect *dstrect);
     3.5  static void GLES2_RenderPresent(SDL_Renderer *renderer);
     3.6  
     3.7 +
     3.8  static int
     3.9 -GLES2_RenderClear(SDL_Renderer *renderer)
    3.10 +GLES2_RenderClear(SDL_Renderer * renderer)
    3.11  {
    3.12 -    float r = (float)renderer->r * inv255f;
    3.13 -    float g = (float)renderer->g * inv255f;
    3.14 -    float b = (float)renderer->b * inv255f;
    3.15 -    float a = (float)renderer->a * inv255f;
    3.16 -
    3.17      GLES2_ActivateRenderer(renderer);
    3.18  
    3.19 -    /* Clear the backbuffer with the selected color */
    3.20 -    glClearColor(r, g, b, a);
    3.21 +    glClearColor((GLfloat) renderer->r * inv255f,
    3.22 +                 (GLfloat) renderer->g * inv255f,
    3.23 +                 (GLfloat) renderer->b * inv255f,
    3.24 +                 (GLfloat) renderer->a * inv255f);
    3.25 +
    3.26      glClear(GL_COLOR_BUFFER_BIT);
    3.27 +
    3.28      return 0;
    3.29  }
    3.30