Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Rotating form is lagging by using glEnable()

  1. #1
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    1

    Rotating form is lagging by using glEnable()

    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():
    Code :
    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 );
     
    }
    main.cpp
    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
    Last edited by Saladir; 01-25-2013 at 11:20 AM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,106
    Are you trapping you erasebackgound command from windows and discarding it. Windows may be erasing you window's background causing a flicker.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    Your problem is this

    gluPerspective(45.0f, this->iWidht/this->iHeight, 0.0f, 100.0f);

    http://www.opengl.org/wiki/Common_Mi...ad_znear_value
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •