Results 1 to 6 of 6

Thread: VAO not working in OpenGL 4.5

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    22

    VAO not working in OpenGL 4.5

    I am attempting to convert some code from OpenGL 4.4 to OpenGL 4.5. Here is the old code which uses the DSA extension:

    Code :
    GLuint vao = 0;
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[2]);
    glEnableVertexArrayAttribEXT(vao, 0);
    glEnableVertexArrayAttribEXT(vao, 1);
    glVertexArrayVertexAttribOffsetEXT(vao, buffers[0], 0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    glVertexArrayVertexAttribOffsetEXT(vao, buffers[1], 1, 2, GL_FLOAT, GL_FALSE, 0, 0);

    Here is the new code which uses core DSA:

    Code :
    GLuint vao = 0;
    glCreateVertexArrays(1, &vao);
    glVertexArrayElementBuffer(vao, buffers[2]);
    glEnableVertexArrayAttrib(vao, 0);
    glEnableVertexArrayAttrib(vao, 1);
    glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, 0);
    glVertexArrayVertexBuffer(vao, 1, buffers[1], 0, 0);
    glVertexArrayAttribFormat(vao, 0, 3, GL_FLOAT, GL_FALSE, 0);
    glVertexArrayAttribFormat(vao, 1, 2, GL_FLOAT, GL_FALSE, 0);

    This code does not work and I am not sure why. Nothing is rendered and no errors or debug output is generated.

    Second question: Is the relativeoffset of glVertexArrayAttribLFormat identical to the stride of glVertexArrayVertexBuffer? It seems odd to have to specify the same exact thing twice in a row.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Try to set a stride to a proper value, not 0.

  3. #3
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    Quote Originally Posted by Yandersen View Post
    Try to set a stride to a proper value, not 0.
    Stride 0 has always been valid in OpenGL for specifying tightly-packed data.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    22
    Quote Originally Posted by Yandersen View Post
    Try to set a stride to a proper value, not 0.
    If the stride was 0 in the first version then why would I want to change it? What's improper about a stride of 0? The attributes are coming from separate buffers filled with packed floats. What stride would you recommend for that?

  5. #5
    Senior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Quote Originally Posted by Chris_F View Post
    If the stride was 0 in the first version then why would I want to change it? What's improper about a stride of 0? The attributes are coming from separate buffers filled with packed floats. What stride would you recommend for that?
    That is true, I remember. But try to find the mention of that in the new specs:
    http://www.opengl.org/sdk/docs/man4/...ibFormat.xhtml
    I don't see a note about special value 0. Therefore, use relativeoffset=8 for tightly packed float2 and 12 for float3. Just try - it wouldn't hurt, right?

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    22
    It works with an explicit stride. It seems that one of the side effects of separating buffer binding from vertex attribute specification is that it can no longer automatically calculate the stride.

Similar Threads

  1. Replies: 0
    Last Post: 04-27-2018, 08:20 PM
  2. OpenGL not working.
    By rickguyface in forum OpenGL: User Software
    Replies: 5
    Last Post: 04-05-2018, 10:56 PM
  3. Replies: 1
    Last Post: 11-18-2011, 08:13 AM
  4. OpenGL isn't working right
    By imported_Wilson in forum OpenGL: User Software
    Replies: 5
    Last Post: 07-27-2006, 11:58 AM
  5. opengl not working on xp
    By in forum OpenGL: User Software
    Replies: 20
    Last Post: 12-01-2004, 09:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean