New tutorial: "Integrating OGRE with wxWidgets."

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

New tutorial: "Integrating OGRE with wxWidgets."

Post by Noiprox »

Here is PDF and demo (Visual Studio .NET source only, sorry).
Comments and suggestions always welcomed (copy & paste, anti-spam):

mailto:%6E%6F%69%70%72%6F%78%40%74%65%6C%75%73%2E%6E%65%74
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
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 »

Great, thanks. I'll add this to our growing collection :)
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post by SpannerMan »

Had a quick look throught the PDF, and it looks very descriptive and rather professional.

I hope to go through this tutorial soon...even if I never end up using wxwidgets, I believe its going to teach me some important things anyway.

Thanks Noiprox :)
User avatar
bad_camel
Halfling
Posts: 74
Joined: Tue Dec 17, 2002 11:57 am
Location: Somerset, England
Contact:

Post by bad_camel »

You start off saying that ogre provides a xplatform integrated gui system, but sometimes something more mature is needed. This I interpret as the reason for the document.

I find this blurs a line that some people new to gui's within 3d apps find hard(surprisingly) to grasp.

There are 2 ways that guis are used in 3d apps. Guis that are contained within and possibly managed by the app, like ogre's "in-app" gui system and the situation where you are using a gui system that contains a widget that happens to be a 3d viewport. They are quite different and in fact can be used together(although the reason to do this would be baffling).

It may be that I read that first sentence wrong, but perhaps further clarifying this difference in terms of ogre's gui and wxWidgets would serve to immediately inform the new comer to their context.

Good document though, I agree it has a proffesional touch :)
tisba
Kobold
Posts: 37
Joined: Sun Jan 26, 2003 1:17 am
Location: France (Paris)

Post by tisba »

Nice, though you might want to regenerate the PDF to be more than one page long. My printer does not handle 60 inch long paper :wink:

-- Baptiste.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Nice tutorial! Although it's still platform dependent until we have a platform independent mechanism to do

Code: Select all

HWND h = (HWND)(mFrame->GetHandle());
D3D9RenderSystem *rsys = ...;
rsys->SetExternalWindowHandle(h);
First off, I don't think the SetExternalWindowHandle call should be a method on the RenderSystem but should be a parameter to the CreateWindow method (to facilitate for multiple 'OGRE areas')

Furthermore, we can generalise the window handle to a (void*), in which case windows puts a HWND and X11 a Window. Although I'm not sure what wx's GetHandle returns in the X11 case?

It would be so nice to use a

Code: Select all

root->CreateRenderWindow(..., mFrame->GetHandle());
in an end user application without even caring which platform is used!
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Post by Noiprox »

Thanks guys!

bad_camel, I see the distinction, but I don't consider it so important. I'll consider rephrasing it to articulate the difference more clearly. Perhaps I should show examples? I could put two screenshots side-by-side if that would help. I imagine that anyone who would go so far as to read my tutorial would probably already be able to tell the difference (it's aimed at intermediate-level programmers).

wumpus, I agree.
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Post by Noiprox »

tisba wrote:Nice, though you might want to regenerate the PDF to be more than one page long. My printer does not handle 60 inch long paper :wink:
Hehe. It's a compromise - screen or print optimized. I chose screen. Can't please everyone. :) I'll see how it looks once paginated.
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
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 »

:wumpus: wrote:...
First off, I don't think the SetExternalWindowHandle call should be a method on the RenderSystem but should be a parameter to the CreateWindow method (to facilitate for multiple 'OGRE areas')

Furthermore, we can generalise the window handle to a (void*), in which case windows puts a HWND and X11 a Window. Although I'm not sure what wx's GetHandle returns in the X11 case?

It would be so nice to use a

Code: Select all

root->CreateRenderWindow(..., mFrame->GetHandle());
in an end user application without even caring which platform is used!
I couldn't agree more !! :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

I just found out that the GetHandle call in X11 returns a GTK_WIDGET.. ouch
A certain perl binding uses this code:

Code: Select all

#ifdef __WXMSW__
    WXHWND handle = THIS->GetHandle();
    RETVAL = handle;
#else
    WXWidget handle = THIS->GetHandle();
    RETVAL = PTR2IV(handle);
#endif
Maybe the X11 handle can be dug out of the GTK one some way, or we can use the Ogre-GTK frontend; but the problem is that this uses GTKmm(GTK C++ binding) and not plain GTK. So it should accept a plain GTK handle too and manually wrap it.. hmm
User avatar
limpnode
Gnoblar
Posts: 5
Joined: Tue May 25, 2004 5:44 am
Location: unspecified
Contact:

Post by limpnode »

First off, thanks to Noiprox for providing the tutorial. Visual Studio is no longer a requirement to accomplish the task decribed in the PDF. I have built the demo using mingw ( gcc 3.3.1 ). The demo is available at:

http://the-agency.sourceforge.net/xoops ... =10&lid=46

The above download uses Ogre v0.14 and wxWidgets-2.5.2. However, I do not have Visual Studio and I am wondering whether or not the mingw version has the same look and feel as the Visual Studio version. Any input would greatly be appreciated.
Thank you for your time.
The Agency - http://the-agency.sourceforge.net/
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Post by Noiprox »

Nice work!

I'm getting strange problems, such as the menu bar not displaying correctly, and the window not being redrawn properly when I resize it. It seems as though the OGRE viewport is too large, so it's overlapping the menu, and the window frame is not resizing with the OGRE viewport.
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
supersuper
Greenskin
Posts: 114
Joined: Wed Feb 11, 2004 5:41 pm
Location: England!

Post by supersuper »

Has there been a change between 0.15 and 1.0 that this does not work (as the code stands) in the tutorial?

Just a few simple changes to the code, and it's working. Thanks again Noiprox for the tutorial.
User avatar
baxissimo
Greenskin
Posts: 135
Joined: Wed Feb 23, 2005 1:28 pm
Location: Tokyo, JAPAN

Fix

Post by baxissimo »

Instead of this:

Code: Select all

  // Render system.
  mRSys = mRoot->getRenderSystem();
  D3D9RenderSystem *rsys = (D3D9RenderSystem *)mRSys;
  rsys->SetExternalWindowHandle(handle);
I think you want to do something more like this:

Code: Select all

    // Render window.
    NameValuePairList misc;
    misc["externalWindowHandle"] = StringConverter::toString((size_t)handle);
    mWnd = mRoot->createRenderWindow("My sub render window", 100, 100, false, &misc);
Was this what you were referring to Supersuper?

--bb
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

Post by Yokom »

I was trying to get this to work last night and im confused on how to cast the HWND now looking at your code.

I was using the namevaluepairlist and passing the HWND like this

Ogre::StringConverter::ToString((UINT)Handle);

not sure the size_t cast and the UINT cast makes a difference but cating as an int is bad.
Adhemar
Gnoblar
Posts: 1
Joined: Wed May 11, 2005 11:15 pm

Post by Adhemar »

I'm trying to get this sample to compile, but I'm having some problems due to this being made for an older version of Ogre. I did what baxissimo suggests but I still get some errors with these lines:

Code: Select all

MaterialManager::getSingleton().parseAllSources();


ResourceManager::addCommonSearchPath("../Media");


ResourceManager::addCommonArchiveEx("../Media/cubemapsJS.zip", "Zip");
If I comment those out, the program compiles but I get an exception "Cannot create window, no render system has been selected" at Root::CreateRenderWindow.

Any ideas?

Also, I would like to know if it's possible to use the OpenGL renderer with wxWidgets, or just D3D like this sample does.
User avatar
psyclonist
OGRE Expert User
OGRE Expert User
Posts: 286
Joined: Fri Nov 01, 2002 3:54 pm
Location: Berlin & Nuremberg, Germany
x 1
Contact:

Post by psyclonist »

I think, this is a bit more uptodate.

-psy
Post Reply