opengl - glVertexAttribPointer, change vertex attributes layout -


i'm programming glsl 1.3+ viewer, , i'll need change sources of shaders not delete , recreate... but, there informations not given in man of opengl redefine vertices attributes layout.

what happens previous call to

    glvertexattribpointer( posattrib, 2, gl_float, gl_false, 0, 0 ); 

when recall using posattrib? how "unbind" shader input variable vertex attribute array? how make same posattrib point different location in vertex attribute array?

to answer question happens previous call glvertexattribpointer, believe attribute pointer got reassigned latest call of glvertexattribpointer.

there no "unbind" in usage. changing reference, there no additional memory created. last input argument offset of supplied posattrib vbo. if posattrib contains vertex coordinate, normal , texture coordinate, following, assuming defined new type attributedvertex 8 floats in (3 vertex, 3 normal, 2 texture coordinate)

glvertexattribpointer(0, 3, gl_float, gl_false, sizeof(attributedvertex), 0); glvertexattribpointer(1, 3, gl_float, gl_false, sizeof(attributedvertex), (void *)(3*sizeof(glfloat)); glvertexattribpointer(2, 3, gl_float, gl_false, sizeof(attributedvertex), (void *)(6*sizeof(glfloat)); 

your vertex shader should have 3 attributes like

attribute vec3 inposition; attribute vec3 innormal; attribute vec2 intexcoord; 

that correspond vertex attributes.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -