glFinish() slowdown

Started by
3 comments, last by hannibar 18 years, 1 month ago
I have a program with two windows in which I draw with openGL. The problem is that sometimes glFinish() is very slow. It happens in this function :
Window *win = G->window->first;

	while (win){
		__int64 test1, test2;

		selectWindow(win);

		test1 = gui_get_current_time_precise(); //for measuring the slowness
		glFinish();
		test2 = gui_get_current_time_precise(); //for measuring the slowness
		printf("%d %d\n", (int)(test2 - test1), win->winHandle); //for measuring the slowness

		SwapBuffers(win->winInfo->hdc);
		//wglSwapLayerBuffers(win->winInfo->hdc, WGL_SWAP_MAIN_PLANE);
		win = win->next;
	}
}
I have two windows opened : One larger window (640 * 480) and a smaller one (320 * 240). When the small window is the active window, glfinish() slows down to more that 35 milliseconds when it is on top of the large window. When I place the small window next to the large one, glFinish() only takes about 2 ms. Does anyone know what can cause this behaviour ? btw : The content drawn in the window is not much. At the moment : One rectangle in each window. so no problem here. Thanks in advance.
Advertisement
Swapping the buffers implicitly calls glFinish anyway, so you shouldn't be calling it in the first place.
If at first you don't succeed, redefine success.
Indeed, but when I leave glFinish() away, SwapBuffers becomes slow. So that's where the problem is.
Check out this and this.

If anything, you should be calling glFlush(), then do any necessary updating, then once you've done everything else, feel free to call SwapBuffers(). It pays to read up on these things, 'specially when you don't know how the functions work.
Thanks for the answer. Unfortuantely, removing glFinish() and using glFlush() doesn't help either. Swapbuffers is still slow as hell. Also not calling anything doesn't help.

The weird thing is that this slowness doesn't always happen. It doesn't happen when the small window doesn't overlap the larger one. And when the small one overlaps the larger one partially is sometimes happens, and sometimes doesn't happen.

This topic is closed to new replies.

Advertisement