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: open GL glitch

  1. #1
    Intern Contributor
    Join Date
    Feb 2011
    Posts
    50

    open GL glitch

    hi

    For some awkward reason my projects displays my object once (found out during debugging) on screen and then displays the clear screen colour constantly.

    It specifically happens after the gluSwapBufffers(); call. However weirdly, it wasn't doing this before so I'm just left wondering if this has happened to you guys.

    Anyway below is an extract of my project, but I'm not sure what causes such an error.

    Code :
    Draw()
    {
    	switch (gbShow)
    	{
    	case 1:	
     
    	glPopMatrix();
    	glTranslatef(f_X,f_Y,0.0f);
    	glPushMatrix();
    	//visible
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D, gui_TextureID);
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    	glNormal3f(0.0f,0.0f,1.0f);
    	glEnable(GL_BLEND);
    	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBegin(GL_QUADS);
    	glColor4f(1.0,1.0,1.0,0.9);
     
        glTexCoord2f(gfCoord_1X, gfCoord_1Y);glVertex3f(gfVertex1_X, gfVertex1_Y, 0.0f);
        glTexCoord2f(gfCoord_2X, gfCoord_2Y);glVertex3f(gfVertex2_X, gfVertex2_Y, 0.0f);
        glTexCoord2f(gfCoord_3X, gfCoord_3Y);glVertex3f(gfVertex3_X, gfVertex3_Y, 0.0f);
        glTexCoord2f(gfCoord_4X, gfCoord_4Y);glVertex3f(gfVertex4_X, gfVertex4_Y, 0.0f);
        glEnd();
        glFlush();
    	break;
    	default:
    		std::cout<<"object hidden"<<std::endl;
    		break;
    	}
    }


    Code :
    void display(void)
    {	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glClearColor(1.0,0.0,0.0,1.0);
     
    	//STATE: MENU
    	C_Visual_Obj qMenu((GLboolean) 1,
    		                guiSmile_txtID,
    						(GLboolean)0,
    						1.0f,
    						300.0f,
    						100.0f,
    						0.0f, 0.0f,//V1
    						100.0f,0.0f,//V2
    						100.0f,50.f,//V3
    						0.0f,50.f,//V4
    						Anime_Static);
    	qMenu.Draw();
     
    	//SATE: GAME
     
    	//STATE: RESET
     
     
       glutSwapBuffers();
    }

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: open GL glitch

    This looks not good :
    Code :
       glPopMatrix();
       glTranslatef(f_X,f_Y,0.0f);
       glPushMatrix();
       // draw commands
    It should probably be like :
    Code :
       glPushMatrix(); // save current Xform
       glTranslatef(f_X,f_Y,0.0f); // apply translation
       // draw commands // draw the translated stuff
       glPopMatrix(); // restore Xform (ie. cancel translation here)

  3. #3
    Intern Contributor
    Join Date
    Feb 2011
    Posts
    50

    Re: open GL glitch

    You are amazing man

Posting Permissions

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