Hey guys,
topic descripes my problem.
i tried to build a simple Quads and Triangles House in OpenGL.
This wasn't the problem. The problem is the color.
i want to give every wall another color. but when it's rotating(x) a dominating color from the other walls is printing through my nearest wall.
i tried to solve this problem with glEnable( GL_DEPTH_TEST );
IT WORKS! but not like intended. the graphic is blinking(dont know how to write it in english).
i placed it already in every function(what includes gl stuff)
i asked a friend and he said that it have to be in my opengl_reset_scene
gl_reset_scene():
main.cppCode :void OpenGL_Init::gl_reset_scene(){ if( iWidht == 0.0f ){ iWidht = 1.0f; } if( iHeight == 0.0f){ iHeight = 1.0f; } glViewport( 0 , 0, this->iWidht, this->iHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective(45.0f, this->iWidht/this->iHeight, 0.0f, 100.0f); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glEnable( GL_DEPTH_TEST ); }
Code :int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmd){ OpenGL_Init start; start.screen_setup(hInstance, iCmd, 800, 460 ); start.opengl_setup( ); start.gl_reset_scene(); start.gl_draw_scene(); while ( true ){ if( start.key_pressed( )){ break; } else{ if(!start.gl_draw_scene()){ MessageBox( NULL,"draw scene error","Error", MB_OK|MB_ICONERROR); break; } else{ SwapBuffers( start.get_hDC()); } } } return 0; }
i use opengl 2.1



Reply With Quote