Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

enter image description here

//note: this code is only for 2 triangles, while on picture there is 4 triangles
float tex_coord[] =
   0.0, 0.0, //3
   0.0, 1.0, //2
   1.0, 1.0, //0
   1.0, 1.0, //0
   1.0, 0.0, //1
   0.0, 0.0  //3

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

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

The result :

enter image description here

share|improve this question
Your first image has 4 triangles but the second one has only 2 – msell Nov 10 '12 at 20:38
Yes you are right but problem is the same with 2 or 4. I updated picture. – tigrou Nov 10 '12 at 20:47
up vote 2 down vote accepted

In your code you need 4 texture coords; one for each position in vertices.

tex_coord[2] & text_coord[3] are the same, even though they are for different vertices.

Change text_coord[2] to 1.0,0 ; should fix the problem.

share|improve this answer
I tried what you said and it worked! My mistake was to think i have to provide a pair of texture coords every time a vertex is used in a triangle, while I should only give one texture coord per vertex (no mater how much times the vertex is used ) – tigrou Nov 11 '12 at 19:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.