Ok ive writen some nice stuff using the irrlicht engine ...
My main goal was to write a multiuser network game..
Ive got a nice chat client and server allready to use..
I took all my code for irrlicht and put it into a header file..
Now beings there are many funtions in this header file how do I go about attaching it to my user sign in button..
At this time the sign in button just signs the person onto the chat client using the name they chose..
Example below..
}
if(pkg.request == SIGNIN){
bSignIn = TRUE;
m_wndShow.ShowMessage(pkg);
OnSignOut();
}
Its something like this..
I tried to rename the main to something else like mainwindow and just added it to the code like this..
}
if(pkg.request == SIGNIN){
bSignIn = TRUE;
m_wndShow.ShowMessage(pkg);
OnSignOut();
mainwindow();
}
But this dosnt work lol..
Im stumped on how to call the entire program code ive writen to run along with signing in the user..
So when they click on sign in It will load and run my code with the engine in its own window as if it was executing a second program..
I had considered useing a exe merge program and just merging them together but not only do most antivirus software not like these files it would also execute both the chat and 3d window at the same time wether the user was signed in or not...
So to clear this up and make more sense, I have a working program that I want to merge my irricht code into. So that when the sign in button is pressed the entire irricht code is executed as well..
It says that I could post some C++ questions here so I hope that someone here can help..
Thanks any help that anyone gives..
C++ ?
In short: "if you can't beat the UI, join it". Make the Irrlicht mainloop into the mainloop, make the communications into supporting functions.
Think about how the end-user would use your program:
he/she starts up some user-interface (either GUI or Irr) and clicks some buttons. Then uses the user-interface some more to actually communicate with other users. Then maybe disconnects and opens another connection. Etc. Etc.
It's all event-driven, and both GUIs and Irrlicht have good event-mechanisms.
So... what I'd do is just make an Irrlicht client, calling whatever communications functions you have when text needs to be sent to the server side.
Poll (don't wait) the receiving comms functions from the Irr mainloop.
Personally I'd make the server a separate program (it can then wait for messages, which is cheap), and it can be run on a separate computer, configured for automatic start etc.
It is certainly possible to place that functionality in the Irr mainloop too, or in a separate thread in the same program.
User input can be handled by handling Irrlicht events.
Finally, a bit of a warning: if you want high responsiveness for everyone involved, make sure there is some regularly scheduled waiting involved in the client, so it does not take away too many cycles from the server - if it's running on the same computer. (If you have Hyperthreading or a multiprocessor system you won't have to worry about this very much)
Sorry if you don't get all this, but if you don't understand what I'm talking about, you're for now probably aiming too high with this project.
Think about how the end-user would use your program:
he/she starts up some user-interface (either GUI or Irr) and clicks some buttons. Then uses the user-interface some more to actually communicate with other users. Then maybe disconnects and opens another connection. Etc. Etc.
It's all event-driven, and both GUIs and Irrlicht have good event-mechanisms.
So... what I'd do is just make an Irrlicht client, calling whatever communications functions you have when text needs to be sent to the server side.
Poll (don't wait) the receiving comms functions from the Irr mainloop.
Personally I'd make the server a separate program (it can then wait for messages, which is cheap), and it can be run on a separate computer, configured for automatic start etc.
It is certainly possible to place that functionality in the Irr mainloop too, or in a separate thread in the same program.
User input can be handled by handling Irrlicht events.
Finally, a bit of a warning: if you want high responsiveness for everyone involved, make sure there is some regularly scheduled waiting involved in the client, so it does not take away too many cycles from the server - if it's running on the same computer. (If you have Hyperthreading or a multiprocessor system you won't have to worry about this very much)
Sorry if you don't get all this, but if you don't understand what I'm talking about, you're for now probably aiming too high with this project.
LOL I must not have made myself clear enoph is all..
I have a working chat client all ready to go.. Its made with microsoft visual studio 6 as well as my irrlicht project..
Both my irrlicht project and the chat client work just fine..
I will work on sending and recieving updated data for irrlicht side after I get these two apps merged together..
This is the main problem im having at this time is putting two applications together...
I took my irricht project and put it all into a header file and included the header in my chat client project.. Now the part im having problems with is how do I call the entire irrlicht code at one time..
So I can execute the irrlicht project from my chat client..
Ive got a button ready to go and all... Just not sure how id go about calling the entire header file and making the 3d window of irricht start and display what ive created for the irrlicht engine...
Like I said both applications work just great...
I just need to figure out how to incorporate my irrlicht code into one funtion so it can be called and be displayed from the chat client application...
Thanks for you help so far..
I have a working chat client all ready to go.. Its made with microsoft visual studio 6 as well as my irrlicht project..
Both my irrlicht project and the chat client work just fine..
I will work on sending and recieving updated data for irrlicht side after I get these two apps merged together..
This is the main problem im having at this time is putting two applications together...
I took my irricht project and put it all into a header file and included the header in my chat client project.. Now the part im having problems with is how do I call the entire irrlicht code at one time..
So I can execute the irrlicht project from my chat client..
Ive got a button ready to go and all... Just not sure how id go about calling the entire header file and making the 3d window of irricht start and display what ive created for the irrlicht engine...
Like I said both applications work just great...
I just need to figure out how to incorporate my irrlicht code into one funtion so it can be called and be displayed from the chat client application...
Thanks for you help so far..
Well then I must not have made myself clear: my point is, don't call an irrlicht main loop from your chat client, put you chat functionality from your irrlicht mainloop.
Or, an alternative, if all you want to do is use the chat client, and optionally call your irrlicht game from it:
use system() to call a standalone irrlicht program.
e.g.:
Presuming you name your game executable "game.exe" (or just "game" in Linux)
in your irrlicht code:
main(int argc, char **argv)
{
int serverport;
if(argc<3) {
printf("usage: game <servername> <portnumber>\n", argv[0]);
exit(1);
}
// here you know the servername and port
port=atof(argv[2]);
// servername is in argv[1]
// open connection to server, then start irrlicht main loop
In your chat client:
char commandline[2048]; // something guaranteed to be big enough - you may want to allocate dynamically
if(...) { // player wants to connect to game
sprintf(commandline,"game %s %d",servername,serverportnumber);
system(commandline); // note that system waits until game exits
}
Note that you probably don't want to connect your game client to the chat server port. That would make your chat server complex.
Or, an alternative, if all you want to do is use the chat client, and optionally call your irrlicht game from it:
use system() to call a standalone irrlicht program.
e.g.:
Presuming you name your game executable "game.exe" (or just "game" in Linux)
in your irrlicht code:
main(int argc, char **argv)
{
int serverport;
if(argc<3) {
printf("usage: game <servername> <portnumber>\n", argv[0]);
exit(1);
}
// here you know the servername and port
port=atof(argv[2]);
// servername is in argv[1]
// open connection to server, then start irrlicht main loop
In your chat client:
char commandline[2048]; // something guaranteed to be big enough - you may want to allocate dynamically
if(...) { // player wants to connect to game
sprintf(commandline,"game %s %d",servername,serverportnumber);
system(commandline); // note that system waits until game exits
}
Note that you probably don't want to connect your game client to the chat server port. That would make your chat server complex.