Buffer object and how GL knows what it’s for.

This topic contains 2 replies, has 2 voices, and was last updated by  RichardUK 8 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29842

    RichardUK
    Member

    How does GL know what my buffer is used for, Pos, UV, Colour or normals???

    You allocate a buffer, you fill it and then later bind it. At some point you enable the attribute and you also set up the attribute parameters. There seems to be no point where I tell GL that buffer X is for vertices, texture coords or colours etc…

    Maybe I hit my head last night and it fell out, but whilst tracking down a crash bug I’ve got myself all confused……. Confused

    My best guess that the next call to one of the attribute functions defines what the last bound buffer is for, if so which?

    Ta.

    #33192

    Xmas
    Member

    When you call glVertexAttribPointer, the buffer that is bound to GL_ARRAY_BUFFER is bound to that attribute slot. Binding a buffer to GL_ARRAY_BUFFER by itself does not affect any attributes, it has to be followed by calls to glVertexAttribPointer.

    The actual meaning (position, texture coords, colours, etc.) of a vertex attribute is determined solely by how it is used in the vertex shader.

    #33193

    RichardUK
    Member

    Ah good, that is what after some more thinking I was hoping was going on. Was getting a little confused by the DX SetStreamSource and thinking it was similar to glBindBuffer.
    I’ve got this right, glBindBuffer just says “this is the buffer that all other related operations will use / operate on”.

    Thanks. 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.