Game Development Community

Making wxWidgets play nice with T3D

by Stefan Lundmark · in Torque 3D Professional · 10/18/2012 (1:29 pm) · 8 replies

Hi,

Anyone had any luck using wxWidgets with T3D?
The Canvas turns green even if I am using PlatformWindow and only have initialized wxWidgets .
As soon as I click to fire a weapon I get a Stack Overflow in ShapeImage::setImageState.I suspect there are issues with the wndProc wxWidgets sets up and the fact that T3D has one too but it is just a guess.

Anyone who have done this?

#1
10/18/2012 (2:35 pm)
I tried using wxPython with my Python extension. I made wx aware of T3D using the window handle. The event systems were incompatible. You will have to deal with the 2 event systems and merge one into the other. I think that will be your biggest hurdle.

I wanted to have separate windows of the same app, but the event systems caused problems. In the future I will just run a separate process and communicate between processes.
#2
10/19/2012 (8:04 am)
Thanks for your input Frank, I appreciate it!

I recall wxWidgets worked just fine (Qt too) in TGEA. I wonder what's changed.. Usually (in Win32) you just create a Window Class and register a WNDPROC for each seperate one. Two different classes shouldn't conflict.

#3
10/19/2012 (10:34 am)
I must not have been doing something right. Probably should not have given the T3D window handle to wx then.
#4
10/19/2012 (11:05 am)
I think I've found the issue, and you were right.

T3D attempts to dispatch events for all windows, even windows that doesn't belong to it like the ones used by wxWidgets. That might be the problem.

Edit: I was wrong.
#5
10/19/2012 (1:51 pm)
Just thought I'd report back.

Symptoms:
* Background is green and sorting is reversed in T3D's PlatformWindows.
* Clicking the mouse crashes the application with a Stack Overflow error.
* Right-clicking and trying to move the mouse won't work, nothing happens.

This went away if I didn't initialize wxWidgets (wxEntryStart).

I stepped trough wxEntryStart and found the culprint. In wxWidgets appbase.cpp ~ line 170. There's a function called wxAppConsoleBase::Initialize. Inside it, comment out the following:

#if wxUSE_INTL
    GetTraits()->SetLocale();
#endif // wxUSE_INTL

And the symptoms go away. SetLocale() sets up locale-specific date and number formatting. It might or might not be important to you. Of course, you can also set wxUSE_INTL to 0 and that'll also solve it.
#6
10/27/2012 (3:40 pm)
Could you please tell us how did you send the wxWindow handle (HWND) to Torque? Thank you!
#7
10/28/2012 (5:56 am)
One note: Frank was right about T3D's and wxWidget's event systems being incompatible. One needs to subclass a wxEventLoop class and let T3D feed events into it manually.

Hi Stan,

Use PlatformWindowManager::get()->setParentWindow.
#8
11/16/2012 (3:53 pm)
@Stefan,
Awesome, glad you figured this out. This is really good info to have on making these compatible.