opengles2: Fixed several incorrect things.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 77ba194..97d1d44 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -878,8 +878,7 @@ GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture *
if (flip & SDL_FLIP_HORIZONTAL) {
minx = dstrect->x + dstrect->w;
maxx = dstrect->x;
- }
- else {
+ } else {
minx = dstrect->x;
maxx = dstrect->x + dstrect->w;
}
@@ -887,16 +886,16 @@ GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture *
if (flip & SDL_FLIP_VERTICAL) {
miny = dstrect->y + dstrect->h;
maxy = dstrect->y;
- }
- else {
+ } else {
miny = dstrect->y;
maxy = dstrect->y + dstrect->h;
}
- minu = (GLfloat) (srcquad->x / texture->w);
- maxu = (GLfloat) ((srcquad->x + srcquad->w) / texture->w);
- minv = (GLfloat) (srcquad->y / texture->h);
- maxv = (GLfloat) ((srcquad->y + srcquad->h) / texture->h);
+ minu = ((GLfloat) srcquad->x) / ((GLfloat) texture->w);
+ maxu = ((GLfloat) (srcquad->x + srcquad->w)) / ((GLfloat) texture->w);
+ minv = ((GLfloat) srcquad->y) / ((GLfloat) texture->h);
+ maxv = ((GLfloat) (srcquad->y + srcquad->h)) / ((GLfloat) texture->h);
+
cmd->data.draw.count = 1;
@@ -988,7 +987,6 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->drawstate.texturing = SDL_FALSE;
} else {
data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD);
- data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 8)));
data->drawstate.texturing = SDL_TRUE;
}
}
@@ -1015,6 +1013,10 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->drawstate.texture = texture;
}
+ if (texture) {
+ data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 8)));
+ }
+
if (GLES2_SelectProgram(data, imgsrc, texture ? texture->w : 0, texture ? texture->h : 0) < 0) {
return -1;
}
@@ -1061,8 +1063,6 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
if (is_copy_ex) {
data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
- data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 16)));
- data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 24)));
} else {
data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
@@ -1070,6 +1070,11 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->drawstate.is_copy_ex = is_copy_ex;
}
+ if (is_copy_ex) {
+ data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 16)));
+ data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 24)));
+ }
+
return 0;
}