Archived

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

stranger4u

DirectDraw Blt slowing down windows?

Recommended Posts

Hi there, I''m using lpDDSFrontBuffer->Blt( &rcWindow, lpDDSBackBuffer, NULL, DDBLT_WAIT, NULL ); to blit the backbuffer into the frontbuffer of my windowed game. But that slows down windows. When I move the mouse cursor it''s jumping around. How is that possible? I just call the above Funktion in the main game loop. Do I call it too often?

Share this post


Link to post
Share on other sites
More information:

I rewrote my application to use ddutil.h for all the DirectDraw stuff. But the problem remains. Mouse is jumping, windows slows down. I still don''t understand why.

Share this post


Link to post
Share on other sites
Why do you need to blit the backbuffer to your front buffer? Why not just call

lpDDSFrontBuffer->Flip(NULL,DDFLIP_WAIT);

that flips the backbuffer to the front buffer (presuming you got your backbuffer as an attached surface of lpDDSFrontBuffer)

If you have any more problems post your code that you use for setting up directdraw.

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=

Share this post


Link to post
Share on other sites
Because he''s in window-ed mode, and you can''t do page-flipping in window-ed mode!!

I''m doing something that runs in window-ed mode, I''d be interested to find out if you find what is causing this problem. How many frame per second are you getting btw??

JJ.

Share this post


Link to post
Share on other sites
I can''t flip because I''m not using full screen mode. It''s just a window in which I''d like to draw. It works, but the slowdown is very weird.

The code I use is:

Display.Clear(0);
Display.Blt( 0, 0, SurfaceNormalBlocks, 0);
Display.Present();

Display is of the type CDisplay (from ddutil.h), SurfaceNormalBlocks contains just a bitmap that I want to display on the screen.

The code works fine, the bitmap gets drawn, but still the slowdown occurs.

Share this post


Link to post
Share on other sites
I think your app slows windows down because you did not include a framerate limit or do not render only on WM_PAINT.
At least I had this kind of problem.

Share this post


Link to post
Share on other sites
quote:
Original post by Jiim
Because he''s in window-ed mode, and you can''t do page-flipping in window-ed mode!!

I''m doing something that runs in window-ed mode, I''d be interested to find out if you find what is causing this problem. How many frame per second are you getting btw??

JJ.


I don''t know, I don''t calculate the fps. This is my first game anyways so right now I''m just trying get something on screen. And that works.. If I manage to get rid of the slowdown everything is alright. IF.

Share this post


Link to post
Share on other sites
quote:
Original post by Hippokrates
I think your app slows windows down because you did not include a framerate limit or do not render only on WM_PAINT.
At least I had this kind of problem.


That sounds interesting. No I don''t have a limit, I just Blit everytime the mainloop is running. So that''s causing the slowdown? Really interesting, will try to limit it. Thanks.

Share this post


Link to post
Share on other sites
I had a similar problem when my main loop wasn''t taking long enough and was able to solve the problem by inserting Sleep(0); at the end of my main loop which gives windows a chance to update the mouse.

Share this post


Link to post
Share on other sites
It''s really frustrating when you''re new to game programming and then at the very beginning something like this happens for no reason (at least no reason you would think of). Something like that happened before and I gave up on game programming. Maybe this time I''ll have more luck and go through with it.

Share this post


Link to post
Share on other sites
It''s not so much something that is game-programming specific but is a more general thing in a co-operative environment. You''ve got to remember that there are other programs running at the same time as yours, and you''ve got to respect that especially if you''re running in window-ed mode.

The Windows scheduler will allocate time on the CPU for each thread of execution running, but for this to work effectively you still need to be careful to make sure that you''re not hogging the CPU. Obviously in a game, you want to hog the CPU as much as you can, so you need to strike a balance between hogging the CPU, and letting other threads run.

Calling Sleep(0) just indicates to Windows that you are prepared to give up the remainder of your current time-slice on the CPU to whatever else wants to run. This is usually enough to keep Windows looking reasonable, anything else that needs a lot of time on the CPU will be given it.

JJ.

Share this post


Link to post
Share on other sites