Hello
I am currently developping a 3D model player using opengl ES.
I found good way to optimize my code with storing all my vertices in one array and the same for a texture.
It works perfectly but i’m encountering a problem then…
How am i supposed to do this with multitexturing ??
Here’s a pseudo code example since my question is not very accurate…
int main()
{
loading_textures_and_vertices(glfloat *tex_vertices, glfloat vertices);
while (42)
{
setting stuff…
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 1); //only using one texture
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, tex_vertices);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLES, 0, total_face_nbr);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
Now i am wondering if it won’t cost me too much performance to store vertices and tex_coords with their appropriate textures in a structure array and then looping through it (code coming after) while switching textures ?
it would look like this (assuming the first example)
for (int a = 0; a < struct_array_size; a++)
{
glBindTexture(GL_TEXTURE_2D, struct_array[a].tex_id);
glTexCoordPointer(2, GL_FLOAT, 0, struct_array[a].tex_vertices);
glVertexPointer(3, GL_FLOAT, 0, struct_array[a].vertices);
glDrawArrays(GL_TRIANGLES, 0, struct_array[a].face_nbr);
}
Do you know a better way to do this ?
Since there are a lot of useful things (like display lists) that are not avaiable in opengl ES ?
Thanks a lot for your time !