c++ - Draw mulitple objects using OpenGL -
i need draw both square , rectangle in opengl. vertices stored in 2 vertex buffers , bound array buffer follows. however, object bound second object displayed on screen. there way display both together?
void application::setupopenglbuffers(void) { float vertexcoords = {0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0}; glgenbuffers(1, &vertexbuffer); glbindbuffer(gl_array_buffer, vertexbuffer); glbufferdata(gl_array_buffer, 2 * 4 * sizeof(float), vertexcoords, gl_static_draw); float vertexcoords2 = {0.0, 0.0, -0.5, 0.0, -0.5, 0.5, 0.0, 0.5}; glgenbuffers(1, &vertexbuffer2); glbindbuffer(gl_array_buffer, vertexbuffer2); glbufferdata(gl_array_buffer, 2 * 4 * sizeof(float), vertexcoords2, gl_static_draw); } void application::drawscene(void) { glbindbuffer(gl_array_buffer, vertexbuffer); glvertexattribpointer(vertattribloc, 2, gl_float, false, 0, 0); glenablevertexattribarray(vertattribloc); gldrawarrays(gl_line_strip, 0, 8); glbindbuffer(gl_array_buffer, vertexbuffer2); glvertexattribpointer(vertattribloc2, 2, gl_float, false, 0, 0); glenablevertexattribarray(vertattribloc2); gldrawarrays(gl_line_strip, 0, 8); }
Comments
Post a Comment