GDI+ backbuffer?

Started by
13 comments, last by Aardvajk 15 years, 6 months ago
Yay [smile].

Re it stopping moving, I'd guess your message loop is perhaps different to mine and you are only calling your update-and-invalidate method in the absence of other windows messages.

When you are moving a mouse across a window, it is getting a constant stream of WM_MOUSEMOVE messages so unless you are calling your update function after every message, you won't get WM_PAINTs in between them.

Post your message pump and show how you are calling your update function "every 25 ticks".
Advertisement
MSG msg;	while(true)	{		DWORD startpoint = GetTickCount();		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))    		{			if (msg.message == WM_QUIT)				break;			TranslateMessage(&msg); 			DispatchMessage(&msg);		}		while ((GetTickCount() - startpoint) < 25);		if (Quitting==false) 			InvalidateRect(hWnd,NULL,false);	}	return msg.wParam;
It's a sofa! It's a camel! No! It's Super Llama!
Hmm. You don't really want to delay your message pump while you wait for a tick. I think that WM_MOUSEMOVE messages are getting queued up in that time maybe. Not too sure.

I'd do something like this untested version:

DWORD startpoint=GetTickCount();while(true)    {    if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))            {        if(msg.message == WM_QUIT) break;        // I assume you set your Quitting variable in your WM_CLOSE handler or something        TranslateMessage(&msg);         DispatchMessage(&msg);        }    if (Quitting==false)         {        DWORD point=GetTickCount();        if(point-startpoint>=25)            {            InvalidateRect(hWnd,NULL,false);            startpoint=point;            }        }    }return msg.wParam;


Basically, every loop, process a message if there is one. Call your update when the tickcount passes the threshold, but don't stop your main loop waiting for it.
Yay! That's probably what's wrong.

Hmmmmm now it only updates when the window doesn't have focus... very strange...

EDIT: Actually I found out that it never gets to the InvalidateRect() function, so it only updates when the window is painted by windows.

EDIT AGAIN:

Okay its fixed, I misinterpreted your example and accidentally put the GetTickCount reset function INSIDE the loop, which caused both variables to be the same the whole time.


It works Perfectly now, thank you so much for all the help [wink]
It's a sofa! It's a camel! No! It's Super Llama!
np

This topic is closed to new replies.

Advertisement