c++ - opengl - glDrawElements not drawing triangles -
im trying create obj parser reads file , send vertices opengl. using gldrawelements draw model looks not compose of triangles. can below code on how doing this. code snippet sample. please take note of indices count different on model loading.
gluint vbuffer; glgenbuffers(1, &vbuffer); glbindbuffer(gl_array_buffer, vbuffer); glbufferdata(gl_array_buffer, 9 * sizeof(glfloat), vertices, gl_static_draw); glenablevertexattribarray(ff); glvertexattribpointer(ff, 3, gl_float, gl_false, 0, 0); glbindbuffer(gl_array_buffer, cbid); gluint buffer; glgenbuffers(1, &buffer); glbindbuffer(gl_element_array_buffer, buffer); glbufferdata(gl_element_array_buffer, 6 * sizeof(glshort), indices, gl_static_draw); gldrawelements(gl_line_strip, 6, gl_unsigned_short, 0); gldisablevertexattribarray(0);
here's output getting. image link
in line of code
gldrawelements(gl_line_strip, 6, gl_unsigned_short, 0);
you using gl_line_strip isn't want if data contains triangles. want in case gl_triangles give expected behavior.
also, don't know if typo in gldrawelements call pass gl_unsigned_short while when initializing element buffer pass in sizeof(glshort), not glushort.
Comments
Post a Comment