How the heck do you put the code in order?!
Posted: Sun Sep 13, 2009 12:41 am
Okay, one problem I have had in all these game engines is organizing my source code and getting all the engine setups into a single function/header.
Say this is my main.cpp
This is masterhead.h
And here's prototype.h
Now, please, isn't this the most newbish, unorganized code ever? I can't even compile it without the compiler making the createAcorn() function be considered an integer or something, and because it for that weird reason it won't access the function createAcorn() it says that device is undeclared and stuff like that, because the device is created in the said function.
Also, I call this project Acorn, which will explain why the function is called createAcorn() if anyone doesn't understand that, createAcorn() is the initiation function.
Also, I'm probably gonna get yelled at for using an #include at the bottom of main.cpp
My question I need help with is... How do I organize my source codes to work with the compiler I'm using (Visual C++ 2008 Express)
Say this is my main.cpp
Code: Select all
#include "masterhead.h"
int main()
{
createAcorn();
device->drop();
return 0;
}
#include "functionmain.h"
Code: Select all
#pragma once
#include <irrlicht.h>
// irrlicht's namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
// Link the library
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
#include "prototype.h"
Code: Select all
#pragma once
// CREATE THE ENGINE AND DRIVERS
int createAcorn(void)
{
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#endif
if(!device)
return 1;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
}
/****************************************************************/
// FRAMES PER SECOND return
int returnFPS(void)
{
driver->getFPS();
}
// Current Software Running return
int returnDriver(void)
{
driver->getName();
}
Also, I call this project Acorn, which will explain why the function is called createAcorn() if anyone doesn't understand that, createAcorn() is the initiation function.
Also, I'm probably gonna get yelled at for using an #include at the bottom of main.cpp
My question I need help with is... How do I organize my source codes to work with the compiler I'm using (Visual C++ 2008 Express)