Identify the pattern

Started by
1 comment, last by Juliean 7 years, 12 months ago

Hi folks,

Is there any way to identify the pattern stored in the buffer (say VBO) from the call glVertexAttribpointer.

Whether it has pattern of

1) Vertices+ Normal +Color

(or)

2) Normal + Vertices + Color

(or)

3) Color + Vertices + Normal ...

Need this information to reply GL API sequence.

Regards,

Venkatesh

Advertisement

No.

For example, both normal and position are typically stored as 3-component float arrays. So given an arbitrary 3 floats, there is no way to tell if they're intended to be interpreted as normal or position.

This is entirely the point of glVertexAttribPointer.

The documentation for both glVertexAttribPointer and glEnableVertexAttribArray refers to "generic vertex attributes"; i.e. the vertex attributes themselves are generic and they have neither metadata, not usage semantics, nor anything else attached to them to denote how they are used. How they are used is entirely determined by your program.

"Generic" in this case even goes a step further in that you are not confined to the typical attributes used in drawing (position/normal/texcoords/colours/etc): if you want your program to interpret an attribute as "kilowombles per square inch", you can.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Is there any way to identify the pattern stored in the buffer (say VBO) from the call glVertexAttribpointer.

As said, you cannot do that directly. If you have control over the source, you can make a wrapper instead of calling glVertexAttribpointer directly, and add the desired information. If not you can maybe identify the shader that is being loaded and manually determine what combation of attributes it requires (just to mention it).

This topic is closed to new replies.

Advertisement