I'm trying to draw a textured triangulated indexed quad using glDrawElements but failed with distortion. My verts,norms and uv data all worked correctly with glBegin/glEnd. Upon tweaking, I found that it only worked if input uvs/norms array are poly based(4 pts) instead of per indices of 2 triangles(6 pts). Did i missed something? Here's my failed python code.
Code :glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2,GL_FLOAT,0,self.uvRef); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointerf(self.normsRef); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointerf(self.vertsRef); #glDrawElementsus(GL_TRIANGLES,self.indicesRef); Both not working glDrawElements(GL_TRIANGLES,self.indicesSize,GL_UNSIGNED_SHORT,self.indicesRef);
Heres my working glBegin/End inserted before hack:
Code :glBegin(GL_TRIANGLES); for i in range(self.indicesSize): index=self.indicesRef[i]; glTexCoord2f(self.uvRef[i][0],self.uvRef[i][1]); glNormal3f(self.normsRef[i][0],self.normsRef[i][1],self.normsRef[i][2]); glVertex3f(self.vertsRef[index][0],self.vertsRef[index][1],self.vertsRef[index][2]); glEnd();
Any ideas?
Thanks.




