Realtime input and drawing.

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Realtime input and drawing.

Post 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?
eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post 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.
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

well...

Post 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
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Post 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?
caseyodonnell
Knows some wx things
Knows some wx things
Posts: 31
Joined: Fri Sep 10, 2004 1:03 pm
Location: Troy, NY
Contact:

Re: well...

Post 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.
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Post 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
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Post 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...
geon
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Tue Sep 07, 2004 4:10 pm
Location: Sweden, Uppsala

Post 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.
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Post 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*
eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post 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.
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Post 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
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
ramirez
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Oct 14, 2004 6:58 pm

Post 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.
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

Don't forget allegro -
http://alleg.sf.net
[Mostly retired moderator, still check in to clean up some stuff]
caseyodonnell
Knows some wx things
Knows some wx things
Posts: 31
Joined: Fri Sep 10, 2004 1:03 pm
Location: Troy, NY
Contact:

Post 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.
soks
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Oct 13, 2004 4:57 am

Post 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.
Post Reply