Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on an object (OBJ File) loader for my app on iOS, currently I have successfully read the vertices and the faces of the object, and I am now just adding colours to the imported models.

I am coming across a major problem now. Out of a cube with six faces, all coloured red apart from two opposite faces which are coloured blue. This cube is set to rotate so I can see all sides, but the colours do not appear correctly as shown in the video below:

http://youtu.be/0L2AIFkd2Qk

The blue faces only shows when the two blue sections overlap, I cannot figure out why - I am used to OpenGL for PC, is there something I am missing which is causing this strange colouring?

The colouring is achieved by sending a large float array of the format RGBA RGBA RGBA etc for each vertex;

// colours is the name of the array of floats
glColorPointer(colorStride, GL_FLOAT, 0, colors);   
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(renderStyle, 0, vertexCount);

Any help you can offer would be great,

[EDIT]

Even if you don't know the problem, but have seen this before and know what it may be that would help as I have no idea where to even start looking as it is!

Many thanks

share|improve this question
1  
Do you have depth buffering enabled? –  Jari Komppa Sep 27 '11 at 4:38
    
Thanks for your comment, I have a working program now! I did enable depth buffering, but it caused the screen to go blank - I made two changes - drew each face with a separate call to glDrawArrays. And also changed how I culled the faces :) –  Paul Reed Sep 27 '11 at 19:09
    
You definitely should not need to render each face separately, but if you're happy with the result, that's probably all that matters. –  Jari Komppa Sep 28 '11 at 5:37
    
Yes it is now causing another problem, rendering each face makes colouring the vertices difficult. This is something I will take a look at and try to solve tomorrow but I may be back on here soon! –  Paul Reed Sep 28 '11 at 17:07
    
@JariKomppa I looked into the issue at more detail and I have now got it drawing all faces from a single call, thanks for pointing out that it should work as it now means I can colour each vertex individually! –  Paul Reed Sep 28 '11 at 19:57
add comment

1 Answer

up vote 1 down vote accepted

It looks like your face normals are pointing to the wrong side. Change the triangle winding order on your loader or set a different glCullMode when rendering.

share|improve this answer
    
Yes. I also think, there could be some problem with vertices order - are all of them entered in the same direction (CCW or CW)? –  zacharmarz Sep 27 '11 at 9:21
    
Hi @r2d2rigo I solved the problem at Uni earlier today, and one of the problems was to do with the culling, so if I had not have done it earlier this would have been a big help! :) –  Paul Reed Sep 27 '11 at 19:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.