Page 1 of 2

Realtime input and drawing.

Posted: Wed Oct 13, 2004 5:34 am
by soks
Ok, I'll start outright by saying I'm programming a game, and I've just made the move to wxWidgets, woot.

But... generally when I would do something like this in Win32 I would use winMain and do something like:

while(!done) {
grab events
handle MY events
handle defaults (go ahead windows...)
game code (includes drawing)
}

but with wx I realized the main thing really isn't wanna-be editible and seems to leave me with only two options, maybe 3 =P

One way would be to use my main frames EVT_IDLE to just handle everything (drawing,input,etc). (can I use the wxApp's EVT_IDLE?)

Another would be to use IMPLEMENT_APP_NO_MAIN, but then I'm not sure about wxEntry's loop variable and whether or nto that makes my main lose control, also with that way I'm worried that I would have to handle more events that the application does by default... not really sure.

A third way might be threads, though I've never actually worked with them, and it really seems like a hack to use it for this.

Any suggestions as to which method to use? I'm trying the first one right now... have some issues... I think it's because I'm trying to use a wxApp with EVT_IDLE... anyways, any ideas?

Posted: Wed Oct 13, 2004 7:15 am
by eco
I'd do option 4: Don't use wxWidgets to make a game. In my opinion, unless you need a lot of GUI code (controls/events/etc.) I'd just use SDL for everything. It's also crossplatform but is faster and more geared towards games. If you need a lot of sound/joystick/keyboard stuff wxWidgets might just get in the way.

That said, I'd probably do the first method you wrote if I were to do it. Just make sure you scale your graphic movement code by time rather than "frames" since I doubt EVT_IDLE is going to be very consistent about its execution.

well...

Posted: Wed Oct 13, 2004 4:39 pm
by soks
Well yes I realize SDL and even GLUT would be good choices, however due to the network options that wxWidgets provides it seemed much more integrated and developed.

Also any development tools I'd be making would require the capabilities of wxWidgets so I figured I might as well learn it... but I guess learning wxWidgets and SDL would only help me.

Ok, so I looked at SDL (it's been a few months since I've been on that site) and I realize that it would be missing one thing... netcode, unless I'm wrong of course. Any ideas on what I would be able to do when it comes to network code? I'm going for cross platform of course...

I don't think my dev team is going to like this switch =P
But then again I guess I will only need widgets for the tools more than anything else.

As for scaling by frames, never =p

Posted: Wed Oct 13, 2004 4:47 pm
by soks
Ok, well I see now that I would most likely have to use wxWidgets for the netcode seeing as how SDL does not support it.

So here's a question, I don't really need to run an instance of application or links against most of wxWidgets to use the net part of the API do I? is there something that I don't know about here?

Re: well...

Posted: Wed Oct 13, 2004 4:58 pm
by caseyodonnell
SDL not GLUT. GLUT is good for demos, or proof-of-concept.

Networking: http://www.libsdl.org/projects/SDL_net/
soks wrote:Well yes I realize SDL and even GLUT would be good choices, however due to the network options that wxWidgets provides it seemed much more integrated and developed.

Posted: Wed Oct 13, 2004 11:12 pm
by soks
Wow, SDL_net, that's cool. Thanks.

Umm... this better be faster... =P

Yeah, I'm still not sure whether I should switch over or not... hrmpf. I guess I'll try =P

Posted: Wed Oct 13, 2004 11:18 pm
by soks
About this SDL_net... can I use it with something other than VC++... I mean I don't want DLL's... but why the heck is the developer lib file just for vc...

Posted: Thu Oct 14, 2004 8:21 am
by geon
As for scaling by frames, never =p
So you rather have the game speed depend on the computer? Or do you lock it to a speciffic framerate, so all computers run it equally slow?

Both alternatives suck.

Posted: Thu Oct 14, 2004 4:09 pm
by soks
wow, it's like people don't read anything at all...

I've been doing this for too many years and am too young to be able to control myself still, so I just won't comment.

Suffice it to say I enjoy the API interface of wxWidgets soooo much, I'll stick to it for now and hopefully things go okay.... worst case scenario I'll need SDL later or something, hopefully using OpenAL will be enough.

Thank you for all your help and.... *poof* *dissapears*

Posted: Thu Oct 14, 2004 4:28 pm
by eco
soks: Good luck. Let us know how it works out.

geon: Neither option. I wrote above he should scale by time and that's what he was replying to. Scaling by time is the solution to both cases you wrote and that's precisly what he says is doing.

Posted: Thu Oct 14, 2004 7:48 pm
by Scorcher24
I know that maybe a little be offtopic but I have tried before a few months to code a little game by myself: a blackjack. I used also SDL and I am missing one feature (or didn't find it):

Is there any way to add a menu to the window ?? thats something sdl is lack of...
rya.
Scorcher24

Posted: Thu Oct 14, 2004 8:03 pm
by ramirez
Scorcher24 wrote:I know that maybe a little be offtopic but I have tried before a few months to code a little game by myself: a blackjack. I used also SDL and I am missing one feature (or didn't find it):

Is there any way to add a menu to the window ?? thats something sdl is lack of...
rya.
Scorcher24
SDL isn't designed for that.
Making a simple GUI controller for a menu yourself isn't hard though.

Posted: Fri Oct 15, 2004 12:18 am
by Ryan Norton
Don't forget allegro -
http://alleg.sf.net

Posted: Fri Oct 15, 2004 2:19 am
by caseyodonnell
OpenAL is quite good for most things.

However...if your app is going to be free, I highly recommend [url=htttp://www.fmod.org/]FMOD[/url]. FMOD is cross platform, fast, cool, good C API, and is pretty trivial to wrap in C++.

You shouldn't have trouble using either in your app. I've used both for proof-of concept stuff along side wxWidgets, and I've also used both along side SDL.
soks wrote:...hopefully using OpenAL will be enough.

Posted: Fri Oct 15, 2004 3:09 am
by soks
AH! FMOD... hrm. Well now that just got me thinking even more, hopefully I won't be dealing with sound too soon.

Wow, thanks a lot for all the help and advice peeps.