Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Implemented OpenGL ES RenderClear()

  • Loading branch information
slouken committed Feb 17, 2011
1 parent 8c12d45 commit 64ac53e60065dd058c799e6838bbc609248bab56
Showing with 25 additions and 23 deletions.
  1. +0 −15 src/render/SDL_render.c
  2. +17 −0 src/render/opengles/SDL_render_gles.c
  3. +8 −8 src/render/opengles2/SDL_render_gles2.c
@@ -848,21 +848,6 @@ SDL_RenderClear(SDL_Renderer * renderer)
{
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);
}

@@ -54,6 +54,7 @@ static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
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 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
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 @@ GLES_UpdateViewport(SDL_Renderer * renderer)
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)
{
@@ -770,19 +770,19 @@ static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const
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;
}

0 comments on commit 64ac53e

Please sign in to comment.