GlVertexAttribPointer for built-in vertex attributes such as gl_Vertex, gl_Normal

I need to send vertex attributes using glVertexAttribPointer so that shaders expect them to be inline ( gl_Vertex , gl_Color , etc.).

The glVertexAttribPointer function must indicate the index (or location) of each inline attribute. I can do this on NVidia implementations, since the location of each attribute is fixed (see http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/attributes.php in the "Custom Attributes" section), however I am "Not sure in places in ATI implementation.

In addition, the glGetAttribLocation function will return -1 when trying to get the location of any attribute starting with "gl _".

I think something is missing and this is a trivial problem, however I did not find the right solution for ATI.

+7
source share
1 answer

Built-in attribute arrays are not set using glVertexAttribPointer , but with features like glVertexPointer , glColorPointer , .... And you turn them on by calling glEnableClientState with constants like GL_VERTEX_ARRAY , GL_COLOR_ARRAY , ... instead of glEnableVertexAttribArray .

While nVidia glVertexAttribPointer may work, due to their smoothing of user attribute indexes with built-in attributes, this is not a standard match, and I'm sure you cannot expect this on any other hardware vendor. Therefore, to use special attributes and glVertexPointer/glNormalPointer/... for bultin attributes, use glVertexAttribPointer , as well as the corresponding on / off functions.

Remember that inline attributes are deprecated anyway, along with the specified functions. Therefore, if you want to write modern OpenGL code, you must define your own attributes anyway. But perhaps you need to support legacy shaders or not care about advanced compatibility at the moment.

+7
source

All Articles