c++ - VAO/VBO management - change all VBO data -
c++ - VAO/VBO management - change all VBO data -
i have vao 3 vbos, containing model vertexes, normals , texture coordinates.
i intend alter info in vbos quite often, 500ms 20ms update frequency. new model downloaded vbo can have less or more triangles previous one. buffer size change.
i'm not expert in opengl tips if possible on how improve code. now, programme implemented follows:
glbindvertexarray(*vao); if (mesh->haspositions()) { glbindbuffer(gl_array_buffer, vbo_pos); glbufferdata( gl_array_buffer, 3 * *point_count * sizeof (glfloat), points, gl_dynamic_draw ); glvertexattribpointer(0, 3, gl_float, gl_false, 0, null); glenablevertexattribarray(0); free(points); // free our temporary memory } if (mesh->hasnormals()) { glbindbuffer(gl_array_buffer, vbo_norm); glbufferdata( gl_array_buffer, 3 * *point_count * sizeof (glfloat), normals, gl_dynamic_draw ); glvertexattribpointer(2, 3, gl_float, gl_false, 0, null); glenablevertexattribarray(2); free(normals); // free our temporary memory } if (mesh->hastexturecoords(0)) { glbindbuffer(gl_array_buffer, vbo_tex); glbufferdata( gl_array_buffer, 2 * *point_count * sizeof (glfloat), texcoords, gl_dynamic_draw ); glvertexattribpointer(1, 2, gl_float, gl_false, 0, null); glenablevertexattribarray(1); free(texcoords); // free our temporary memory }
edit:
this current solution have issue drawing not should be.
if first model big 1 (50mb) , load 1 bit smaller (25mb) there's still part of previous model drawn.
if first model little 1 (25mb) , changed big 1 (50mb) drawing isn't changed (or @ to the lowest degree doesn't seem change). if charge after smaller 1 (216kb) drawing changes (but there's still part remaining).
so suppose there's wrong vbo management?
ok found issue
i updating vbo info in thread. didn't know doesn't work :/
c++ opengl vbo vao
Comments
Post a Comment