opengles2: Fixed several incorrect things. SDL-ryan-batching-renderer
authorRyan C. Gordon <icculus@icculus.org>
Sat, 06 Oct 2018 17:08:04 -0400
branchSDL-ryan-batching-renderer
changeset 123005d5d45f82f28
parent 12297 d1a491c3ad17
child 12349 a67dedb293c8
opengles2: Fixed several incorrect things.
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Thu Oct 04 21:10:42 2018 -0400
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sat Oct 06 17:08:04 2018 -0400
     1.3 @@ -878,8 +878,7 @@
     1.4      if (flip & SDL_FLIP_HORIZONTAL) {
     1.5          minx = dstrect->x + dstrect->w;
     1.6          maxx = dstrect->x;
     1.7 -    }
     1.8 -    else {
     1.9 +    } else {
    1.10          minx = dstrect->x;
    1.11          maxx = dstrect->x + dstrect->w;
    1.12      }
    1.13 @@ -887,16 +886,16 @@
    1.14      if (flip & SDL_FLIP_VERTICAL) {
    1.15          miny = dstrect->y + dstrect->h;
    1.16          maxy = dstrect->y;
    1.17 -    }
    1.18 -    else {
    1.19 +    } else {
    1.20          miny = dstrect->y;
    1.21          maxy = dstrect->y + dstrect->h;
    1.22      }
    1.23  
    1.24 -    minu = (GLfloat) (srcquad->x / texture->w);
    1.25 -    maxu = (GLfloat) ((srcquad->x + srcquad->w) / texture->w);
    1.26 -    minv = (GLfloat) (srcquad->y / texture->h);
    1.27 -    maxv = (GLfloat) ((srcquad->y + srcquad->h) / texture->h);
    1.28 +    minu = ((GLfloat) srcquad->x) / ((GLfloat) texture->w);
    1.29 +    maxu = ((GLfloat) (srcquad->x + srcquad->w)) / ((GLfloat) texture->w);
    1.30 +    minv = ((GLfloat) srcquad->y) / ((GLfloat) texture->h);
    1.31 +    maxv = ((GLfloat) (srcquad->y + srcquad->h)) / ((GLfloat) texture->h);
    1.32 +
    1.33  
    1.34      cmd->data.draw.count = 1;
    1.35  
    1.36 @@ -988,7 +987,6 @@
    1.37                  data->drawstate.texturing = SDL_FALSE;
    1.38              } else {
    1.39                  data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
    1.40 -                data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 8)));
    1.41                  data->drawstate.texturing = SDL_TRUE;
    1.42              }
    1.43          }
    1.44 @@ -1015,6 +1013,10 @@
    1.45          data->drawstate.texture = texture;
    1.46      }
    1.47  
    1.48 +    if (texture) {
    1.49 +        data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 8)));
    1.50 +    }
    1.51 +
    1.52      if (GLES2_SelectProgram(data, imgsrc, texture ? texture->w : 0, texture ? texture->h : 0) < 0) {
    1.53          return -1;
    1.54      }
    1.55 @@ -1061,8 +1063,6 @@
    1.56          if (is_copy_ex) {
    1.57              data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
    1.58              data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
    1.59 -            data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 16)));
    1.60 -            data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 24)));
    1.61          } else {
    1.62              data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
    1.63              data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
    1.64 @@ -1070,6 +1070,11 @@
    1.65          data->drawstate.is_copy_ex = is_copy_ex;
    1.66      }
    1.67  
    1.68 +    if (is_copy_ex) {
    1.69 +        data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 16)));
    1.70 +        data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 24)));
    1.71 +    }
    1.72 +
    1.73      return 0;
    1.74  }
    1.75