OpenGL ES (displaying model)
I have loaded and displayed an wavefront .obj model in OpenGL perfectly, but the same model displays crazy in OGL ES. It is missing polygons, like there are triangles missing or being connected incorrectly. Culling is not turned on. The same code works perfectly in OpenGL.
Does anybody else have this problem. Here is the rendering source using vertex arrays:
Does anybody else have this problem. Here is the rendering source using vertex arrays:
Code:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, va_verts);
if ( numNormals > 0 ) {
glNormalPointer(GL_FLOAT, 0, va_norms);
glEnableClientState(GL_NORMAL_ARRAY);
}
if ( numTexCoords > 0 ) {
glTexCoordPointer(2, GL_FLOAT, 0, va_textures);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glDrawElements(GL_TRIANGLES, numTriVerts, GL_UNSIGNED_SHORT, va_indices);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
I'll reply to my own post, it may help someone.
Looks like glDrawElements wants the triangles to be connected together, and in a particular order. So for now I am going to use glDrawArrays, though eventually will SEEK :
something more efficient.
Looks like glDrawElements wants the triangles to be connected together, and in a particular order. So for now I am going to use glDrawArrays, though eventually will SEEK :

Code:
glPushMatrix();
glTranslatef(0, 0.45f, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, a_vertData);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, a_texData);
for (i=0; i < a_facesCount; i++) {
glDrawArrays(GL_TRIANGLES, (i * 3), 3);
}
glPopMatrix();
Hi green_ghost,
Did the 2nd code solve your problem? I am still struggling with the same problem like how you said.
Did the 2nd code solve your problem? I am still struggling with the same problem like how you said.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
UIView Subclass not displaying controls... | flipflop | 7 | 9,878 |
May 13, 2010 01:16 PM Last Post: flipflop |
|
Problem displaying point sprites | Duddd | 0 | 3,035 |
Feb 12, 2010 02:45 AM Last Post: Duddd |
|
conditionally displaying interface elements | aerospaceman | 2 | 3,905 |
Jun 25, 2009 12:20 PM Last Post: aerospaceman |