Jump to content
  • Advertisement
Sign in to follow this  
ProgrammerZ

Calling BeginScene and EndScene slows down my program . . . help!

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

Hey guys. I finally finished my renderer class, so I immediately started playing around with it, of course. However, I noticed that my window was a little slow -- it took a second to drag it around, and when I moused over the close button (xp) it took a second to highlight it. I also tried drawing a sprite at the location of the mouse cursor, but it was terribly jerky and lagged behind a lot, and if I pushed keys at the same time, it would follow along the trail my cursor had left a few seconds ago. Also, I did a simple check to see if my frame rate was normal (rendering a sprite every other frame) and it was. It's like my message queue is on a delay. However, I noticed that if I didn't call BeginScene and EndScene (and didn't do any rendering) my window was completely responsive. Does anyone know what my problem could be? -- ProgrammerZ

Share this post


Link to post
Share on other sites
Advertisement
I work with Delphi (You didn't mention what your IDE is), but I think that the problem has to do with this (it happened to me at first):

You should always check in your main loop (either yours or from your IDE) the immediate response to messages dispatched from the operating system.

That is, make sure to verify after each BeginScene ... EndScene block if there is a message queued and then immediately process it (for example, messages related to the mouse or keyboard).

[Edited by - jpventoso on September 16, 2008 12:59:21 AM]

Share this post


Link to post
Share on other sites
Are you completely pumping the message loop every frame? It's a common mistake to only process one message per frame, and this causes the message queue to become backed up. Your main loop should look something like this:


// main game loop
while (gameIsRunning)
{
// loop until the message queue is empty
MESSAGE msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
DispatchMessage(&msg);
}

Update(); // Update game logic
Render(); // Render everything
}


Share this post


Link to post
Share on other sites
Original post by MJP
Are you completely pumping the message loop every frame?

Oh. Duh. (kicks self)

Anyway, I changed an
if
to a
while
in my message processing code, and it works like a charm. Thanks! I guess I hadn't noticed that mistake when I was coding that part.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!