OpenGL ES (displaying model)

Member
Posts: 35
Joined: 2008.06
Post: #1
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:

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);
Quote this message in a reply
Member
Posts: 35
Joined: 2008.06
Post: #2
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 :
Huh something more efficient.

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();
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.10
Post: #3
Hi green_ghost,
Did the 2nd code solve your problem? I am still struggling with the same problem like how you said.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  UIView Subclass not displaying controls... flipflop 7 6,970 May 13, 2010 01:16 PM
Last Post: flipflop
  Problem displaying point sprites Duddd 0 2,054 Feb 12, 2010 02:45 AM
Last Post: Duddd
  conditionally displaying interface elements aerospaceman 2 2,807 Jun 25, 2009 12:20 PM
Last Post: aerospaceman