c++ - nvolgv32.dll - glDrawElements trouble -
at moment im coding graphic app using opengl , im drawing obj files using gldrawelements. i've nvidia geforce gt 740m
the trouble : first-chance exception @ 0x68fcf460 (nvoglv32.dll) in demo.exe: 0xc0000005: access violation reading location 0x00000000. , dont know how can fix this.
these buffers initialization
// <-- vbos ibo vao creation --> // glgenbuffers(3, obj_vbo); glgenbuffers(1, &obj_ibo); glgenvertexarrays(1, &obj_vao); // <-- ibo --> // glbindbuffer(gl_element_array_buffer, obj_ibo); glbufferdata(gl_element_array_buffer, obj_triangles.size() * sizeof(glushort), obj_triangles.data(), gl_static_draw); glbindbuffer(gl_element_array_buffer, null); // <-- vao --> // glbindvertexarray(obj_vao); glenablevertexattribarray(vertex_layout); glbindbuffer(gl_array_buffer, obj_vbo[vertex_layout]); glbufferdata(gl_array_buffer, obj_vertices.size() * sizeof(glfloat), obj_vertices.data(), gl_static_draw); glvertexattribpointer(vertex_layout, 3, gl_float, gl_false, gl_false, (glubyte *) null); glbindbuffer(gl_array_buffer, null); gldisablevertexattribarray(vertex_layout); glenablevertexattribarray(normal_layout); glbindbuffer(gl_array_buffer, obj_vbo[normal_layout]); glbufferdata(gl_array_buffer, obj_normals.size() * sizeof(glfloat), obj_normals.data(), gl_static_draw); glvertexattribpointer(normal_layout, 3, gl_float, gl_false, gl_false, (glubyte *) null); glbindbuffer(gl_array_buffer, null); gldisablevertexattribarray(normal_layout); glenablevertexattribarray(texture_layout); glbindbuffer(gl_array_buffer, obj_vbo[texture_layout]); glbufferdata(gl_array_buffer, obj_textures.size() * sizeof(glfloat), obj_textures.data(), gl_static_draw); glvertexattribpointer(texture_layout, 2, gl_float, gl_false, gl_false, (glubyte *) null); glbindbuffer(gl_array_buffer, null); gldisablevertexattribarray(texture_layout); glbindvertexarray(null); // <-- save , calculate stuffs . . . --> // obj_triangles_size = (gluint) obj_triangles.size();
and draw method, vertex_layout = 0, normal_layout = 1, texture_layout = 2
glbindvertexarray(obj_vao); glenablevertexattribarray(vertex_layout); glenablevertexattribarray(normal_layout); glenablevertexattribarray(texture_layout); glbindbuffer(gl_element_array_buffer, obj_ibo); gldrawelements(gl_triangles, obj_triangles_size, gl_unsigned_short, null); glbindbuffer(gl_element_array_buffer, null); gldisablevertexattribarray(texture_layout); gldisablevertexattribarray(normal_layout); gldisablevertexattribarray(vertex_layout); glbindvertexarray(null);
if use option (auto-select) on nvidia panel / manage 3d settings app renders when switch option high-performance nvidia processor gives problem.
disclaimer:
this not answer, explaining in comments impossible.
here how vaos intended used, track of states redundantly changing every time draw.
initialization:
// <-- vbos ibo vao creation --> // glgenbuffers(3, obj_vbo); glgenbuffers(1, &obj_ibo); glgenvertexarrays(1, &obj_vao); // <-- vao --> // glbindvertexarray(obj_vao); // <-- ibo (moved) --> // glbindbuffer(gl_element_array_buffer, obj_ibo); glbufferdata(gl_element_array_buffer, obj_triangles.size() * sizeof(glushort), obj_triangles.data(), gl_static_draw); // glbindbuffer(gl_element_array_buffer, null); -- remove glenablevertexattribarray(vertex_layout); glbindbuffer(gl_array_buffer, obj_vbo[vertex_layout]); glbufferdata(gl_array_buffer, obj_vertices.size() * sizeof(glfloat), obj_vertices.data(), gl_static_draw); glvertexattribpointer(vertex_layout, 3, gl_float, gl_false, gl_false, (glubyte *) null); //glbindbuffer(gl_array_buffer, null); -- remove //gldisablevertexattribarray(vertex_layout); -- remove glenablevertexattribarray(normal_layout); glbindbuffer(gl_array_buffer, obj_vbo[normal_layout]); glbufferdata(gl_array_buffer, obj_normals.size() * sizeof(glfloat), obj_normals.data(), gl_static_draw); glvertexattribpointer(normal_layout, 3, gl_float, gl_false, gl_false, (glubyte *) null); //glbindbuffer(gl_array_buffer, null); -- remove ///gldisablevertexattribarray(normal_layout); -- remove glenablevertexattribarray(texture_layout); glbindbuffer(gl_array_buffer, obj_vbo[texture_layout]); glbufferdata(gl_array_buffer, obj_textures.size() * sizeof(glfloat), obj_textures.data(), gl_static_draw); glvertexattribpointer(texture_layout, 2, gl_float, gl_false, gl_false, (glubyte *) null); //glbindbuffer(gl_array_buffer, null); -- remove //gldisablevertexattribarray(texture_layout); -- remove glbindvertexarray(null); // <-- save , calculate stuffs . . . --> // obj_triangles_size = (gluint) obj_triangles.size();
drawing:
glbindvertexarray(obj_vao); //glenablevertexattribarray(vertex_layout); -- remove //glenablevertexattribarray(normal_layout); -- remove //glenablevertexattribarray(texture_layout); -- remove //glbindbuffer(gl_element_array_buffer, obj_ibo); -- remove gldrawelements(gl_triangles, obj_triangles_size, gl_unsigned_short, null); //glbindbuffer(gl_element_array_buffer, null); -- remove //gldisablevertexattribarray(texture_layout); -- remove //gldisablevertexattribarray(normal_layout); -- remove //gldisablevertexattribarray(vertex_layout); -- remove glbindvertexarray(null);
Comments
Post a Comment