How do i tell the indexbuffer to only use what is acctually the position

Started by coolian, September 11, 2020, 07:38:53

Previous topic - Next topic

coolian

Hello
I want to render 2 quads making a rectangle using an indexbuffer this worked fine until i added a second attribute which means each vertex now looks like this:
0.5f,  0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // top right
and the indexbuffer also takes the last values when it should only take the first 3 values. How do i tell the indexbuffer to only take the first three values for each vertex

KaiHH

The indexes in the index buffer only point to whole vertices. Which vertex attributes a vertex is actually composed of, is specified via the vertex specification commands, such as glVertexAttribPointer(), if you use generic vertex attributes, that is. If your vertex contains multiple vertex attributes and you define those in an interleaved form then you would also have multiple glVertexAttribPointer() calls while having the same buffer object bound to GL_ARRAY_BUFFER, and in glVertexAttribPointer() you would specify different offsets and same strides for the individual vertex attributes.
If you want some vertex attributes to not be fetched (which results in them simply not being available in your vertex shader) then you can disable them. However, this should not be necessary. You can simply define a vertex shader by only using the vertex attribute locations of interest to you.