Problem when texturing triangles using glVertexPointer()

Posted by tigrou on Game Development See other posts from Game Development or by tigrou
Published on 2012-11-10T20:04:22Z Indexed on 2012/11/10 23:18 UTC
Read the original article Hit count: 200

Filed under:
|
|

I'm having a problem for displaying a single quad, here is how i do :

enter image description here

float tex_coord[] =
{
   0.0, 0.0,
   0.0, 1.0,
   1.0, 1.0,
   1.0, 1.0,
   1.0, 0.0,
   0.0, 0.0
};  //how many coords should i give ?

int indexes[] = 
{
    3, 2, 0, 0, 1, 3
}

float vertexes[] = 
{
   -37, 0, 30,
   -38, 0, 29,
   -41, 0, 32,
   -42, 0, 31
}

 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 glEnableClientState(GL_VERTEX_ARRAY);
   glVertexPointer(3, GL_FLOAT, 0, vertexes);
   glTexCoordPointer(2, GL_FLOAT, 0, tex_coord);
   glDrawElements(GL_TRIANGLES, 2, GL_UNSIGNED_INT, indices);
 glDisableClientState(GL_VERTEX_ARRAY);
 glDisableClientState(GL_TEXTURE_COORD_ARRAY);

The result :

(with 2 triangles)

enter image description here

(with 4 triangles)

enter image description here

© Game Development or respective owner

Related posts about c++

Related posts about opengl