c++ - glDrawElements not drawing anything to screen -
whenever try draw mesh using gldrawelements, program gets no errors, doesn't draw anything. i'm pretty sure issue gldrawelements since if comment gldrawelements out , replace gldrawarrays, works perfectly. so, question is, can me figure out why happening?
also glgeterror returns no errors
#include "mesh.h" mesh::mesh(glm::vec2* vertices, glm::vec2* texcoords, glushort* elements, int size) { m_size = size; m_vertices = vertices; m_elements = elements; movementvector = glm::vec2(0.0f, 0.0f); glgenvertexarrays(1, &vao); glbindvertexarray(vao); glgenbuffers(1, &vbo); glbindbuffer(gl_array_buffer, vbo); glbufferdata(gl_array_buffer, size * sizeof(float), vertices, gl_dynamic_draw); glenablevertexattribarray(0); glbindbuffer(gl_array_buffer, vbo); glvertexattribpointer(0, 2, gl_float, gl_false, 0, null); glgenbuffers(1, &tex_vbo); glbindbuffer(gl_array_buffer, tex_vbo); glbufferdata(gl_array_buffer, size * sizeof(float), texcoords, gl_static_draw); // note: assume vertex positions location 0 int dimensions = 2; // 2d data texture coords glvertexattribpointer(1, dimensions, gl_float, gl_false, 0, null); glenablevertexattribarray (1); // don't forget this! glgenbuffers(1, &ebo); glbindbuffer(gl_element_array_buffer, ebo); glbufferdata(gl_element_array_buffer, sizeof(elements), elements, gl_static_draw); } mesh::~mesh() { gldeletevertexarrays(1, &vbo); } void mesh::draw() { glbindvertexarray(vao); glenablevertexattribarray(0); //gldrawarrays(gl_triangles, 0, 8); glbindbuffer(gl_array_buffer, vbo); glvertexattribpointer(0, 2, gl_float, gl_false, 0, null); gldrawelements(gl_triangles, 6, gl_unsigned_short, null); gldisablevertexattribarray(0); }
here's link code handling drawing objects screen, also, have tested shaders, functional , unless drawing via gldrawelements requires changes shaders well, there nothing causing them.
Comments
Post a Comment