How to setup the Ogre window?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
oldfox
Halfling
Posts: 57
Joined: Mon Apr 18, 2005 5:46 pm

How to setup the Ogre window?

Post by oldfox »

Hi, I'm porting a project from basic glut/openGL to Ogre, and I have a little problem : I don't find how to setup the window, so it can be rendered even if it isn't at top, and so I can still see the mouse and select other windows.

I'm currently using the exempleApplication class, and I have to do a "alt tab" to see the mouse pointer, and then the render stops until I put Ogre on top again.


Don't know if it is a Ogre problem or a windows API one...



Thanks!
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

This is because OGRE is running the rendering loop for you, and the default behaviour is to only render when the window is in focus, not show the OS mouse, and other such game-like behaviour.

If you want to have different behaviour, it's probably because you're writing a tool of some sort, and in this case you should create the window yourself and pass the handle to OGRE in the externalWindowHandle parameter when you create a window. You should then run the window loop yourself, however you like - telling the window when to update (paint events) etc.
oldfox
Halfling
Posts: 57
Joined: Mon Apr 18, 2005 5:46 pm

Post by oldfox »

Can I find a little tutorial to do that as I'm pretty unfamiliar with all the windows API stuff ? : glut did it for me :lol:
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

Post by Yokom »

sinbad wrote:This is because OGRE is running the rendering loop for you, and the default behaviour is to only render when the window is in focus, not show the OS mouse, and other such game-like behaviour.

If you want to have different behaviour, it's probably because you're writing a tool of some sort, and in this case you should create the window yourself and pass the handle to OGRE in the externalWindowHandle parameter when you create a window. You should then run the window loop yourself, however you like - telling the window when to update (paint events) etc.
This sounds good in theory but here i set I have my winapi app running and im starting to but child window contorls in and want to render ogre in a child window. This seems easy at first till you get to the point where you have to init ogre. I dont want the dialog box that gets the prams I need to get ogre up to the renderone frame state.

Ok can you just jot down a few lines of clues on the basic steps to get ogre rendering.

I have this so far.

new root
load resources file parse it
?qestion on what to do for configure
choose scenemanager
create/position camera
load and position somthing to view
renderoneframe

I plan on setting up a timer under winapi to fire the renderloop so the gui of the tool doesnt get bogged down from the renderloop, or I might make the render loop run from the winproc function for the window ogre is in.

The question is how do I pass the handle(hwnd) for the window to ogre?
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

Post by Yokom »

Code: Select all

	mRoot = new Root();
	ConfigFile cf;
	cf.load("resources.cfg");
	ConfigFile::SectionIterator seci = cf.getSectionIterator();
	String sec,type,arch;
	while(seci.hasMoreElements())
	{
		sec = seci.peekNextKey();
		ConfigFile::SettingsMultiMap *settings = seci.getNext();
		ConfigFile::SettingsMultiMap::iterator i;
		for(i = settings->begin();i!=settings->end();i++)
		{
			type = i->first;
			arch = i->second;
			ResourceGroupManager::getSingleton().addResourceLocation(
				arch,type,sec);
		}
	}
	
    RenderSystemList* lstRend;
    RenderSystemList::iterator pRend;
	// in resource.cfg we only load one rendersystem plugin
	// so we dont need to sort the list of system in this app
	lstRend = mRoot->getSingleton().getAvailableRenderers();
	pRend = lstRend->begin();
	mRoot->getSingleton().setRenderSystem(pRend[0]);
	
	mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
	mWindow = mRoot->initialise(true,"OgreEdmWindow");
	mCamera = mSceneMgr->createCamera("nToolCam");
    mCamera->setPosition(Vector3(500,200,0));
    mCamera->lookAt(Vector3(0,100,0));
    mCamera->setNearClipDistance(5);
	mCamera->setFarClipDistance(20000);

This is very ugly atm and im just working though the absolute grit to get ogre started. This opens a fullscreen window ontop of my gui window so im getting closer. I really dont know where to set the external window handle I have tracked down in rendersystem_direct3d9 in the create function where it parses out the hadle but i havnt caught where you set the params and when you set it yet. Ive been working for around 18 hours straight on a few things so I hope all this makes sense.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

@Yokom: This looks okay - but I think you could (and should) save some work and get hold of ogreaddons from CVS.
There you should browse the code for meshviewer - it does exactly what you are trying to do. You might pick up some tricks. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

Post by Yokom »

jacmoe wrote:@Yokom: This looks okay - but I think you could (and should) save some work and get hold of ogreaddons from CVS.
There you should browse the code for meshviewer - it does exactly what you are trying to do. You might pick up some tricks. :wink:
Thats good news ill pull that up and look though it thanks, and getting some sleep helps also.
Post Reply