src/video/SDL_renderer_gles.c
changeset 3641 1e2e19d51265
parent 3547 8b18669c2663
child 3685 64ce267332c6
     1.1 --- a/src/video/SDL_renderer_gles.c	Mon Jan 11 21:49:09 2010 +0000
     1.2 +++ b/src/video/SDL_renderer_gles.c	Wed Jan 13 04:58:31 2010 +0000
     1.3 @@ -85,12 +85,14 @@
     1.4                                 SDL_Texture * texture);
     1.5  static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     1.6                                int numrects, const SDL_Rect * rects);
     1.7 -static int GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
     1.8 -                             int count);
     1.9 -static int GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
    1.10 -                            int count);
    1.11 -static int GLES_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
    1.12 -                            int count);
    1.13 +static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
    1.14 +                                 const SDL_Point * points, int count);
    1.15 +static int GLES_RenderDrawLines(SDL_Renderer * renderer,
    1.16 +                                const SDL_Point * points, int count);
    1.17 +static int GLES_RenderDrawRects(SDL_Renderer * renderer,
    1.18 +                                const SDL_Rect ** rects, int count);
    1.19 +static int GLES_RenderFillRects(SDL_Renderer * renderer,
    1.20 +                                const SDL_Rect ** rects, int count);
    1.21  static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    1.22                             const SDL_Rect * srcrect,
    1.23                             const SDL_Rect * dstrect);
    1.24 @@ -244,9 +246,10 @@
    1.25      renderer->LockTexture = GLES_LockTexture;
    1.26      renderer->UnlockTexture = GLES_UnlockTexture;
    1.27      renderer->DirtyTexture = GLES_DirtyTexture;
    1.28 -    renderer->RenderPoints = GLES_RenderPoints;
    1.29 -    renderer->RenderLines = GLES_RenderLines;
    1.30 -    renderer->RenderRects = GLES_RenderRects;
    1.31 +    renderer->RenderDrawPoints = GLES_RenderDrawPoints;
    1.32 +    renderer->RenderDrawLines = GLES_RenderDrawLines;
    1.33 +    renderer->RenderDrawRects = GLES_RenderDrawRects;
    1.34 +    renderer->RenderFillRects = GLES_RenderFillRects;
    1.35      renderer->RenderCopy = GLES_RenderCopy;
    1.36      renderer->RenderPresent = GLES_RenderPresent;
    1.37      renderer->DestroyTexture = GLES_DestroyTexture;
    1.38 @@ -371,7 +374,6 @@
    1.39  GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
    1.40  {
    1.41      GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
    1.42 -    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
    1.43      GLES_TextureData *data;
    1.44      GLint internalFormat;
    1.45      GLenum format, type;
    1.46 @@ -643,7 +645,8 @@
    1.47  }
    1.48  
    1.49  static int
    1.50 -GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
    1.51 +GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    1.52 +                      int count)
    1.53  {
    1.54      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    1.55      int i;
    1.56 @@ -671,7 +674,8 @@
    1.57  }
    1.58  
    1.59  static int
    1.60 -GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
    1.61 +GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    1.62 +                     int count)
    1.63  {
    1.64      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    1.65      int i;
    1.66 @@ -706,7 +710,47 @@
    1.67  }
    1.68  
    1.69  static int
    1.70 -GLES_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
    1.71 +GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
    1.72 +                     int count)
    1.73 +{
    1.74 +    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    1.75 +    int i;
    1.76 +
    1.77 +    GLES_SetBlendMode(data, renderer->blendMode, 1);
    1.78 +
    1.79 +    data->glColor4f((GLfloat) renderer->r * inv255f,
    1.80 +                    (GLfloat) renderer->g * inv255f,
    1.81 +                    (GLfloat) renderer->b * inv255f,
    1.82 +                    (GLfloat) renderer->a * inv255f);
    1.83 +
    1.84 +    data->glEnableClientState(GL_VERTEX_ARRAY);
    1.85 +    for (i = 0; i < count; ++i) {
    1.86 +        const SDL_Rect *rect = rects[i];
    1.87 +        GLshort minx = rect->x;
    1.88 +        GLshort maxx = rect->x + rect->w;
    1.89 +        GLshort miny = rect->y;
    1.90 +        GLshort maxy = rect->y + rect->h;
    1.91 +        GLshort vertices[8];
    1.92 +        vertices[0] = minx;
    1.93 +        vertices[1] = miny;
    1.94 +        vertices[2] = maxx;
    1.95 +        vertices[3] = miny;
    1.96 +        vertices[4] = minx;
    1.97 +        vertices[5] = maxy;
    1.98 +        vertices[6] = maxx;
    1.99 +        vertices[7] = maxy;
   1.100 +
   1.101 +        data->glVertexPointer(2, GL_SHORT, 0, vertices);
   1.102 +        data->glDrawArrays(GL_LINE_LOOP, 0, 4);
   1.103 +    }
   1.104 +    data->glDisableClientState(GL_VERTEX_ARRAY);
   1.105 +
   1.106 +    return 0;
   1.107 +}
   1.108 +
   1.109 +static int
   1.110 +GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   1.111 +                     int count)
   1.112  {
   1.113      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
   1.114      int i;
   1.115 @@ -898,7 +942,6 @@
   1.116  static void
   1.117  GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.118  {
   1.119 -    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
   1.120      GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
   1.121  
   1.122      if (!data) {