Classes?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Classes?

Post by Robomaniac »

Sorry this is a noob question but, I am trying to have one main function (like in the tech demo), but i'm confused on how to do it. I want to have a bunch of c files all with functions and then the main function that just draws everything using the functions. I know you could use classes, but i'm very confused with them. Could i just possibly do #include <source.cpp>? Thanks of the help

~~ The Robomaniac
Ironfoot
Posts: 15
Joined: Fri Aug 22, 2003 12:30 pm
Location: Germany
Contact:

Post by Ironfoot »

you could write a header file with all the functions declared as extern e.g.

Code: Select all

extern void drawHUD( void );
Great Engine, Niko, keep up the good work!
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Then would i just write the function in the header?
Ironfoot
Posts: 15
Joined: Fri Aug 22, 2003 12:30 pm
Location: Germany
Contact:

Post by Ironfoot »

That will work, but only if you included the .cpp files into your Project

And you only declare(or is it define??) the function in the header...
Great Engine, Niko, keep up the good work!
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

So in a header i say

extern void drawWindow(void);

etc.

Then i an cpp file i would write drawWindow(). Then do i link it or just have it in the project.

Thanks

~~THE Robomaniac
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Got it sort of, except i don't want to have to declare like driver and smgr and device in all the cpp files. right now, i have one header that has the declarations (ex. extern void loadGUIGraphics) and then cpp files with the functions (ex. in GUIGraphFunctions.cpp... the function loadGUIGraphics). I want to have a function for every process i have. So far i have this list :

drawWindow();
loadGUIGraphics();
loadGUIModel();
renderGUI();
checkGUI();
loadMap();
loadModels();
drawScene();

all of those are in main. I compile and i get errors like

`device' undeclared (first use this function)
and
`driver' undeclared (first use this function)

Do i have to put all of my functions into one file. Say have a file like GUI.cpp and then put drawWindow, loadGUIGraphics, loadGUIModel, etc, etc. into that file or can i have different c files. Thanks for any help

~~ The Robomaniac
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

Your driver and device will have to be declared globally so that all functions will see them, thats why it says they are undeclared. Any other varibles of any kind that are used in all functions will have to be global too.
Post Reply