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 3 of 3

Thread: Vertex array objects and black screen of death

  1. #1
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    Vertex array objects and black screen of death

    I have problems with the following pseudo code. It works when not defining USEVAO, but as soon as I define USEVAO it stops working.
    Code :
    Init() {
      glEnableVertexAttribArray
      glGenVertexArrays(1, &vao)
      glBindVertexArray(vao)
      glGenBuffers
      glBindBuffer(GL_ARRAY_BUFFER)
      glBufferData(GL_ARRAY_BUFFER)
      glVertexAttribPointer
      glBindVertexArray(0)
    }
     
    Draw() {
    #ifdef USEVAO
      glBindVertexArray(vao)
    #else
      glBindVertexArray(0)
      glBindBuffer(GL_ARRAY_BUFFER)
      glVertexAttribPointer
    #endif
      glDrawArrays
    }

    Using glGetVertexAttribPointerv() immediately before glDrawArrays(), I have verified that the byte offset is correctly set-up (works with and without USEVAO defined). There is probably some simple mistake, but having spent a couple of days I am becoming desperate. This is not the only draw function I am using, maybe there is an interdependency I didn't know about. I am using VAOs in other places. Apart from glGetVertexAttribPointerv, are there other ways I can read out the stored state of the vertex array object?

    If I enable both branches of the #ifdef, it still does not work.

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    381

    Re: Vertex array objects and black screen of death

    Calling glEnableVertexAttribArray affects the currently bound VAO, so you are not enabling the attribute for the generated vao.

  3. #3
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    Re: Vertex array objects and black screen of death

    Thanks, that fixed it!

Posting Permissions

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