PDA

View Full Version : Element buffer offset?



Zulfiqar Malik
08-16-2005, 09:37 AM
Ok, the problem is that, in case of using regular index buffers you can specify offset to the start of an index buffer (in case you have multiple index buffers packed together in a single array) by simply giving offset from the base pointer like ...

glDrawElements(..., ..., (basePointer + offset));

However, i can't figure out how to specify offset in case of hardware accelerated element buffers. I have tried giving offset as an integer, something similar to specifying offset in glVertexPointer(...) while using VBOs. I have even played around with glDrawRangeElements(...) by specifying offset in the "start" parameter (2nd parameter if i remember correctly) and also in the last parameter. Nothing seems to be working. I am sure you can do it in GL similar to DrawIndexedPrimitive(...) in DX. I hope its not a driver issue. I have tested it on two different NV3x video cards with the latest certified drivers.

Thanks in advance.

SirKnight
08-16-2005, 01:24 PM
Here is how I do it:

char *indPtr = (char*)0 + ( indexStart * sizeof( indexType ) );

So if you have your indices as integers, sizeof( indexType ) will be sizeof(int).

And indPtr is put in the last parameter of glDrawElements for example.

-SirKnight