Jump to content
  • Advertisement

Archived

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

pai

problem with simple d3d9 app

This topic is 5425 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

hi there. i''ve just started to practice some dx9. after creating an dx object and getting the device to simply draw a blue screen (windowed) as described in the dx tutorials the window appearing always hangs my computer when another window is placed above the one i created. hanging means: mouse movement hangs, winamp hangs, and so on any idea what the problem is?

Share this post


Link to post
Share on other sites
Advertisement
My guess would be something to do with either the message loop, or the handling of the WM_PAINT message (if you do indeed handle that). Moving a window around on top of yours causes Windows to send your application the WM_PAINT message, so maybe it''s in there that a problem occurs. It''s hard to tell, though. If it isn''t too large, could we see the WindowProc code and the message loop?

Share this post


Link to post
Share on other sites
of course you can. :D

while( WM_QUIT != msg.message )
{
bGotMsg = ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) != 0 );
if( bGotMsg )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
} // if

else
{
// Render einen Frame, wenn gerade keine andere Nachricht vorliegt.

if( FAILED( Render3DEnvironment() ) )
SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
} // else


} // while



and the windowproc switch statement

switch( uMsg )
{
case WM_PAINT:
Render3DEnvironment();
break;
case WM_DESTROY:
Cleanup3DEnvironment();
PostQuitMessage( 0 );
return 0;
default:
break;
} // switch


Share this post


Link to post
Share on other sites
Well, I don''t see anything definite, but...

1) BeginPaint()/EndPaint() might be important with typical GDI stuff, and it won''t hurt to try it, but if you''re using DX9 to draw, then I doubt it will be an issue.

2) I''ve heard of people having odd problems when their message loop handles only one message per iteration. Typically, it''s suggested to have a smaller loop that calls PeekMessage over and over until there is no message left (or a message was WM_QUIT), then do your game update/render stuff, and then repeat the outer loop.

I can''t see anything seriously wrong, though. Do you raise your thread/process priority anywhere? Because the most common cause of those symptons that I''ve had has been an infinite loop in a program with raised priority.

3) I just saw something. Maybe... Do you call DefWindowProc() in your WindowProc? Because that could cause some serious issues if you don''t. I noticed that your default: case was simply a break; , but I suppose you called DefWindowProc() after the switch statement most likely. But if not, that''ll change a lot of things.

Share this post


Link to post
Share on other sites
I believe if you don''t handle WM_PAINT, but do pass it on to DefWndProc it will do an empty pair of BeginPaint/EndPaint for you. You should definitely be calling DefWndProc for any message you do not handle yourself.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
hey everyone.

firstly: i found the problem but don''t really understand it atm. i just changed the message loop from the above quoted to the following code fragment:


MSG msg;
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
} // while


quote:
Original post by Agony
2) I''ve heard of people having odd problems when their message loop handles only one message per iteration. Typically, it''s suggested to have a smaller loop that calls PeekMessage over and over until there is no message left (or a message was WM_QUIT), then do your game update/render stuff, and then repeat the outer loop.



i think i have to try your version, agony. what exactly is the difference between peekmessage and getmessage? and what version of the message loop would be better (if both were working correctly ;-)

thanks for your help.

-pai

Share this post


Link to post
Share on other sites
ok. another thing is just found out: my window (peekmessage version) just hangs when its completely disguised. if there is just a part of the window disguised nothing hangs.

any idea?

Share this post


Link to post
Share on other sites
Try to run your program under spy++ to see if there is something wrong.

I don't understand how your second version of message loop can draw anything, you don't call your rendering function.

From msdn :
"Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning."

Are you using thread ?


[edited by - arsouille on February 6, 2004 6:34:40 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Arsouille
Try to run your program under spy++ to see if there is something wrong.

I don't understand how your second version of message loop can draw anything, you don't call your rendering function.

From msdn :
"Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning."

Are you using thread ?


hey arsouille, you're right. the call to the rendering function has been in the 'catch WM_PAINT' statement.

as i don't know what you mean by thread, i suppose i don't use it ;-)

[edited by - pai on February 6, 2004 6:52:36 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!