Jump to content
  • Advertisement

Archived

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

JonW

Slow windowed mode

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

AdjustWindowRectEx(&rc, GetWindowStyle(g_hwnd), GetMenu(g_hwnd)!= 0,GetWindowExStyle(g_hwnd));

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 repainting
case 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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!