Jump to content
  • Advertisement
Sign in to follow this  

OpenGL ES 2.0: My parsed .obj is all wrong

This topic is 1960 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, I've recently begun exploring OpenGL ES 2.0 and I've been trying to render and .obj model that I've loaded with a parser that I worked with using OpenGL 1.x (its from Mario Zechner's "Beginning Android Games"). The parsed data is stored in an IntBuffer called 'vertices' in my renderer. 


When I try to draw the mesh, however, my "spaceship" ends up looking like this:




Here's how I'm drawing it:


//Set up program, handles, etc etc

GLES20.glVertexAttribPointer(mPositionsHandle, 3, GLES20.GL_FLOAT, false, 0, vertices);        
	// Pass in the color information
	GLES20.glVertexAttribPointer(mColoursHandle,  4, GLES20.GL_FLOAT, false, 0,  vertices);        
	 // Pass in the texture coordinate information
        vertices.position(hasColor ? 7 : 3);
	GLES20.glVertexAttribPointer(mTextureCoordinatesHandle, 2, GLES20.GL_FLOAT, false, 0,  vertices);
       // Pass in the normal information
    	int offset = 3;
        if (hasColor)
                offset += 4;
         if (hasTexCoords)
                offset += 2;
        GLES20.glVertexAttribPointer(mNormalsHandle,  3, GLES20.GL_FLOAT, false, 0, vertices);

GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, getNumVertices());


Is there anything I'm forgetting to do that I'm meant to? Or am I doing something wrong stupid?  I appreciate any help - I'm an OpenGL beginner and I'm a bit lost.

Share this post

Link to post
Share on other sites

And I have figured it out... I left out the "stride" argument in all those glVertexAttribPointer calls. Sorry for chewing up forum space

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!