Getting the Window Handle

BLiTZWiNG

20-12-2006 05:14:15

I saw the previous post and tried the unsafe code before I realised that the variable "window" used in the unsafe code doesn't actually exist anywhere.

I don't want to use Windows.Forms because of the memory leak issue in Application.DoEvents().

So unless there is a way to create a window then pass it off to Ogre, is there a way to get the handle of the Ogre created window?

Bekas

20-12-2006 10:39:53

IntPtr hwnd;
root.AutoCreatedWindow.GetCustomAttribute("HWND", out hwnd);


Plus, there's a way to create a window and pass it to Ogre, see Clay's excellent tutorial 6

BLiTZWiNG

20-12-2006 11:13:15

IntPtr hwnd;
root.AutoCreatedWindow.GetCustomAttribute("HWND", out hwnd);


Plus, there's a way to create a window and pass it to Ogre, see Clay's excellent tutorial 6


Thanks Bekas, that worked =)

I have been through all the tutorials, they were great. I did however mention above that there is an issue with tutorial 6 using Application.DoEvents() as shown by Tom Miller, it has a memory leak of about 116 bytes per call cumulative, which ends up forcing the GC to move your own short term objects to gen 2 when they should be gen 1, hence Tom and others stopped recommending App.DoEvents() as the way to go.

Bekas

20-12-2006 12:54:22

I did however mention above that there is an issue with tutorial 6 using Application.DoEvents() as shown by Tom Miller, it has a memory leak of about 116 bytes per call cumulative, which ends up forcing the GC to move your own short term objects to gen 2 when they should be gen 1, hence Tom and others stopped recommending App.DoEvents() as the way to go.
Very interesting and good to know.

pjcast

20-12-2006 17:28:36

IntPtr hwnd;
root.AutoCreatedWindow.GetCustomAttribute("HWND", out hwnd);


Plus, there's a way to create a window and pass it to Ogre, see Clay's excellent tutorial 6


Thanks Bekas, that worked =)

I have been through all the tutorials, they were great. I did however mention above that there is an issue with tutorial 6 using Application.DoEvents() as shown by Tom Miller, it has a memory leak of about 116 bytes per call cumulative, which ends up forcing the GC to move your own short term objects to gen 2 when they should be gen 1, hence Tom and others stopped recommending App.DoEvents() as the way to go.


You can use either method to create an Ogre render window (externally created Ogre window, or embedded form window) and avoid using DoEvents. You can use a timer (threaded or not) for a callback to update the ogre window. Or, you can use a real thread to update the ogre window (this has multithreading issues as does a multithreaded timer).

BLiTZWiNG

20-12-2006 21:41:50

Getting the window handle allows me to do it the way I like it. I don't really want to deal with threading issues at the moment.. I could have used DoEvents(), and would have if the get hwnd hadn't been implemented at this time, but its not an ideal solution.

marc_antoine

22-01-2007 06:34:09

hey blitzwing how did you found out what prameters to pass to the
root.AutoCreatedWindow.GetCustomAttribute() to get the HANDLE? since there are other methods in Mogre that i have a doubt on what parametrs to pass, like compositors for example.

CK_MACK

22-01-2007 08:07:17

Thanks for explaining this btw.... this will go a long way to figuring out some of the blind spots!