Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glDrawArrays works, while glDrawElements fails. Why?

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    5

    glDrawArrays works, while glDrawElements fails. Why?

    Here is a code sample of what I mean: https://github.com/nucleartide/grape...aster/main.cpp

    This is the result of using glDrawArrays:



    And this is the result of using glDrawElements:



    In the code, window.DrawElements just calls glDrawElements with some default values. Most OpenGL objects are abstracted away into C++ classes; I don't think there are any problems in my classes, since glDrawArrays works perfectly.

    What the heck is going on? For what it's worth, here's my glxinfo:

    Code :
    $ optirun glxinfo | grep OpenGL
    OpenGL vendor string: NVIDIA Corporation
    OpenGL renderer string: GeForce GT 750M/PCIe/SSE2
    OpenGL core profile version string: 4.3.0 NVIDIA 331.38
    OpenGL core profile shading language version string: 4.30 NVIDIA via Cg compiler
    OpenGL core profile context flags: (none)
    OpenGL core profile profile mask: core profile
    OpenGL core profile extensions:
    OpenGL version string: 4.4.0 NVIDIA 331.38
    OpenGL shading language version string: 4.40 NVIDIA via Cg compiler
    OpenGL context flags: (none)
    OpenGL profile mask: (none)
    OpenGL extensions:

    Thanks in advance.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    894
    Have you run this under a debugger to figure out where it crashes?
    On possibility I can see after skimming the wrapper classes is that I don't think you have a VAO bound at the time you bind the index buffer, so there is not source for index data stored in the VAO. Can you post a trace of the OpenGL calls issued (e.g. using apitrace)?

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    5
    Ah, that must be it - the VAO isn't bound. I'll post a trace after work tonight.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by carsten neumann View Post
    Have you run this under a debugger to figure out where it crashes?
    On possibility I can see after skimming the wrapper classes is that I don't think you have a VAO bound at the time you bind the index buffer, so there is not source for index data stored in the VAO. Can you post a trace of the OpenGL calls issued (e.g. using apitrace)?
    It worked! I got confused since setting GL_ARRAY_BUFFER doesn't require a bound VAO. Thanks so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •