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.
Post Reply
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

I already updated it some time ago, both in the wiki article and in the downloadable version?!? Or am I missing something?
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 »

In the downloaded version it needed to be corrected (at least at the time I downloaded it, a couple weeks ago). The wiki is fine.

Also, Xcode doesn't seem to like the catch(std::exception& e) going with the call to getFullDescription() in main(), so I replaced it with Ogre::Exception.


Update:
I just got it completely working on my Mac, and there were some things that I had to "splice together" from ExampleApplication. I'll post again when I find all the changes.
harkathmaker
Kobold
Posts: 36
Joined: Tue Aug 11, 2009 12:27 am

Re: New wiki article: BasicOgreFramework

Post by harkathmaker »

Ok, here's all the changes necessary to get it to run in Xcode on Mac.

In main.cpp: In OgreFramework.h:
  • Add

    Code: Select all

    #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    #include <CoreFoundation/CoreFoundation.h>
    
    // This function will locate the path to our application on OS X,
    // unlike windows you can not rely on the curent working directory
    // for locating your configuration files and resources.
    std::string macBundlePath();
    #endif
  • In the framework class add

    Code: Select all

    protected:
    	//added for Mac compatibility
    	Ogre::String mResourcePath;
In OgreFramework.cpp:
  • Add

    Code: Select all

    #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    std::string macBundlePath()
    {
        char path[1024];
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        assert(mainBundle);
    
        CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
        assert(mainBundleURL);
    
        CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
        assert(cfStringRef);
    
        CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
    
        CFRelease(mainBundleURL);
        CFRelease(cfStringRef);
    
        return std::string(path);
    }
    #endif
  • In the constructor add:

    Code: Select all

    #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    		mResourcePath = macBundlePath() + "/Contents/Resources/";
    	#else
    		mResourcePath = "";
    	#endif
  • In initOgre(), replace:

    Code: Select all

    m_pRoot = new Ogre::Root();
    with:

    Code: Select all

    String pluginsPath;
    	// only use plugins.cfg if not static
    	#ifndef OGRE_STATIC_LIB
    		pluginsPath = mResourcePath + "plugins.cfg";
    	#endif
    		
    	m_pRoot = new Ogre::Root(pluginsPath);
    Replace:

    Code: Select all

    cf.load("resources.cfg");
    with:

    Code: Select all

    cf.load(mResourcePath+"resources.cfg");
    Replace:

    Code: Select all

    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
    with:

    Code: Select all

    #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
                    // OS X does not set the working directory relative to the app.
                    // In order to make things portable on OS X we need to provide
                    // the loading with its own bundle path location
                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                        String(macBundlePath() + "/" + archName), typeName, secName);
    #else
                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                        archName, typeName, secName);
    #endif
Some other notes... m_pRoot->showConfigDialog() causes it to crash, so I replaced it with my own configuration system.
OIS::InputManager::destroyInputSystem(m_pInputMgr) makes it crash, although the game seems to be fine if it's commented out (program is shutting down anyway...).
Xcode wants the Ogre:: scope identifier in front of all uses of Vector3.

Hope this helps. :)
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Wow :shock: ! That's a lot of differences... Thanks for listing them. Now I've got to find a good solution to include them. I'm thinking about making an additional page to my article with all these MAC stuff. I don't rellay want to blow up the whole code base by also adding the OS dependent stuff. But still have to decide on this one...

Really appreciate the detailed help!!!
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,

I'm back from over on page 3 of this thread- I haven't been able to play around with Ogre for a few months.

I've got it crashing inside the bool Root::_updateAllRenderTargets(void) function in Ogre::Root - specifically :

bool Root::_updateAllRenderTargets(void)
{
// update all targets but don't swap buffers
mActiveRenderer->_updateAllRenderTargets(false); <---- it fails on that line.

I didnt trace it any further... as I had to manually get it to write log entries at what point it was in the script (the debugger wont attach to the debug build because it cant/wont find the config files that it finds when its run as an executable. I suspect this is somethign to do with it copying the exe to another location within the compiler environment before executing - meaning its no longer in the correct directory.

Anyway - this all comes when I run renderOneFrame from the current framework. This is my code surounding the error:

Code: Select all

OgreFramework::getSingletonPtr()->m_pLog->logMessage("Render a frame");
if (OgreFramework::getSingletonPtr()->m_pRoot == NULL) {
                OgreFramework::getSingletonPtr()->m_pLog->logMessage("Root is null");
} else {
                bool rendered;
                OgreFramework::getSingletonPtr()->m_pLog->logMessage("Just before renderOneFrame()");
                rendered = OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame();
                if(rendered) {
                    OgreFramework::getSingletonPtr()->m_pLog->logMessage("renderOneFrame() returned True;");
                } else {
                    OgreFramework::getSingletonPtr()->m_pLog->logMessage("renderOneFrame() returned False;");
                }
}
            
As you can seeo - Root is not null like you sugested I check - so I'm lost as to the crash. All I get is a "encountered a problem and had to close" (winxp proff). This comes after I select setup ( OpenGL in this case).

any suggestions ?

thanks,
PC_Nerd
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

Did you alter the code apart from the log writes?

Am I right, that you get the log entries "Render a frame" and "Just before renderOneFrame()" and that's about it?

Concerning the not running debug version: Set a working directory so that the IDE can find the needed .CFG files of Ogre.
Project Settings > 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...
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,
That is correct about the log file output. however - I've also gone into the Ogre::Root cpp file and added the log writing in there - which is where I traced it through to the _updateAllRenderTargets(void) function ( I'm not entirely sure how I ended up getting there - but it was through the RenderOneFrame() function. Specifically - it was at the point in the Ogre::Root::_updateallRenderTargets() above ( passing the non void value into a void function)... It just seems weird to me that its been programmed that way to call a function that isnt defined (granted, this is an older source download from svn... probably a few months at least). Is this a bug that is known( and fixed) in a later ogre?.... I'd prefer to not have to update the working copy - as I've integrated the project files for OgreMain and the Rendering plugins etc - into a workspace for myself, so that all the output directories are customise to my build environment.... but if I must..

Also - I've added the build/working directory to project -> properties -> debugger (tab) -> Search directories, which was the most similar location to what you described... I'm running 8.02 and not a nightly build - I'm yet to get round to update codeblocks.

Thanks :)
PC_Nerd
nikolajsheller
Gnoblar
Posts: 2
Joined: Thu Sep 17, 2009 7:39 pm

Re: New wiki article: BasicOgreFramework

Post by nikolajsheller »

Hi, and thank you for a nice framework!

I have used this framework under linux and I have a small suggestion to improve linux support:

In "DemoApp.cpp" Sleep() is not recognized and can be replaced by usleep(), i.e.:

Code: Select all

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    Sleep(1000);
#else
    usleep(1000);
#endif
Thank you for publishing your code!
-Nikolaj
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: BasicOgreFramework

Post by spacegaier »

@PC_Nerd: Don't know if that was a bug, but it does not occure here. An update an a more recent version of Ogre (still1.6.X) would not hurt, I guess.
But I don't really think that this is an Ogre error, but something caused by your code.
I'm yet to get round to update codeblocks.
I'd switch to VisualStudio, if that's possible with your OS...

@nikolajsheller: I already added something like this as the third note to the framework due to a suggestion in this thread, although it is a bit different than your proposal. Do both versions work?
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: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

UPDATE: Wiki page updated with the fixes / hints from this thread (as well as from those applying from the AdvancedOgreFramework thread). New out-of-the-box-running vesion uploaded.

I also linked the article to the great and huge post of harkathmaker with all the needed changes for XCode/Mac.
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...
nQue
Gnoblar
Posts: 1
Joined: Fri Jul 31, 2009 1:08 pm

Re: New wiki article: Basic Ogre Framework

Post by nQue »

Hello! I've started using this framework a few days ago, very nice work and thanks!

However, my biggest grief was debugging with GDB under Linux since the mouse cursor is confined to the Ogre window, and the application is also hogging the keyboard input, so there's no way to get out of that mess without killing GDB manually (you have to ctrl+alt+Fx and log into another console to kill it). This effectively prevents any debugging from being done. Even more annoying: doing this shuts down the keyboard autorepeat! :-(

Here is how I fixed my framework to allow me to do basic debugging (copied straight from the OIS tutorial in the wiki);

Code: Select all

	// in order to allow the mouse to leave the ogre window when debugging
	// insert the following lines right before calling m_pInputMgr = OIS::InputManager::createInputSystem( paramList );
	#if defined OIS_WIN32_PLATFORM
		paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
		paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
		paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
		paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
	#elif defined OIS_LINUX_PLATFORM
		paramList.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
		paramList.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
		paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
		paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
	#endif
Warning! This might break absolute mouseposition under win32, but maybe you can correct the error by listening to the windowMoved event in a Ogre::WindowEventListener and substract the left-top coordinates of the window from the "absolute" mouseposition returned by OIS.

You might want to add this, or some variant of it? Or at least put it in the "how to use basic framework" tutorial?
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

Major update 2010/01/11: I updated the Basic Ogre Framework to work with Ogre 1.7 [Chtugha]. For details, see the first post.
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: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

Minor update: See first post (wiki article and downloadable version updated).
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...
sizeak
Gnoblar
Posts: 9
Joined: Sun Jan 17, 2010 3:33 am
Location: UK

Re: New wiki article: Basic Ogre Framework

Post by sizeak »

Would you be interested in a version (the one i got off the wiki demo) I've tidied up and commented for myself? There is no added functionality, I've just added and changed comments, fixed the thing where parts of it were dependent on the using namespace Ogre command and parts were prefixed Ogre:: so now its all Ogre::, split the framework init off into smaller helper functions to make it easier to read and easier to extend. That kind of pedantic tidy stuff.
shame on us
doomed from the start
may god have mercy
on our dirty little hearts
shame on us
for all we've done
and all we ever were
just zeros and ones
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

Well, I did not really comment it, since there is nothing fancy going on, only basic Ogre commands which can be looked up in the API if necessary. More comments would just blow up the code here.

Concerning the namespace thing: Yes, you are right on this one. I probably will go through it again and alter that in one of the next evenings.
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...
OGRE1
Kobold
Posts: 27
Joined: Sun Jan 10, 2010 5:54 pm

Re: New wiki article: Basic Ogre Framework

Post by OGRE1 »

Hey spacegaier

I got basic ogre framework application working, but I had to do the following.

In OgreFrameWork.cpp I had to uncomment the following to avoid segment error and crash of app:
m_pDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
m_pDebugOverlay->show();
UpdateStats()

plus
//#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_LINUX
Ogre::WindowEventUtilities::messagePump();

I will try to find fix for not uncommenting debugoverlay.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

I guess that Ogre couldn't find the needed resources. Have a look at the Ogre.log.
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
Svenstaro
Greenskin
Posts: 115
Joined: Fri Dec 15, 2006 1:30 pm
Location: Germany
x 3
Contact:

Re: New wiki article: Basic Ogre Framework

Post by Svenstaro »

What is the license on this?
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: New wiki article: Basic Ogre Framework

Post by spacegaier »

You can do with it, whatever you want to. Don't know which license that would be...
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
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: New wiki article: Basic Ogre Framework

Post by jacmoe »

That would be public domain:
Wiki wrote:Source code is public domain
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
mirlix
Goblin
Posts: 225
Joined: Mon May 01, 2006 12:03 am
Location: Germany
x 5

Re: New wiki article: Basic Ogre Framework

Post by mirlix »

I think it woudl be greate if the basic application could be in the SDK like ExampleApplication, so Tutorials can assume thats its there and use it without describing how to get it.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: New wiki article: Basic Ogre Framework

Post by jacmoe »

What tutorials? :)

If you are talking about the rewrite, we are already working on converting them to use the Ogre AppWizard 'framework'.
Simply because a kind person came forward and offered to do this, and he liked the idea of using the appwizard, especially since it means that people will have an easy time setting it all up.
That doesn't mean that the BOF is bad, it's just an alternative for when people have done the tutorials.

Look at the changes @ the experimental wiki:
http://test.ogitor.org/tiki/

Setting up an application uses it, and it's used for the tutorials.
The first basic tutorial is already rewritten using it.

I view the BOF as the next logical step from the tutorial framework.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Svenstaro
Greenskin
Posts: 115
Joined: Fri Dec 15, 2006 1:30 pm
Location: Germany
x 3
Contact:

Re: New wiki article: Basic Ogre Framework

Post by Svenstaro »

I get a segmentation fault on calling m_pDebugOverlay->show(); so I had to comment that out. This is Arch Linux x86_64, Ogre 1.7rc1 and this framework. No other crash-related info shows up in the log or on stderr/stdout. Help appreciated :).
wom
Gnoblar
Posts: 8
Joined: Sat Feb 27, 2010 12:20 pm

Re: New wiki article: Basic Ogre Framework

Post by wom »

Hi,

On OSX I am not receiving any mouse or keyboard events. Based on debugging all those xxxx->capture() get called and main loop is running. Just no events are received. I don't even see mouse cursor there, should I?

Also seems that app is running somehow weirdly since when I alt-tab to another app and move mouse over DemoApp I see beach ball rotating. OSX guys any experience on this?

I got Ogre 1.7 from SVN and compiled and ran those samples successfully. They work.
harry_ftw
Gnoblar
Posts: 2
Joined: Tue Mar 02, 2010 11:24 am

Re: New wiki article: Basic Ogre Framework

Post by harry_ftw »

wom wrote:On OSX I am not receiving any mouse or keyboard events. Based on debugging all those xxxx->capture() get called and main loop is running. Just no events are received. I don't even see mouse cursor there, should I?
I was in a similar situation, and found that by calling Ogre::WindowEventUtilities::messagePump(), where previously it would only be called for Win32, the program runs as it probably should.

As something of a disclaimer: I only successfully compiled Ogre yesterday, currently know very little about how it all works, and discovered the messagePump solution basically by trial and error... so if any more experienced Ogre users find my proposed solution horrendous, I hope they shall correct me. D:
Post Reply