DirectX Windowed Mode - Slow Down Issues

Started by
8 comments, last by Evil Ozzy 14 years, 8 months ago
Hi, I've written a simple puzzle game using C++, Direct7, Windows XP and it runs in Windowed Mode. (It also runs in full-screen but that's fine). In windowed mode the game runs at a healthly frame rate of around 90fps. This means all the movement and ainimation is smooooooth. However, start moving the mouse cursor over the game window and the frame rate absolutely dies, the animation becomes jerky, down to almost a frame per second, in fact the whole game just sloooooows down to a crawl. I am guessing it's because the game window suddenly gets hundreds of MOUSEMOVEMENT messages to deal with, and those end up in the messsage queue and have to be processed, therefore the game which runs in the idle time when there are no messages to be processed just suffers. Now, I've seen plenty of games that run in windowed mode that don't suffer from this. So what am I missing, and what do I have to do the prevent my game from running like a dog just because you moved the mouse cursor over the game window. Thanks in advance.
Advertisement
Do you have pointer trails on?
Pointer trails...Nope....just a regular mouse pointer!

As I said, as soon as the mouse cursor moves over the game window, it criples performance, it must be that the window messaging is dealing with loads and loads of MOUSEMOVEMENT messages, but I have no idea what to do about it.

There must be a simple solution as many windowed games reply upon the user using the mouse to control the game character or make selections etc...

If it helps the window is 800x600 and the primary DirectX surface uses the whole of the client area. Nothing out of the ordinary there.
Quote:Original post by Evil Ozzy
As I said, as soon as the mouse cursor moves over the game window, it criples performance, it must be that the window messaging is dealing with loads and loads of MOUSEMOVEMENT messages, but I have no idea what to do about it.
Nope, that won't make the slightest difference, unless you're doing a crapload of work in your WM_MOUSEMOVE handler. A profiler will tell you where all the time is going.

We'll need to see your code to be any help.
OK Cool..

Am at work at the moment, so I'll post my main game loop in a bit...and see if you can see anything odd...

Defo not doing anything on a MOUSEMOVE event/message...but will double check later..

Cheers in advance...
How are you handling restoring your graphics, if your doing it based on like WM_ACTIVATE (I can't remember what it is), and its reloading stuff even if its not gone that cause alot of problems.
Sorry, havent had a chance to post the cod eup yet, pulled an all-nighter at work and still going aarrgghh..

Defo nothing to do with restoring grahpics, its purely when the mouse cursor is moved over the game window, the performance is crippled, its got to be the game loop and the mousemove messages...ill try to post the code later...
Ahhhhhhhh

Found my issue! I wasnt rendering the scene if there was a message to be processed in the message queue.

So when it got flooded with MOUSEMOVE messages the scene wasnt being updated for several frames, hence the apparent slow down.

So a miner tweak of the maion game loop and I'm back in business lol

Cheers
That doesnt sound like your issue unless you're on a 100mhz pc.

Proccessing 2000 messages is near instant.

If you proceed with your current approach of not processing ALL messages before rendering, you will encounter problems with this in the future.

In a more message-heavy environment such as an FPS, (mousemove and keyboard clicks constantly), processing 1 message per frame would be the end of you.
Defo was the issue. Game now runs at the correct speed no matter how much you wiggle the mouse over the game window.

Like I said the problem was not rendering the scene whenever I was processing messages, so missing a few here or there was making a big difference to the action on screen, although the game loop was still probably running at 70-90 FPS, the screen was only getting updated 10-15 times a second.

Basically it was a mistake on my part.

This topic is closed to new replies.

Advertisement