Example based on Clay's Wiki Tutorial #1

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

I'm not sure if I understand entirely. I actually don't use the ExampleApplication at all.

The code you are looking for is in the configure function of the application.cpp file. The behavior where <esc> causes the config dialog box to close is the default behavior of the config box and is not controlled by the application. I.e. it is the behavior defined by Ogre and/or the OS you are running on (i.e. MFC for windows).

If you don't want to have <esc> cancel the config dialog, you can modify these lines of code:

Code: Select all

if (mRoot->restoreConfig() || mRoot->showConfigDialog())
	{
		// If returned true, user clicked OK so initialise or valid values were loaded from a previous run
		// Here we choose to let the system create a default rendering window by passing 'true'
		mWindow = mRoot->initialise(true, "Bots");
		return true;
	}
	else
	{
		return false;
	}
The

Code: Select all

mRoot->showConfigDialog()
returns false when <esc> is pressed.

HTH

Saetrum
gabriele_scibilia
Gnoblar
Posts: 13
Joined: Tue Mar 15, 2005 4:59 pm

Post by gabriele_scibilia »

I had to explain better my hint... I really appreciated your code, thank you for releasing it.

In the code you released I found:

Code: Select all

bool MoveDemoApplication::setup()
{
	ExampleApplication::setup();
	LogManager::getSingleton().setLogDetail( LL_BOREME );

	return true;
}
This way there is no way to end the config dialog and quit the process as you never return <false> on quit/cancel, the process is still running and the application cannot end safely the execution!.

This should be the modified method, imho:

Code: Select all

bool MoveDemoApplication::setup(void)
{
	if (!ExampleApplication::setup())
		return false;

	LogManager::getSingleton().setLogDetail( LL_BOREME );

	return true;
}
Look at this (your overridden ExampleApplication::setup never returns <false>):

Code: Select all

class ExampleApplication
{
    /// Start the example
    virtual void go(void)
    {
        if (!setup())
            return;
    
        mRoot->startRendering();
    
        // clean up
        destroyScene();
    }
}
saetrum
Halfling
Posts: 60
Joined: Fri Oct 24, 2003 6:39 pm
x 1

Post by saetrum »

I see what you mean. I've actually modified the code quite a bit from what is currently available for download. It now has the ability to return false.

Thanks for catching that.
Post Reply