Beginner question about vertex arrays in OpenGL
Posted
by
MrDatabase
on Game Development
See other posts from Game Development
or by MrDatabase
Published on 2011-01-12T17:19:52Z
Indexed on
2011/01/12
17:59 UTC
Read the original article
Hit count: 292
Is there a special order in which vertices are entered into a vertex array? Currently I'm drawing single textures like this:
glBindTexture(GL_TEXTURE_2D, texName);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, coordinates);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
where vertices has four "xy pairs". This is working fine.
As a test I doubled the sizes of the vertices and coordinates arrays and changed the last line above to:
glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
since vertices now contains eight "xy pairs". I do see two textures (the second is intentionally offset from the first). However the textures are now distorted. I've tried passing GL_TRIANGLES to glDrawArrays instead of GL_TRIANGLE_STRIP but this doesn't work either. I'm so new to OpenGL that I thought it's best to just ask here :-)
Cheers!
© Game Development or respective owner