@@ -1022,8 +1022,8 @@ static bool SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, c
1022
1022
}
1023
1023
1024
1024
if (texture ) {
1025
- SDL_Vertex * verts = (SDL_Vertex * )((( Uint8 * ) vertices ) + cmd -> data .draw .first );
1026
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_TEXCOORD , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )& verts -> tex_coord );
1025
+ uintptr_t base = (uintptr_t ) vertices + cmd -> data .draw .first ; // address of first vertex, or base offset when using VBOs.
1026
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_TEXCOORD , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )( base + offsetof( SDL_Vertex , tex_coord )) );
1027
1027
}
1028
1028
1029
1029
SDL_Colorspace colorspace = texture ? texture -> colorspace : SDL_COLORSPACE_SRGB ;
@@ -1057,9 +1057,9 @@ static bool SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, c
1057
1057
1058
1058
// all drawing commands use this
1059
1059
{
1060
- SDL_VertexSolid * verts = (SDL_VertexSolid * )((( Uint8 * ) vertices ) + cmd -> data .draw .first );
1061
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_POSITION , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )& verts -> position );
1062
- data -> glVertexAttribPointer (GLES2_ATTRIBUTE_COLOR , 4 , GL_FLOAT , GL_TRUE /* Normalized */ , stride , (const GLvoid * )& verts -> color );
1060
+ uintptr_t base = (uintptr_t ) vertices + cmd -> data .draw .first ; // address of first vertex, or base offset when using VBOs.
1061
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_POSITION , 2 , GL_FLOAT , GL_FALSE , stride , (const GLvoid * )( base + offsetof( SDL_VertexSolid , position )) );
1062
+ data -> glVertexAttribPointer (GLES2_ATTRIBUTE_COLOR , 4 , GL_FLOAT , GL_TRUE /* Normalized */ , stride , (const GLvoid * )( base + offsetof( SDL_VertexSolid , color )) );
1063
1063
}
1064
1064
1065
1065
return true;
@@ -1375,7 +1375,8 @@ static bool GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
1375
1375
if (data -> current_vertex_buffer >= SDL_arraysize (data -> vertex_buffers )) {
1376
1376
data -> current_vertex_buffer = 0 ;
1377
1377
}
1378
- vertices = NULL ; // attrib pointers will be offsets into the VBO.
1378
+ // attrib pointers will be offsets into the VBO.
1379
+ vertices = (void * )(uintptr_t )0 ; // must be the exact value 0, not NULL (the representation of NULL is not guaranteed to be 0).
1379
1380
#endif
1380
1381
1381
1382
while (cmd ) {
0 commit comments