C++ OpenGL flickering Issues -
im having problem, when render 1 cube it's okay, if add multiple cubes of them start flickering.. might because intefering each other im using double dubbers shouldn't that. here code of render method
for (std::vector<entity *>::iterator iterator = entityarray->begin(); iterator != entityarray->end(); iterator++) { entity *entity = *iterator; if (entity->getvertexbuffer() != null) { glclear(gl_color_buffer_bit | gl_depth_buffer_bit); gluseprogram(entity->getvertexbuffer()->getshader()->getprogramhandle()); glloadidentity(); glulookat(_currentcamera->getposition().x, _currentcamera->getposition().y, _currentcamera->getposition().z, _currentcamera->geteyevector().x, _currentcamera->geteyevector().y, _currentcamera->geteyevector().z, _currentcamera->getupvector().x, _currentcamera->getupvector().y, _currentcamera->getupvector().z); gltranslatef(entity->getposition().x, entity->getposition().y, entity->getposition().z); glrotatef(entity->getrotation().x, 0.0f, 0.0f, 1.0f); glrotatef(entity->getrotation().y, 0.0f, 1.0f, 0.0f); glrotatef(entity->getrotation().z, 1.0f, 0.0f, 0.0f); glscalef(entity->getscale().x, entity->getscale().y, entity->getscale().z); gluniform4f(entity->getvertexbuffer()->getshader()->get_ucolor(), entity->getvertexbuffer()->getshaderdata()->get_ucolorvalue().x, entity->getvertexbuffer()->getshaderdata()->get_ucolorvalue().y, entity->getvertexbuffer()->getshaderdata()->get_ucolorvalue().z, entity->getvertexbuffer()->getshaderdata()->get_ucolorvalue().w); gluniform3f(entity->getvertexbuffer()->getshader()->get_ulightposition(), entity->getvertexbuffer()->getshaderdata()->get_ulightposition().x, entity->getvertexbuffer()->getshaderdata()->get_ulightposition().y, entity->getvertexbuffer()->getshaderdata()->get_ulightposition().z); entity->getvertexbuffer()->configurevertexattributes(); entity->getvertexbuffer()->rendervertexbuffer(); glfwswapbuffers(_window); glfwpollevents(); } }
clear first, draw cubes, swap, this:
glclear(); (cube in cubes) { draw(cube); } glfwswapbuffers(_window); glfwpollevents();
that should solve it.
Comments
Post a Comment