@@ -975,8 +975,8 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
975
975
}
976
976
977
977
if (texture ) {
978
- SDL_Vertex * verts = (SDL_Vertex * )((( Uint8 * ) vertices ) + cmd -> data .draw .first );
979
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_TEXCOORD , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )& verts -> tex_coord );
978
+ uintptr_t base = (uintptr_t ) vertices + cmd -> data .draw .first ; // address of first vertex, or base offset when using VBOs.
979
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_TEXCOORD , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )( base + offsetof( SDL_Vertex , tex_coord )) );
980
980
}
981
981
982
982
if (GLES2_SelectProgram (data , imgsrc , texture ? texture -> w : 0 , texture ? texture -> h : 0 ) < 0 ) {
@@ -1009,9 +1009,9 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
1009
1009
1010
1010
/* all drawing commands use this */
1011
1011
{
1012
- SDL_VertexSolid * verts = (SDL_VertexSolid * )((( Uint8 * ) vertices ) + cmd -> data .draw .first );
1013
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_POSITION , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )& verts -> position );
1014
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_COLOR , 4 , GL_UNSIGNED_BYTE , GL_TRUE /* Normalized */ , stride , (const GLvoid * )& verts -> color );
1012
+ uintptr_t base = (uintptr_t ) vertices + cmd -> data .draw .first ; // address of first vertex, or base offset when using VBOs.
1013
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_POSITION , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )( base + offsetof( SDL_VertexSolid , position )) );
1014
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_COLOR , 4 , GL_UNSIGNED_BYTE , GL_TRUE /* Normalized */ , stride , (const GLvoid * )( base + offsetof( SDL_VertexSolid , color )) );
1015
1015
}
1016
1016
1017
1017
return 0 ;
@@ -1200,7 +1200,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
1200
1200
if (data -> current_vertex_buffer >= SDL_arraysize (data -> vertex_buffers )) {
1201
1201
data -> current_vertex_buffer = 0 ;
1202
1202
}
1203
- vertices = NULL ; /* attrib pointers will be offsets into the VBO. */
1203
+ // attrib pointers will be offsets into the VBO.
1204
+ vertices = (void * )(uintptr_t )0 ; // must be the exact value 0, not NULL (the representation of NULL is not guaranteed to be 0).
1204
1205
#endif
1205
1206
1206
1207
while (cmd ) {
0 commit comments