Implemented OpenGL ES RenderClear()
authorSam Lantinga <slouken@libsdl.org>
Thu, 17 Feb 2011 02:23:48 -0800
changeset 5333 5d3a2cd4e8c9
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
--- a/src/render/SDL_render.c	Thu Feb 17 02:18:41 2011 -0800
+++ b/src/render/SDL_render.c	Thu Feb 17 02:23:48 2011 -0800
@@ -848,21 +848,6 @@
 {
     CHECK_RENDERER_MAGIC(renderer, -1);
 
-    if (!renderer->RenderClear) {
-        SDL_BlendMode blendMode = renderer->blendMode;
-        int status;
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
-        }
-
-        status = SDL_RenderFillRect(renderer, NULL);
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(renderer, blendMode);
-        }
-        return status;
-    }
     return renderer->RenderClear(renderer);
 }
 
--- a/src/render/opengles/SDL_render_gles.c	Thu Feb 17 02:18:41 2011 -0800
+++ b/src/render/opengles/SDL_render_gles.c	Thu Feb 17 02:23:48 2011 -0800
@@ -54,6 +54,7 @@
 static void GLES_UnlockTexture(SDL_Renderer * renderer,
                                SDL_Texture * texture);
 static int GLES_UpdateViewport(SDL_Renderer * renderer);
+static int GLES_RenderClear(SDL_Renderer * renderer);
 static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
                                  const SDL_Point * points, int count);
 static int GLES_RenderDrawLines(SDL_Renderer * renderer,
@@ -180,6 +181,7 @@
     renderer->LockTexture = GLES_LockTexture;
     renderer->UnlockTexture = GLES_UnlockTexture;
     renderer->UpdateViewport = GLES_UpdateViewport;
+    renderer->RenderClear = GLES_RenderClear;
     renderer->RenderDrawPoints = GLES_RenderDrawPoints;
     renderer->RenderDrawLines = GLES_RenderDrawLines;
     renderer->RenderFillRects = GLES_RenderFillRects;
@@ -451,6 +453,21 @@
     return 0;
 }
 
+static int
+GLES_RenderClear(SDL_Renderer * renderer)
+{
+    GLES_ActivateRenderer(renderer);
+
+    glClearColor((GLfloat) renderer->r * inv255f,
+                 (GLfloat) renderer->g * inv255f,
+                 (GLfloat) renderer->b * inv255f,
+                 (GLfloat) renderer->a * inv255f);
+
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    return 0;
+}
+
 static void
 GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
 {
--- a/src/render/opengles2/SDL_render_gles2.c	Thu Feb 17 02:18:41 2011 -0800
+++ b/src/render/opengles2/SDL_render_gles2.c	Thu Feb 17 02:23:48 2011 -0800
@@ -770,19 +770,19 @@
                             const SDL_Rect *dstrect);
 static void GLES2_RenderPresent(SDL_Renderer *renderer);
 
+
 static int
-GLES2_RenderClear(SDL_Renderer *renderer)
+GLES2_RenderClear(SDL_Renderer * renderer)
 {
-    float r = (float)renderer->r * inv255f;
-    float g = (float)renderer->g * inv255f;
-    float b = (float)renderer->b * inv255f;
-    float a = (float)renderer->a * inv255f;
-
     GLES2_ActivateRenderer(renderer);
 
-    /* Clear the backbuffer with the selected color */
-    glClearColor(r, g, b, a);
+    glClearColor((GLfloat) renderer->r * inv255f,
+                 (GLfloat) renderer->g * inv255f,
+                 (GLfloat) renderer->b * inv255f,
+                 (GLfloat) renderer->a * inv255f);
+
     glClear(GL_COLOR_BUFFER_BIT);
+
     return 0;
 }