Advertisement

windows messages.

Started by October 02, 2000 06:04 PM
2 comments, last by Smegboy 24 years, 3 months ago
Hi, I work for an education software company and we have a suit of software that has about 1000 small programs. about a third of these are direct-x direct3d based. About 15 of these programs are games and require the user to press heaps more keys than the other programs. It is these programs that sometimes freeze or hang at the end of the program. I think it is due to not being able to process all the windows messages throughout game play. When the program finishes it has a backlog. Does this seem plausible? My junior programmer removed my application.processmessages which I am a little annoyed about, but hopefully this will make a difference. I have also turned key repeat rate down on the machines to minimise keypress messages... How do the powerhouses deal with issues like this?
It''s probably the setup for your message processing loop is not suitable for gaming.

Take a look at some of the windows programming resources here on how to setup the loop.
Advertisement
I don''t know how other people do it, but I usually don''t process normal game keystrokes in the windows procedure. Instead I use a macro which uses GetAsyncKeyState() function to test for a certain key or multiple keys. On the other hand, if I want keyboard input with a repeat rate or for ASCII input, I use a Windows procedure. How are you processing the keys?

Alex
bigshot@austin.rr.com

Opinions are like assholes. Everyone has one and they all stink.
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Sounds like you are using Delphi. Why are you so annoyed about the removal of all calls to Application.ProcessMessages? I would be congratulating the junior programmer. Give the junior programmer a pat on the back. I would have been pushing for that to happen a long time ago. Calling ProcessMessages can have bad side-effects if you do not fully understand how the message pump and events work. Being a Delphi programmer since 1996, I have never found any real-life situation where ProcessMessages was required. A game will generally have a few functions that are called once each frame, therefore they should be quick to execute. This means that control gets back to the message very quickly anyway, so once again there is no need for ProcessMessages.

I do not think it would be a backlog of messages. If this was the case, then you would be seeing movement happening on the screen long after you released the key. If you are using the Application.OnIdle event for rendering of each frame (I assume you are using the OnIdle event and setting the Done parameter to False), then you can be assured that all messages in the queue are processed before the OnIdle event is triggered. So I would be looking elsewhere for possible causes.

Are you sure that you are releasing the Direct3D and DirectDraw objects properly? In my Delphi game engine, I found that order of destruction of these objects is very important.

On another note, have you tried using DirectInput for these games? It would be preferable to using standard Windows messages for keyboard and mouse input. DirectInput is also very easy to use.

ProcessMessages is evil. Evil I tell you. Evil!


Steve 'Sly' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement