@@ -975,8 +975,8 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
975975 }
976976
977977 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 )) );
980980 }
981981
982982 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
10091009
10101010 /* all drawing commands use this */
10111011 {
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 )) );
10151015 }
10161016
10171017 return 0 ;
@@ -1200,7 +1200,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
12001200 if (data -> current_vertex_buffer >= SDL_arraysize (data -> vertex_buffers )) {
12011201 data -> current_vertex_buffer = 0 ;
12021202 }
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).
12041205#endif
12051206
12061207 while (cmd ) {
0 commit comments