Problem with glDrawElements in OpenGL ES 2.0



  • Hi,

    I'm trying to use glDrawElements to draw and it seems that there's something wrong with the triangles that are drawn so the shapes that are drawn don't look as expected. However when I use glDrawArrays everything is drawn just as expected.

    To make sure that I hadn't messed up in the code that calculates the normals or triangle indices I copied the code for generating spheres from the opengl es 2.0 book, but the output looks just as strange with their code. I used the setup code from hello_es2 example for initializing opengl.

    If there's anyone who has had a similar problem or has an idea what could be wrong I would be very grateful.

    /Simon



  • Something you messed up with arrays.



  • Do you mean that the vertex positions might be wrong?

    I'm pretty sure that the model is correct, because I used the code from the examples for the opengl es 2.0 book to generate the model, including positions, normals and triangle indices. I've used that code before (although not with QT). Also if I render with GL_POINTS I can se that the positions seem to be correct.

    If I've misunderstood you please let me know more in detail what you meant.



  • You mean glDrawElements with GL_POINT?

    And when you use glDrawArrays do you use unindexed vertex array?



  • Yes to both questions.

    glDrawElements with GL_POINT and glDrawArrays without indices. However the glDrawArrays call was made with a different model where all vertices were duplicated for each triangle in which it was included.



  • Can you test with one or two triangles? And see what the output is...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.