Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem with glDrawElements in OpenGL ES 2.0
Qt 6.11 is out! See what's new in the release blog

Problem with glDrawElements in OpenGL ES 2.0

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simon_saffer
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      Something you messed up with arrays.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        simon_saffer
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          minimoog77
          wrote on last edited by
          #4

          You mean glDrawElements with GL_POINT?

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            simon_saffer
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              minimoog77
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved