#### Archived

This topic is now archived and is closed to further replies.

# Slow windowed mode

This topic is 5602 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I recently added a windowed mode for my DirectDraw app for debugging, but for some reason the application runs really slow unless I call GetDC () and ReleaseDC () on my backbuffer every frame. What is really strange is that the framerate is in the 100''s, but when I move the cursor it takes about 2 seconds for it to move. When I click it takes another two seconds for the application to do anything. But it works fine when calling GetDC every frame. Thanks.

##### Share on other sites
I guess you''re using "GetMessage()" instead of "PeekMessage()".
It happened to me in Direct3D, I was using "GetMessage()" and only
when I moved the mouse over the window it runned fast otherwise it
was slow as hell....

"GetMessage()" is only used for aplications, if you''re developing a
game/demo you should use "PeekMessage()"

Hope that helps

KaMiKaZe

##### Share on other sites
I don''t have the code with me right now, but it worked in fullscreen mode just fine. So I wouldn''t think it would have something to do with the message pump. And what is the deal with GetDC ()? The idea that I have to call it in order to get my program to work right is mind boggling :)

Good suggestion though.

[Edited by - JonW on July 21, 2009 8:23:46 PM]

##### Share on other sites
Try the "PeekMessage()"
Well, about GetDC(), maybe it sends a notification to the window so the
"GetMessage()" receives the notification message and runs with the rest of the code...

[Edit:] About working fine in fullscreen:
I think that when direct draw is in fullscreen mode it renders directly to the
monitor, not to the window...

KaMiKaZe

[edited by - Kamikaze15 on January 22, 2003 10:40:38 AM]

##### Share on other sites
No luck with PeekMessage (), but you are probably right in that the problem lies in Windows messages.

Maybe it is how I created the window? I only use WS_OVERLAPPED for the style, but maybe I need CS_VREDRAW, CS_HREDRAW, and CS_OWNDC also?

##### Share on other sites
When I create my D3D windows I create it only with WS_OVERLAPPEDWINDOW
flag.
Don''t know what''s your problem, but you could see if it''s a windows messages
problem try to "PostMessage()" every frame to the window, if it works ok then
the problem lies on windows messages otherwise I can''t see where your
problem lies.
Good Luck

KaMiKaZe

##### Share on other sites
right after you create you window do the following, sometimes it gives a huge boost in windowed mode.

rect_t rc(0, 0, width, height); // desired width , height

SetWindowPos(g_hwnd, NULL, 0, 0, rc.width(), rc.height(),
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );

BTW rect_t is a simple wrapper around the regular RECT.

hope this helps ...

##### Share on other sites
Are you handling WM_PAINT. In this message handling, you ValidateRect()... or InvalidateRect().... not sure...

And by the way, if you resize your window (if you have an WS_OVERLAPPEDWINDOW), it will really things up.

/* Bullmax */
-------------
Reality has many forms : good and evil, black and white, yin and yang.

##### Share on other sites
I think that u should call GetDC() and ReleaseDC() every frame, i read it somewhere but i don''t remember exactly.

##### Share on other sites
I found out that you can call GetDC () on any surface every frame and it will work. I wasn''t handling WM_PAINT before, but I tried putting in some code to validate:

  // Window needs repaintingcase WM_PAINT:{	// Tell Windows to leave us alone	PAINTSTRUCT ps;	HDC hDC = BeginPaint (hWnd, &ps);	EndPaint (hWnd, &ps);	break;}

But it didn''t work.

Kamikaze : What message do I post with PostMessage ()?
remi : I''ll use that as a last resort.
neo_ryder : The game runs just fine, like I said the fps is about 180. But everything goes so slow if I don''t call GetDC ().

Thanks for all the replies.

[Edited by - JonW on July 21, 2009 8:41:57 PM]

• 10
• 16
• 9
• 13
• 41