Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK .NET / Event handlers for 3D Game play

Years of Service
User Offline
Joined: 1st May 2009
Posted: 1st May 2009 13:53
As an experienced Visual Studio (VB.NET) developer, most interactive stuff in Windows apps is done via event handlers.

With 3D games however, it seems that everything is traditionally done within a main game loop where the SYNC is called at the end of the loop to update the screen.

Has anyone tried to develop a 3D game using event handling instead? The reason why I think it would be good is that it's a very intuitive way of developing a game. I'm just wondering if there is a big performance hit by using event handlers? Unless anyone knows, I guess there is only one way to find out!!!
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st May 2009 20:19
You can't really use event handlers exclusively, since things like calling 'sync' need to be done every frame, but most games use a similar setup where in the game loop, you check if certain triggers have happened, and then call the necessary routines.

Years of Service
User Offline
Joined: 21st Jan 2009
Posted: 17th May 2009 13:16
Hi ulogix,

when developing games you have to think different when it comes to events. Since I also do mainly C# business / enterprise applications, I know this can be sometimes frustrating when switching over to less comfort.

Using DGDK.NET you could still declare delegates and events and raise them from the loop, although I wouldn't recommend them since you cannot rely on them, especially because of the fact (as Diggsey stated) that a game has it's own synchronization (frame), so that to be correctly in sync with the main game loop, you should call your methods from inside that loop (maybe using flags, states, ...).

As you have said, 3D games seems to be traditionally developed within a main game loop. That's true and basically every application is build upon that concept, even if it is not always clear. Windows itself is basically a big loop where messages are processed.

Keep in mind that, when it comes to game development, you have to follow some different paths, since performance is one of the biggest factors. Keep your paths short, do not use delegates and event handlers while in game loop (trust me, it's not a good idea, I just already tried that ), make yourself a state handler which tells you in which state you currently are, trigger your own routines instead of using .NET events, and you're on the good side.


[ this post expresses my personal view ]
Years of Service
User Offline
Joined: 1st Aug 2009
Posted: 7th Aug 2009 11:35
I think you could do ok with it if you do it right...

Mostly you would just have to make sure the windows message pump could take care of any events. for example...

Quote: "
bool exit = false;
// I am not sure if this works outside of a windows forms app
// but this is the only way I know of at the moment to pass
// control to the windows message pump...
// Assuming your event handlers and main function take care of
// all the processing required...
if(exit) break;

[ Amnzero ]

if(enemy == troll) runAway();

Login to post a reply

Server time is: 2023-05-29 15:29:08
Your offset time is: 2023-05-29 15:29:08