Hey all good people, I have a question.. I took some time learning C++ and now I'm starting to work with graphic engines, namely the Ogre3D.. Now reading lessons and examples is one thing, they usually work out (:)) but jumping head down into a project and trying to do something, is entirely a different thing..
I basically just want to practice by doing this..
I have one big function called startup() in class Game.. This functions contain following code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int Game::startup()
{
root = new Ogre::Root("plugins_d.cfg");
root->loadPlugin("RenderSystem_GL_d.dll");
Ogre::RenderSystem *rs = root->getRenderSystemByName("OpenGL Rendering Subsystem");
root->setRenderSystem(rs);
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
....
return 0;
}
|
root is a pointer to the new instance of Ogre::Root class which takes 1 argument. root is earlier defined in Game.h with following:
Ogre::Root *root;
Now what I want it to take that block of code (starting with root->loadPlugins, and endind with setting a resolution) to its own function. So the final result should be:
1 2 3 4 5 6 7 8 9
|
int Game::startup()
{
root = new Ogre::Root("plugins_d.cfg");
setupRenderer("RenderSystem_GL_d.dll");
....
return 0;
}
|
This has to be possible, right? I've been playing around but didn't managed to do it.. First thinking is, okay I need to pass pointer root by reference, and string "RenderSystem_GL_d.dll" by value.. So this is what I got so far:
1 2 3 4 5 6 7 8
|
void Game::setupRenderer(Ogre::Root &root, Ogre::String renderer)
{
root->loadPlugin(renderer);
Ogre::RenderSystem *rs = root->getRenderSystemByName("OpenGL Rendering Subsystem");
root->setRenderSystem(rs);
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
}
|
Then I get error "did you intend to use '.' instead of -> ?" That's another question that's been bugged me lately, when does one use -> and when does one use . instead? So that's where I am, hopefully someone can help me out!
Best regards,
-eXtremeCpp