New wiki article: Basic Ogre Framework

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

First of all: Thanks for your comments!

However, I'll leave the includes as they are. Everone should be able to change them to their needs. I have these paths added to my IDE and I'd like to stick with it.

Concerning the messed up FPS values: You're absolutely right! I also had this problem in almost every of my Ogre applications, but never tried to solve it. So, thanks a lot for showing me the trick with resetStatistics()! I added it to the code and also uploaded an new version. Thanks a lot!
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Vaarp
Gnoblar
Posts: 8
Joined: Thu Apr 23, 2009 3:15 pm

Re: New wiki article: BasicOgreFramework

Post by Vaarp »

- EDIT -

NEVERMIND! MY FAULT! I used setFarClipDistance(1000) for the camera and didn't position the sky near me, so obviously I couldn't see a damn!

[s]Hi,

I'm having a little trouble with this Ogre Framework, I can't see the SpaceSkyBox, my environment background is just plain light brown.

I've tried to set an SkyDome but same problem, seems like the framework is not loading the texture "Examples/SpaceSkyBox" for the skyBox, but the Ogre head looks textured fine.

Any idea why is this happening?

Thanks in advance![/s]
User avatar
DerShodan
Gnoblar
Posts: 12
Joined: Tue Jan 20, 2009 12:12 pm

Re: New wiki article: BasicOgreFramework

Post by DerShodan »

Hey!

I downloaded this "BasicOgreFramework" from the Wiki Article, and it compiles without Errors. Hoever there are no Rendering Systems available in the Ogre Dialog. Any idea what I did wrong?

added Header:
include
include/OIS

added librarys:
/lib

Thanks in advance!
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

The available render systems are listed in the file ogre.cfg that has to be in the same folder as the exe you are running. If you now run it from inside your IDE (that's what you do, right?) then it doesn't work. You have to tell your IDE to use the directory as its working directory where the ogre.cfg lies.

In VisualStudio: Rightclick on your project -> properties -> debugging -> working directory
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
DerShodan
Gnoblar
Posts: 12
Joined: Tue Jan 20, 2009 12:12 pm

Re: New wiki article: BasicOgreFramework

Post by DerShodan »

Thanks a'mill!

Might be the wrong place here, but may I consider to add a little explanation about how to Setup Visual Studio to work with Ogre properly? The Article on CodeBlocks + MinGW includes a Step-by-Step explanation, but VC9 shows basically no details.

Anyway I am good to go now! :)
wraitii
Gnoblar
Posts: 20
Joined: Thu Mar 27, 2008 7:12 pm

Re: New wiki article: BasicOgreFramework

Post by wraitii »

Thanks for posting this, really useful to anyone !

I am currently running it under Mac Os X ( not without a few problems, but merely because of my configuration and file paths ).

However, It seems that Calling OIS::InputManager::destroyInputSystem(m_pInputMgr); in the OgreFramework destructor resulted in a crash ( how silly is it to crash when quitting? :) ). Commenting it solved my problem. Is it Mac specific, am I missing something, or is there a mistake somewhere? ( edit: btw, commenting the two delete before solve the problem two, and I think it's better to comment those )

Edit : Btw, I see you still use " Sleep(1000) ". At least, consider replacing it with ( I know, that's not much of a difference :) )

Code: Select all

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
	Sleep(1000);
#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
	sleep(1000);
#endif
I don't know if there's an equivalent for Linux, howether.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Sorry, for the late answer. I've put this on my todo list, but it got a bit burried... :?

First: Thanks for the tipp with the Mac sleep. I will either change it or at least add a note in the article.

Regarding the OIS crash: No idea :( . Will add a note. Perhaps you could open a new thread on this (I searched the forum here, but couldn't find something about it here). Having a look at the OIS forum could also be worth it.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
ixlilton
Gnoblar
Posts: 1
Joined: Thu Jul 02, 2009 2:58 am

Re: New wiki article: BasicOgreFramework

Post by ixlilton »

Just a quick update on the Basic Framework along with the latest version of Ogre. I am assuming this is valid for all platforms since I develop on a Mac.

In OgreFramework.cpp the line

Code: Select all

template<> OgreFramework* Ogre::Singleton<class OgreFramework>::ms_Singleton = 0;
should be updated to

Code: Select all

template<> OgreFramework* Ogre::Singleton<OgreFramework>::ms_Singleton = 0;
A very subtle/minor difference however if you check out the details of Ogre::Singleton it has this form of the declaration:http://www.ogre3d.org/wiki/index.php/Singleton


The above is the only big change ignoring the "issues" with Mac development and where it places its resource bundles. But this is a simple exercise that can be achieved referring to ExampleApplication.h and integration.

D
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

So, to clarify that: My version doesn't run on Mac, right? After changing this line it does?

PS: Sorry that it took me that long. This thing got burried on my ToDo list :( .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Any comments from Mac Users?
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
ptrb
Gnoblar
Posts: 5
Joined: Sat Jun 07, 2008 4:43 pm

Re: New wiki article: BasicOgreFramework

Post by ptrb »

if the application fails because the resource pack files aren't available ... the program will terminate with a segmentation fault, and not report the actual problem...

problem lies with OIS code in ~OgreFramework()...

Code: Select all

 OgreFramework::~OgreFramework()
{
    delete m_pKeyboard;
    delete m_pMouse;
    OIS::InputManager::destroyInputSystem(m_pInputMgr);

    delete m_pRoot;
}
 
to fix i changed it to:

Code: Select all

OgreFramework::~OgreFramework()
{
    if(m_pInputMgr)
	{
        m_pInputMgr->destroyInputObject(m_pKeyboard);
        m_pInputMgr->destroyInputObject(m_pMouse);
        OIS::InputManager::destroyInputSystem(m_pInputMgr);
	}
	delete m_pRoot;
}




Linux specific notes:

under main()... i had problems with the following:

Code: Select all

	catch(std::exception& e)
        {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA(NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        fprintf(stderr, "An exception has occurred: %s\n", e.getFullDescription().c_str());
#endif
getFullDescription() is an method of OGRE::exception ... if we must use std::exception then we should use e.what() right?

Code: Select all

#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA(NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        std::cerr << "An exception has occurred: " << e.what()  << std::endl;
#endif

like mac uses, i also had trouble with an uppercase "S" in sleep... the following should work for both mac and Linux

Code: Select all

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
   Sleep(1000);
#else
   sleep(1000);
#endif
PC_Nerd
Halfling
Posts: 55
Joined: Thu May 08, 2008 9:23 am
Location: Sydney

Re: New wiki article: BasicOgreFramework

Post by PC_Nerd »

Hi,

Its great to be able to see how Ogre is meant to be used ( well... "meant" being a very subjective word), so firstly I'd like to say thanks :).

I'm currently haviing issues running the framework around line 73 of the Demo App ( which is the main rendering loop)

OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame();

seems to be the line which it fails on but there is not log message noting the error. The only changes I've made to the code is to add debugging output to the log file to identify what line it occured on. eg:

OgreFramework::getSingletonPtr()->m_pLog->logMessage("Render a frame");

I'm running it with OpenGL - and I cant test Direct X right this second because I haven't got the SDK installed properly ( I've got _33 instead of the _30 as the DirectX9 renderer requires).

Any ideas?

Thanks,
PC_Nerd
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

@ptrb:
ptrb wrote: to fix i changed it to:

Code: Select all

OgreFramework::~OgreFramework()
{
if(m_pInputMgr)
{
m_pInputMgr->destroyInputObject(m_pKeyboard);
m_pInputMgr->destroyInputObject(m_pMouse);
OIS::InputManager::destroyInputSystem(m_pInputMgr);
}
delete m_pRoot;
}
You are right on this one. Will change it.
ptrb wrote: under main()... i had problems with the following:

Code: Select all

   catch(std::exception& e)
        {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA(NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        fprintf(stderr, "An exception has occurred: %s\n", e.getFullDescription().c_str());
#endif
Will change that too (somehow I only changed it in the if-branch :? ).
ptrb wrote:like mac uses, i also had trouble with an uppercase "S" in sleep... the following should work for both mac and Linux

Code: Select all

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
   Sleep(1000);
#else
   sleep(1000);
#endif
That is already covered in the notes at the bottom.

@PC_Nerd:
PC_Nerd wrote:Its great to be able to see how Ogre is meant to be used ( well... "meant" being a very subjective word), so firstly I'd like to say thanks.
You're welcome :) .

Which Ogre version are you using and on which platform (Win, Mac, Linux)?
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
PC_Nerd
Halfling
Posts: 55
Joined: Thu May 08, 2008 9:23 am
Location: Sydney

Re: New wiki article: BasicOgreFramework

Post by PC_Nerd »

Hi,

Thanks for the reply- I'm running windows XP Proff (SP2 from memory), with codeblocks 8.02 ( not nightly build). I also have installed the DirectX April 2007 SDK, however the testing is currently only using OpenGL.

The code I'm building from is the 1.6 branch in SVN, last updated.... last week ? Well its recent. OgreMain and all the other plugins I've copied across to my workspace compile fine without any compile errors.

Thanks :)

*Edit: forgot the compiler. I'm running MinGW TDM version ( which contains the 4.x (I think) series of GNU compilers, instead of the 3.4 in the official MinGW release).. I've also got MSYS installed if needed.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

I assume that the Ogre demos and other Ogre apps run properly, right?

If you take out that renderOneFrame() it works?

OT: I'd go for VisualStudio....
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
PC_Nerd
Halfling
Posts: 55
Joined: Thu May 08, 2008 9:23 am
Location: Sydney

Re: New wiki article: BasicOgreFramework

Post by PC_Nerd »

Hi,

Yup - it compiles and runs fine ( and in its mainloop) without the rennderOneFrame(). From what I googled, windows platform needs the MessagePump() in there - and I've checked that preproccessor is definately running ( so I know the compile time flags are setting it to a windows compile).

The samples built perfectly on the standard ogre workspace. What I've done is the structure/setup of my current build:

/ogre/ {all the ogre source code is checked out into here}
/Dependencies {the precompiled libraries and the headers such as OIS and OpenGL etc }
/Media {all the .scene, .material etc }
/client {where this current project is, with its .cbp}
/build {the output of all the proejct files goes here}

Then the CodeBlocks workspace then includes the Ogre Projects as well as my own project file, and I've modified the output directories so that the binary's are placed in the /build directory. At the moment, debug and release is all into the same directory, but they are specifically linking to _d version ( which are in there), so I know its not a debug linking to the release build.

For the record, I particularly dont like VisualStudio, I enjyo working with codeblocks, and I will be compileing this app ( eventually) on Mac and Linux.... so codeblocks provides me with a nice cross platform alternative ( given that - I'll admit there might be better solutions for me like the same system Ogre3D uses to actually neverate these project files, but now isnt the time to debate it).

Just a thought - is there any compiler or linker flag that I need to set to be able to render stuff in ogre that I may have missed? Something in the samples that I haven't included ?

Thanks :)
PC_Nerd
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Okay, you could try the note No. 2 from the BasicOgreFramework.

Otherwise: What is the error message popping up? Did you have a look at the Ogre log? Anything suspicious? Did you check that m_pRoot isn't null here (for what reason ever):

Code: Select all

OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame();
PC_Nerd wrote: Just a thought - is there any compiler or linker flag that I need to set to be able to render stuff in ogre that I may have missed? Something in the samples that I haven't included ?
Can't say as I only use VisualStudio and therefore have no clue how and what to set up in CodeBlocks.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
PC_Nerd
Halfling
Posts: 55
Joined: Thu May 08, 2008 9:23 am
Location: Sydney

Re: New wiki article: BasicOgreFramework

Post by PC_Nerd »

Ok, root is as it turns out - NULL.

However wouldnt previous functions throw an error if it was NULL ?

Thanks,
PC_Nerd


Edit:

I've noticed a (possible?) issue with calling the initOgre() method on the OgreFramework:
the function is defined as :
void OgreFramework::initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
but, we call it as:
OgreFramework::getSingletonPtr()->initOgre("DemoApp v1.0", this, 0);
How does "this" turn into the key listener, ... and 0 ? (I dont really know much/anything about OIS so that may simply be something there).
Thanks
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

PC_Nerd wrote:Ok, root is as it turns out - NULL.
Can you check when m_pRoot turns to NULL or whether it never gets initialized? Could be that in initOgre() everything is still fine for you, but that in the main loop, the passing of the m_pRoot variable goes wrong.

Code: Select all

OgreFramework::getSingletonPtr()->initOgre("DemoApp v1.0", this, 0);
This line works, because "this" is the self-reference to the class DemoApp which inherits OIS::KeyListener, so is a key listener which is needed as a parameter for the function.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
PC_Nerd
Halfling
Posts: 55
Joined: Thu May 08, 2008 9:23 am
Location: Sydney

Re: New wiki article: BasicOgreFramework

Post by PC_Nerd »

Ok, I'll have a check back through wherever m_pRoot is passed,called or references to make sure it get initialised etc.

And I shoudl have noticed that - I've been working through a lot of Pascal, PHP and JavaScript lately so I completely missed that in the declaration of the Class :)

Thanks,
PC_Nerd
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: New wiki article: BasicOgreFramework

Post by boyamer »

any news about advanced ogre framework?
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Yes, I'm back on it. Just worked a bit on it yesterday, but currently (so for the next five days) my project thesis has the higher priority, as I'm finally reaching the deadline...

PS: Wrong thread, isn't it ;) ?
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: New wiki article: BasicOgreFramework

Post by boyamer »

Only because i can't find the Advanced Framework thread.
Why don't you create a svn and just commit all changes there? :)
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Okay, the AdvancedOgreFramework-Thread is here.

Setting up an SVN would be a bit overkill, don't you think? But as my project thesis is now written, I will have time while the weekend (in fact as well this evening, once I'm home from work) to go on with it and eventually even release a first version (if not even a finished one). Stay tuned :wink: .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
harkathmaker
Kobold
Posts: 36
Joined: Tue Aug 11, 2009 12:27 am

Re: New wiki article: BasicOgreFramework

Post by harkathmaker »

ixlilton wrote:Just a quick update on the Basic Framework along with the latest version of Ogre. I am assuming this is valid for all platforms since I develop on a Mac.

In OgreFramework.cpp the line

Code: Select all

template<> OgreFramework* Ogre::Singleton<class OgreFramework>::ms_Singleton = 0;
should be updated to

Code: Select all

template<> OgreFramework* Ogre::Singleton<OgreFramework>::ms_Singleton = 0;
A very subtle/minor difference however if you check out the details of Ogre::Singleton it has this form of the declaration:http://www.ogre3d.org/wiki/index.php/Singleton


The above is the only big change ignoring the "issues" with Mac development and where it places its resource bundles. But this is a simple exercise that can be achieved referring to ExampleApplication.h and integration.

D
I just compiled the framework in Xcode, and needed to do this change, so it should probably be updated :mrgreen: