wxOgre? Ogre in a wxWidget frame?

Get answers to all your basic programming questions. No Ogre questions, please!
Blackbeard
Kobold
Posts: 31
Joined: Sun Mar 04, 2007 9:07 pm

wxOgre? Ogre in a wxWidget frame?

Post by Blackbeard »

Hi,
i want to port my Mogre project to Ogre 1.6 and C++.
As GUI for my tools i want to use wxWidget, but its hart to get started.
How to make Ogre render in a wxWidget Window (frame)?

Theres a tutorial telling you how to get wxWidget's and Ogre 1.2 to work.
Is that tutorial outdated or does it work for Ogre1.6 too?

In Mogre basicly all i have to do is to give the control handle to Ogre as string.
misc["externalWindowHandle"] = Handle.ToString();

How does it work with wxWidgets?
Any other examples around which could tell me how to render in a wxWidget frame?

Any help or clues of how to get started would be more then welcome :?
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: wxOgre? Ogre in a wxWidget frame?

Post by xavier »

There is nothing about Ogre that has changed the way you embed it in any window, wxWidgets included.

You don't need "wxOgre" or anything special -- you get the window handle the same way in wx as you do in Mogre, it's a method:

Code: Select all

/*****************************************************************************/

void ColladaViewerFrame::initGfx()
{
	m_pRoot = new Ogre::Root("", "");
#if defined(_DEBUG)
	m_pRoot->loadPlugin("RenderSystem_Direct3D9_D");
	m_pRoot->loadPlugin("Plugin_OctreeSceneManager_D");
	m_pRoot->loadPlugin("Plugin_CgProgramManager_D");
#else
	m_pRoot->loadPlugin("RenderSystem_Direct3D9");
	m_pRoot->loadPlugin("Plugin_OctreeSceneManager");
	m_pRoot->loadPlugin("Plugin_CgProgramManager");
#endif // _DEBUG

	m_pRoot->setRenderSystem((*m_pRoot->getAvailableRenderers())[0]);
	m_pRoot->initialise(false);

	Ogre::NameValuePairList params;
	params["externalWindowHandle"] = Ogre::StringConverter::toString( (unsigned long)GetHwnd() );

	m_pWindow = m_pRoot->createRenderWindow(m_title, GetSize().GetWidth(), GetSize().GetHeight(), false, &params);
	m_pSceneMgr = m_pRoot->createSceneManager("OctreeSceneManager");
	m_pRayQuery = m_pSceneMgr->createRayQuery(Ogre::Ray());
	m_pWindow->setActive(true);
}
I would start with a basic wx "hello world" program, and the rest of your questions should answer themselves.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: wxOgre? Ogre in a wxWidget frame?

Post by stealth977 »

It may be a complex example but, in Addons forum we have a project called ogitor, the source is available and it has BOTH MFC and wxWidgets versions which you can check (for wxOgitor, check renderpanel.h/cpp)

ismail,
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: wxOgre? Ogre in a wxWidget frame?

Post by jacmoe »

xavier wrote:There is nothing about Ogre that has changed the way you embed it in any window, wxWidgets included.

You don't need "wxOgre" or anything special -- you get the window handle the same way in wx as you do in Mogre, it's a method
Right, so it is.
But define GetHwnd() - it's slightly different across various windowing frameworks.

This is from the Project Wish wiki - a useful wxWidgets/Ogre snippet:
http://wiki.projectwish.com/index.php?t ... ts_Control
And, Xavier is right: Nothing about Ogre has changed regarding setting the window handle.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Blackbeard
Kobold
Posts: 31
Joined: Sun Mar 04, 2007 9:07 pm

Re: wxOgre? Ogre in a wxWidget frame?

Post by Blackbeard »

Nice, thank you, thats a start :D
User avatar
RedEyeCoder
Gnome
Posts: 344
Joined: Sat Jun 16, 2007 7:29 am
Location: Brisbane, Australia

Re: wxOgre? Ogre in a wxWidget frame?

Post by RedEyeCoder »

Hi, I found the learning curve for wxWidgets quite steep myself, mainly due to conventions that I was just not used to.

This was useful for getting started with wxWidgets as it worked almost out of the box (I had some issues with the preprocessor and wxWidgets).

FYI there is source for Ogre 1.01, 1.2, 1.4 and the above link on the wiki. I have some more wxWidgets links at home that I will post later.
Blackbeard
Kobold
Posts: 31
Joined: Sun Mar 04, 2007 9:07 pm

Re: wxOgre? Ogre in a wxWidget frame?

Post by Blackbeard »

Thanks guys, its working so far:D
Setting up wxWidget was an adventure itself. Quiet easy once you have done it the first time.

MVS C++ Express + wxWidget 2.8.10
That cool guy here shows you how to setup it:

http://www.mefeedia.com/entry/08_instal ... s/11244535
http://www.mefeedia.com/entry/installin ... 2/11787227

Think i will use DevC++ IDE as Widget Designer (sucks a little, but it doesnt seem that there is any other free designer around?).

Cheers
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: wxOgre? Ogre in a wxWidget frame?

Post by jacmoe »

I use wxFormBuilder - it's by far the best, IMO. Payed for or free. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
c4engine
Gnoblar
Posts: 1
Joined: Sat Jul 21, 2012 12:11 am
Location: Mohali

Re: wxOgre? Ogre in a wxWidget frame?

Post by c4engine »

wxSmith inside Codeblocks has so many widgets in the Gui-builder that cant even compare to wxFormBuilder. wxSmith is very stable too
User avatar
AlexeyKnyshev
Goblin
Posts: 213
Joined: Sat May 26, 2012 10:37 am
Location: Russia
x 13

Re: wxOgre? Ogre in a wxWidget frame?

Post by AlexeyKnyshev »

It seems that I have a good chances to get answer from gurus for this question: "why is externalWindowHandle deprecated?" See this post.
Voltage Engine - boost your ogre project with realtime physics and interactive scripting!
OgreBullet & CMake - easy to use bullet physics integration.