render: opengles renderer actually works now. :) SDL-ryan-batching-renderer
authorRyan C. Gordon <icculus@icculus.org>
Tue, 25 Sep 2018 16:17:10 -0400
branchSDL-ryan-batching-renderer
changeset 1223519863e13a81a
parent 12219 0d5da1145cad
child 12236 80367def8b68
render: opengles renderer actually works now. :)
src/render/opengles/SDL_render_gles.c
     1.1 --- a/src/render/opengles/SDL_render_gles.c	Tue Sep 25 10:41:25 2018 -0400
     1.2 +++ b/src/render/opengles/SDL_render_gles.c	Tue Sep 25 16:17:10 2018 -0400
     1.3 @@ -556,7 +556,7 @@
     1.4  GLES_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
     1.5                            const SDL_Rect * srcrect, const SDL_FRect * dstrect)
     1.6  {
     1.7 -    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
     1.8 +    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
     1.9      GLfloat minx, miny, maxx, maxy;
    1.10      GLfloat minu, maxu, minv, maxv;
    1.11      GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, 16 * sizeof (GLfloat), 0, &cmd->data.draw.first);
    1.12 @@ -607,7 +607,7 @@
    1.13                          const SDL_Rect * srcquad, const SDL_FRect * dstrect,
    1.14                          const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
    1.15  {
    1.16 -    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
    1.17 +    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
    1.18      GLfloat minx, miny, maxx, maxy;
    1.19      GLfloat centerx, centery;
    1.20      GLfloat minu, maxu, minv, maxv;
    1.21 @@ -638,13 +638,13 @@
    1.22          maxy =  dstrect->h - centery;
    1.23      }
    1.24  
    1.25 -    minu = (GLfloat) srcrect->x / texture->w;
    1.26 +    minu = (GLfloat) srcquad->x / texture->w;
    1.27      minu *= texturedata->texw;
    1.28 -    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
    1.29 +    maxu = (GLfloat) (srcquad->x + srcquad->w) / texture->w;
    1.30      maxu *= texturedata->texw;
    1.31 -    minv = (GLfloat) srcrect->y / texture->h;
    1.32 +    minv = (GLfloat) srcquad->y / texture->h;
    1.33      minv *= texturedata->texh;
    1.34 -    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
    1.35 +    maxv = (GLfloat) (srcquad->y + srcquad->h) / texture->h;
    1.36      maxv *= texturedata->texh;
    1.37  
    1.38      cmd->data.draw.count = 1;
    1.39 @@ -723,10 +723,11 @@
    1.40               SDL_Texture **current_texture)
    1.41  {
    1.42      SDL_Texture *texture = cmd->data.draw.texture;
    1.43 -    SetDrawState(data, cmd, shader, current_blend, current_texturing);
    1.44 +    SetDrawState(data, cmd, current_blend, current_texturing);
    1.45  
    1.46      if (texture != *current_texture) {
    1.47 -        data->glBindTexture(textype, texturedata->texture);
    1.48 +        GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
    1.49 +        data->glBindTexture(GL_TEXTURE_2D, texturedata->texture);
    1.50          *current_texture = texture;
    1.51      }
    1.52  }
    1.53 @@ -738,7 +739,6 @@
    1.54      SDL_Rect viewport;
    1.55      SDL_Texture *bound_texture = NULL;
    1.56      SDL_BlendMode blend = SDL_BLENDMODE_INVALID;
    1.57 -    GLES_Shader shader = SHADER_INVALID;
    1.58      int drawablew = 0, drawableh = 0;
    1.59      SDL_bool cliprect_enabled = SDL_FALSE;
    1.60      const SDL_bool istarget = renderer->target != NULL;
    1.61 @@ -824,24 +824,23 @@
    1.62                  const size_t count = cmd->data.draw.count;
    1.63                  const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
    1.64                  SetDrawState(data, cmd, &blend, &texturing);
    1.65 -                data->glVertexPointer(2, GL_FLOAT, 0, vertices);
    1.66 +                data->glVertexPointer(2, GL_FLOAT, 0, verts);
    1.67                  data->glDrawArrays(GL_POINTS, 0, count);
    1.68                  break;
    1.69              }
    1.70  
    1.71              case SDL_RENDERCMD_DRAW_LINES: {
    1.72                  const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
    1.73 -                size_t count = cmd->data.draw.count;
    1.74 +                const size_t count = cmd->data.draw.count;
    1.75                  SetDrawState(data, cmd, &blend, &texturing);
    1.76                  data->glVertexPointer(2, GL_FLOAT, 0, verts);
    1.77 -                if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
    1.78 +                if (count > 2 && (verts[0] == verts[(count-1)*2]) && (verts[1] == verts[(count*2)-1])) {
    1.79                      /* GL_LINE_LOOP takes care of the final segment */
    1.80 -                    --count;
    1.81 -                    data->glDrawArrays(GL_LINE_LOOP, 0, count);
    1.82 +                    data->glDrawArrays(GL_LINE_LOOP, 0, count - 1);
    1.83                  } else {
    1.84                      data->glDrawArrays(GL_LINE_STRIP, 0, count);
    1.85                      /* We need to close the endpoint of the line */
    1.86 -                    data->glDrawArrays(GL_POINTS, count-1, 1);
    1.87 +                    data->glDrawArrays(GL_POINTS, count - 1, 1);
    1.88                  }
    1.89                  break;
    1.90              }
    1.91 @@ -892,7 +891,7 @@
    1.92          cmd = cmd->next;
    1.93      }
    1.94  
    1.95 -    return GL_CheckError("", renderer);
    1.96 +    return 0;
    1.97  }
    1.98  
    1.99  static int