Passing fewer components through glVertexAttribPointer than expected shader

In OpenGL (in particular, ES 2.0 in this case), what happens if I pass 2 components to the top, for example:

  glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, sizeof( MyVertexStruct ), pPos );

... but the shader expects three?

It seems that the third (Z, in this case) component is 0, which I want, but I hesitate to rely on behavior. Is it defined somewhere in the OpenGL, ES or GLSL standards?

(My search-fu does not allow me: to find nothing in the red book, the purple book, or on the khronos.org man pages, but I may have simply not paid attention to it.)

+3
source share
1 answer

OpenGL, , , (0,0,0,1), , , glVertexAttrib2f ( ).

EDIT: OpenGL ES 2.0, :

GL DrawArrays DrawElements, . , x ; y, z w , , . , x y ; z w , . , x, y z, w . , .

, , .

+2

Source: https://habr.com/ru/post/1773167/


All Articles