arrays - Is the glVertexAttribPointer state bound to the current GL_ARRAY_BUFFER? -


i have simple question. right, glvertexattribpointer operations have called once gl_array_buffer save attribute states until want change them? or need call glvertexattribpointer each time in between glbindbuffer(gl_array_buffer, ...); , gldrawarrays(...); ?

is right, glvertexattribpointer operations have called once gl_array_buffer save attribute states until want change them? or need call glvertexattribpointer each time.

glvertexattribpointer specifies location , data format of array of generic vertex attribute @ specified index.

this has done before object drawn:

glbindbuffer( array_buffer, posbufobj ); glenablevertexattribarray( 0 ); glvertexattribpointer( 0, .... ); glbindbuffer( nvbufobj ); glenablevertexattribarray( 1 ); glvertexattribpointer( 1, .... );  gldrawarrays( .... ) gldisablevertexattribarray( 0 ); gldisablevertexattribarray( 1 ); glbindbuffer( array_buffer, 0 ); 

yes, sufficient call glvertexattribpointer once per vetrex attribute. vertex specification keept until not redefined. of course, buffer object, glvertexattribpointer refers must not deleted. state, whether vertex attribute enabled (glenablevertexattribarray) or not kept until vertex attribute disabled again (gldisablevertexattribarray).
khronos opengl wiki vertex specification says:

the glvertexattribpointer functions state attribute index gets array data from.

this state can retrieved glgetvertexattrib.

more information vertex attrbutes can found in opengl coreprofile specification chapter 10.2 10.6

to handle different vertex attribute pointers , not specify , enable or disable them alternately, vertex array object can generated (glgenvertexarrays), stores information buffer location, data format, state , attribute index:

generated , specify vertex array object

vaoobj = glgenvertexarrays(); glbindvertexarray( vaoobj ); glbindbuffer( array_buffer, posbufobj ); glenablevertexattribarray( 0 ); glvertexattribpointer( 0, .... ); glbindbuffer( nvbufobj ); glenablevertexattribarray( 1 ); glvertexattribpointer( 1, .... ); glbindbuffer(gl_array_buffer, 0); glbindvertexarray( 0 ); 

bind vertex array object

glbindvertexarray( vaoobj ); gldrawarrays( .... ) glbindvertexarray( 0 ); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -