• Create Account

### #Actualslicer4ever

Posted 06 May 2013 - 06:35 AM

I can't seem to find an answer for this with openGL, but recently when using PSM i've found that I can pass an interleaved array to the shader, and the api can map my interleaved arrays to the shader inputs without any fuss. It reduces alot of additional calls for setting up where each specific part of the vbo has to go.

I'm curious if their is something like this for openGL that i haven't found. I'd like it to be 3.0 capable if possible, but instead of doing:
...
glVertexAttribPointer(PosIdx, 4, GL_FLOAT, sizeof(myvertex), 0x0);
glVertexAttribPointer(ClrIdx, 4, GL_FLOAT, sizeof(myvertex), 0x10);
glVertexAttribPointer(NrmIdx, 3, GL_FLOAT, sizeof(myvertex), 0x20); //I know, padding, just an example!
glVertexAttribPointer(TexIdx, 2, GL_FLOAT, sizeof(myvertex), 0x2C);
//etc, etc
...

i could do something like:
glVertexAttribBlock(BlockIdx, sizeof(myvertex), 0, 0x0);
//Index to attribute block, size of the block in bytes, stride(0 is tightly packed), offset into vbo)


### #2slicer4ever

Posted 06 May 2013 - 06:34 AM

I can't seem to find an answer for this with openGL, but recently when using PSM i've found that I can pass an interleaved array to the shader, and the api can map my interleaved arrays to the shader inputs without any fuss. It reduces alot of additional calls for setting up where each specific part of the vbo has to go.

I'm curious if their is something like this for openGL that i haven't found. I'd like it to be 3.0 capable if possible, but instead of doing:
...
glVertexAttribPointer(PosIdx, 4, GL_FLOAT, sizeof(myvertex), 0x0);
glVertexAttribPointer(ClrIdx, 4, GL_FLOAT, sizeof(myvertex), 0x10);
glVertexAttribPointer(NrmIdx, 3, GL_FLOAT, sizeof(myvertex), 0x20); //I know, padding, just an example!
glVertexAttribPointer(TexIdx, 2, GL_FLOAT, sizeof(myvertex), 0x2C);
...

i could do something like:
glVertexAttribBlock(BlockIdx, sizeof(myvertex), 0, 0x0);
//Index to attribute block, size of the block in bytes, stride(0 is tightly packed), offset into vbo)


### #1slicer4ever

Posted 06 May 2013 - 06:34 AM

I can't seem to find an answer for this with openGL, but recently when using PSM i've found that I can pass an interleaved array to the shader, the api can map my interleaved arrays to the shader without any fuss. it reduces alot of additional calls for setting up where each specefic part of the vbo has to go.

I'm curious if their is something like this for openGL that i haven't found. I'd like it to be 3.0 capable if possible, but instead of doing:
...
glVertexAttribPointer(PosIdx, 4, GL_FLOAT, sizeof(myvertex), 0x0);
glVertexAttribPointer(ClrIdx, 4, GL_FLOAT, sizeof(myvertex), 0x10);
glVertexAttribPointer(NrmIdx, 3, GL_FLOAT, sizeof(myvertex), 0x20); //I know, padding, just an example!
glVertexAttribPointer(TexIdx, 2, GL_FLOAT, sizeof(myvertex), 0x2C);
...

i could do something like:

glVertexAttribBlock(BlockIdx, sizeof(myvertex), 0, 0x0);
//Index to attribute block, size of the block in bytes, stride(0 is tightly packed), offset into vbo)


PARTNERS