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 4 of 4

Thread: PC interrupt using glClear

  1. #1
    Intern Contributor
    Join Date
    May 2001
    Posts
    54

    PC interrupt using glClear

    hi,

    If I have glClear() in the main loop, this causes my PC to hang for one second after hitting the ESC to quit the application.

    Any reasons why glClear() causes this behaviour? Obviously, putting SwapBuffers() after glClear() eliminates the problem.

    thanks.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: PC interrupt using glClear

    I assume you're drawing in the idle loop?
    (I consider this bad Windows programming style in general, there are only very few excuses.)
    I suppose all the clears are buffered and need to finish before the program can exit.
    SwapBuffers seems to limit the amount of buffered commands, otherwise interactive content would lag too much.

  3. #3
    Intern Contributor
    Join Date
    May 2001
    Posts
    54

    Re: PC interrupt using glClear

    Hi Relic

    What I mean is i'm experimenting to see what would happen to the output. Here is my code:
    Code :
    while ( !(GetAsyncKeyState(VK_ESCAPE) & 0x8000) )
    	{
    		PeekMessage(&msg,NULL,0,0,PM_REMOVE);
    		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    		//glClearColor(0, 0, 0, 0);
    		//Demo();
    		//SwapBuffers(hDC);
    	}
    The Demo() has the actual drawing routines...

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: PC interrupt using glClear

    Sorry, I have no idea what your trying to achieve.
    Your code doesn't contradict my previous post.
    You send a glClear in the main event loop.
    Fine, the OpenGL driver may be able to buffer many of those. If you don't flush, finish or swap the OpenGL driver may still have a thousand clear commands to chew on until your program can exit.

Posting Permissions

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