Question

I "trying" to learn OpenGL using the book "Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming by Erik M. Buck"

I have got to the stage where I am trying to load a 3D model in a tester app to confirm my knowledge and although I can get the model displayed it appears reversed and the texture seems part displayed (or displayed incorrectly).

I have tried GL_BLEND, GL_DEPTH_TEST, using ortho not using ortho to no avail and realise I'm probably missing something integral..thinking it might be something to do with face normals?

here is what should appear:

enter image description here

and this is what I get:

enter image description here can anyone help?

Thanks

Was it helpful?

Solution 2

The author of the book looked at this for me and found out the following:

The .obj model was produced using "quads", 4 sided polygons, but OpenGL ES can only render points, lines, and triangles. As a result, only half (1 triangle) of each quad was rendered.

Opening the .obj file in Blender and exporting using triangles resulted in the correct display appearing.

Thanks to Erik Buck for taking the time to help one of his readers and thanks too to @clayMontgomery for his assistance ;-)

OTHER TIPS

I think the code for your sphere model assumes that backface culling is either disabled or requires the opposite winding direction (clock-wise or counter-clock wise) for its triangle strips. You should try to initialize OpenGL ES correctly for what that code expects. I would try this:

gl.glDisable(GL10.GL_CULL_FACE);

OR

gl.glEnable(GL10.GL_CULL_FACE);
gl.glFrontFace(GL10.GL_CCW);
gl.glCullFace(GL10.GL_BACK);

OR

gl.glEnable(GL10.GL_CULL_FACE);
gl.glFrontFace(GL10.GL_CW);
gl.glCullFace(GL10.GL_BACK);

For more information, see "Polygon Details" in the OpenGL Red Book, chapter 2:

http://www.glprogramming.com/red/chapter02.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top