Just curious if anyone has tried and successfully embedded ogre into a GTK-sharp widget? If so, and tutorials or code I could look at?
I;m planning on using GTK rather than winforms becuase there is a little better compatibility on Mono and linux.
hmm... I was thinking about this last week. It should not be too different than Winforms, just need to call a different Initialise function in root.
public RenderWindow Initialise(int existingwindowhandle, int width, int height, bool fullscreen)
The real question is how to get a handle to something in gtk-sharp. was looking in monodoc and didn't see anything explicitly saying it was the equivalent of a Hwnd
. But everything derives from GLib.Object and that has a read-only property Handle.
well no joy on my first try with gtk-sharp and ogre in linux. I got the same error as winforms is giving me. "Got a SIGSEGV while executing native code". almost the same the stactrace is differnt. seems mono is not working the same as .net somewhere.
i found some post in Mono-winforms-list about simarlar problem but not sure how to resolve it.
feb 2006 archive
in this post
Just a small update for all of you who are watching this topic/
thread. With help from the very friendly people on irc.gimp.net #mono-
winforms we managed to find out that the cause of this problem was
because of the -fomit-frame-pointer CFLAG. which for some reason was
causing the application to seg fault.
By Compiling the library without the -fomit-frame-pointer cflag we
were able to solve the problem. The proposed solution is to patch the
configure/make file script to check if the -fomit-frame-pointer is
turned on and if so disable it.
but what library. and how would i check/remove that flag i haven't figured out.
Have you tried your code in windows?
If not, send me a copy of your test code and I'll give it a try. Just curious if it is a linux issue, a mono issue, or a gtk usage issue.
I'm having trouble as well... I'm running code very similar to yours and I'm getting an ogre exceptions.
class OgreWidget : Gtk.Container
//...Skipping attribute code
public OgreWidget() : base()
root = new Root();
renderWindow = root.Initialise(this.Handle.ToInt32(), 640, 480, false);
// Skipping code that follows
I'm getting an error on the initialize function
The error says
15:19:26: GLRenderSystem::createRenderWindow "", 640x480 windowed miscParams: externalWindowHandle=79039736
15:19:26: An exception has been thrown!
Error #: 0
Description: selectPixelFormat failed.
I've been digging though this.. wish i saved the URLs
fog was doing work to allow Ogre to render in a Gtk window
. He has not posted anything in a while so I gess ill try and email him about this.
I think that Glib.Handle is retruning an IntPtr to the GTK class, in your code a Gtk Container class, not an X11 or Windows handle to a window. in c++ gtk there are functions to get the window handle from that i beleve, not sure what functions. It looks like we will have to create another c++ dll that references GTK and Ogre and can do this work. othere than that one thing, I'm not sure what else may need to be done.
I think I'm going to look into the "gdk_window_foreign_new ()" function tomorrow.
It might be possible to let Ogre create the window, and then attach it to the GTK widget.
I'v extracted fog's GtkOgre widget from his project shy. Still a problem on windows
but we may be able to figure it out.
Now just have to wrapp it.
Hope you have better luck than I am having.
I'm following the gtk# example for creating custom widgets, and looked at the ogregtk example, and I still have the same problem. How do I get an HWND handle. The gtk C++ library has methods to do this, I can't find anything similar in the C# library.
Hey Rastaman, thank you for adaptation GTKOgre to windows.
I found two bugs in the code, cause that in test1 example there was no ogre in the window and in all examples, ogre window was notconnected with it's parent window.
in gtk_ogre_bridge_window_create function
params[String("parentWindowHandle")] = handle;
ought to be
params[String("externalWindowHandle")] = handle;
#if defined( __WIN32__ ) || defined( _WIN32 )
Now there is only problem
, ogre widget occupy the hole parent window (other child widgets are cover).
Hi Ocelot, thanks for the info. I haven't mested with that project in a while, and probably will not have time this weekend
Now there is only problem Wink , ogre widget occupy the hole parent window (other child widgets are cover).
in linux i had the same problem with widgets. I think it was to create the ogre widget on top and other widgets at bottum, not sure if i tried any other way like with a hbox.
@rastaman: i downloaded and compiled your code (i also patched it with ocelot's improvements) but both example programs always create an extra ogre window (i.e. not embedded into gtk), and test1 also fails right after startup:
lt-test1: OgreControllerManager.cpp:41: static Ogre::ControllerManager& Ogre::ControllerManager::getSingleton(): Assertion »ms_Singleton« failed.
i'm trying to code a wxWidgets (2.6.2, using gtk on linux) application with an ogre control inside for hours but it's still not working ... i also tried this
piece of code, though it's for windows only (i mixed it with your/shy's code)
what's remarkable: the ogre window's created before
the application main frame shows up
is it because i compiled ogre to use SDL?
hope you can help me, i'm also willing to provide some hours of work to help you all