Kirix Support Forums

X Window System error with wxGLCanvas under GTK+

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

X Window System error with wxGLCanvas under GTK+

Postby Peek on Mon Jul 24, 2006 4:27 pm

I'm having trouble getting wxGLCanvas to work with wxAUI under GTK+. I've spent the day isolating the problem and I've narrowed it down to a pretty simple test case: If I take the sample wxAUI app and replace one of the text controls with a wxGLCanvas (I used TestGLCanvas from the cube app in samples/opengl/cube):

Code: Select all
MyFrame(wxWindow* parent) : wxFrame(parent, -1, _("wxAUI Test"),
                     wxDefaultPosition, wxSize(800,600),
                     wxDEFAULT_FRAME_STYLE)
  {
    m_mgr.SetFrame(this);

    TestGLCanvas* canvas = new TestGLCanvas( this );
    wxTextCtrl* text2 = new wxTextCtrl(this, -1, _("Pane 2 - sample text"),
                     wxDefaultPosition, wxSize(200,150),
                     wxNO_BORDER | wxTE_MULTILINE);

    wxTextCtrl* text3 = new wxTextCtrl(this, -1, _("Main content window"),
                     wxDefaultPosition, wxSize(200,150),
                     wxNO_BORDER | wxTE_MULTILINE);

    // add the panes to the manager
    m_mgr.AddPane( canvas, wxLEFT, wxT( "OpenGL" ) );
    m_mgr.AddPane(text2, wxBOTTOM, wxT("Pane Number Two"));
    m_mgr.AddPane(text3, wxCENTER);

    m_mgr.Update();
  }


when I run the app I get an X server error as soon as I undock the OpenGL pane:

(FMTestApp:15587): Gdk-WARNING **: gdkdrawable-x11.c:912 drawable is not a pixmap or window
The program 'FMTestApp' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
(Details: serial 1348 error_code 8 request_code 143 minor_code 5)


Similar results happen when starting with an undocked pane and I try to dock it.
This works fine under MSW, btw.
Environment: gcc 3.4.5, wxAUI 0.9.2, GTK 2.4.13, Red Hat

I don't have the debug version of X installed, so I can't put a breakpoint at gdk_x_error(), but using the '--g-fatal-warnings' command line option, I'm able to get a stack trace to the code that's generating the gdk warning. Here's the germane part of it:

Code: Select all
#1  0x00bef7f5 in raise () from /lib/tls/libc.so.6
#2  0x00bf1199 in abort () from /lib/tls/libc.so.6
#3  0x04310ebe in g_logv () from /usr/lib/libglib-2.0.so.0
#4  0x04310ef0 in g_log () from /usr/lib/libglib-2.0.so.0
#5  0x00694a79 in gdk_x11_drawable_get_xid () from /usr/lib/libgdk-x11-2.0.so.0
#6  0x002f25d1 in wxGLContext::SetCurrent (this=0x8658790)
    at ../src/gtk/glcanvas.cpp:166
#7  0x002f3e60 in wxGLCanvas::SetCurrent (this=0x8632768)
    at ../src/gtk/glcanvas.cpp:657
#8  0x08073572 in TestGLCanvas::OnSize (this=0x8632768, event=@0xbff0c1c0)
    at ../src/testoglcanvas.cpp:286
#9  0x003cf309 in wxAppConsole::HandleEvent (this=0x85c37d8,
    handler=0x8632768, func=
      {__pfn = 0x8073536 <TestGLCanvas::OnSize(wxSizeEvent&)>, __delta = 0},
    event=@0xbff0c1c0) at ../src/common/appbase.cpp:324
#10 0x00481639 in wxEvtHandler::ProcessEventIfMatches (entry=@0x807d6e0,
    handler=0x8632768, event=@0xbff0c1c0) at ../src/common/event.cpp:1193
#11 0x00480580 in wxEventHashTable::HandleEvent (this=0x807d6c8,
    event=@0xbff0c1c0, self=0x8632768) at ../src/common/event.cpp:875
#12 0x0048184d in wxEvtHandler::ProcessEvent (this=0x8632768,
    event=@0xbff0c1c0) at ../src/common/event.cpp:1255
#13 0x002f2a28 in gtk_glcanvas_size_callback (alloc=0xbff0c720, win=0x8632768)
    at ../src/gtk/glcanvas.cpp:294
#14 0x00943acd in g_cclosure_marshal_VOID__BOXED ()
   from /usr/lib/libgobject-2.0.so.0
#15 0x0092b347 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#16 0x0094094e in g_signal_has_handler_pending ()
   from /usr/lib/libgobject-2.0.so.0
#17 0x009429bc in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#18 0x00942c5a in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#19 0x040654f6 in gtk_widget_size_allocate () from /usr/lib/libgtk-x11-2.0.so.0
#20 0x010c0087 in gtk_pizza_allocate_child (pizza=0x862f430, child=0x8638470)
    at ../src/gtk/win_gtk.c:971
#21 0x010bf867 in gtk_pizza_size_allocate (widget=0x862f430,
    allocation=0xbff0cd20) at ../src/gtk/win_gtk.c:768
#22 0x00943acd in g_cclosure_marshal_VOID__BOXED ()
   from /usr/lib/libgobject-2.0.so.0
#23 0x0092b6b2 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0
#24 0x0092b347 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#25 0x00940616 in g_signal_has_handler_pending ()
   from /usr/lib/libgobject-2.0.so.0
#26 0x009429bc in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#27 0x00942c5a in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
..and so forth and so on...


Any ideas on how to fix this problem? Does wxAUI support wxGLCanvas under GTK?
Peek
Registered User
 
Posts: 10
Joined: Thu Mar 30, 2006 12:56 pm

Postby Kazade on Sun Sep 03, 2006 3:44 pm

I am having an identical problem. Has anyone come up with a way to fix this yet?
Kazade
Registered User
 
Posts: 1
Joined: Sun Sep 03, 2006 3:43 pm

Postby jonnyO2 on Tue Jun 12, 2007 6:59 pm

I'm experiencing the same problem as well under GTK with wxGTK 2.8.4. I'm also hoping there is a solution! Anyone...?

My code works fine under Windows, BTW.
jonnyO2
Registered User
 
Posts: 5
Joined: Tue Jun 12, 2007 5:17 pm

Postby Ben on Thu Jun 14, 2007 8:35 am

Hi,

It seems everybody has problems with aui and gl canvas on gtk. I don't have experience with wxGLCanvas, so I have no quick and easy way to debug this particular problem. It'd be great if someone could look into what's causing this. I wonder if this is a problem with wxGLCanvas's ability to reparent... all other window types work well on GTK.

Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Postby jonnyO2 on Thu Jun 14, 2007 10:58 am

Ben,

I'm no GLX expert, but GLX does appear to be finnicky about what the state of the GL context is.

Let's hope someone who knows GLX can help out on this one!

Jon
jonnyO2
Registered User
 
Posts: 5
Joined: Tue Jun 12, 2007 5:17 pm

Postby jonnyO2 on Thu Jun 14, 2007 11:02 am

BTW - this is also a problem under wxMac.
jonnyO2
Registered User
 
Posts: 5
Joined: Tue Jun 12, 2007 5:17 pm

Re: X Window System error with wxGLCanvas under GTK+

Postby luke on Mon Jun 25, 2007 10:05 am

Not sure if this helps, but it worked for us. It is important to make sure the window is created before attempting to occupy the context, or else you will get a crash every time.


In this code, class GUIGLCanvas (derived from wxGLCanvas) has bool member variable '_isCreated'. Here is a clip of the .cpp file:


BEGIN_EVENT_TABLE(GUIGLCanvas, wxGLCanvas)
#ifdef __WXGTK__
EVT_WINDOW_CREATE(GUIGLCanvas::onCreate)
#endif
END_EVENT_TABLE()

GUIGLCanvas::GUIGLCanvas(wxWindow* parent,
wxWindowID id,
int* attribList,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name,
const wxPalette& palette) :
wxGLCanvas(parent, id, attribList, pos, size, style, name, palette),
_glContext(NULL),
_isCreated(false)
{
//create the GL context
_glContext = new wxGLContext(this);

#ifdef _WIN32
_isCreated = true;
#endif

return;
}

#ifdef __WXGTK__
void GUIGLCanvas::onCreate(wxWindowCreateEvent& event)
{
_isCreated = true;
return;
}
#endif

bool GUIGLCanvas::occupyContext()
{
if(!_isCreated || !this->IsShown() || _glContext == NULL)
{
return false;
}

this->SetCurrent(*_glContext);

return true;
}


Luke
luke
Registered User
 
Posts: 1
Joined: Mon Jun 25, 2007 9:59 am

Re: X Window System error with wxGLCanvas under GTK+

Postby qcp on Fri Aug 22, 2008 3:45 pm

Hi
I encounter the same problem with wxAuiManager and dockage wxGLCanvas under wxGTK. The proposed solution (SetCurrent() on saved opengl context) does not work for me.
Did you manage to solve your problem ? If so, could you please help me ?

Thanks
qcp
Registered User
 
Posts: 1
Joined: Fri Aug 22, 2008 3:41 pm

Re: X Window System error with wxGLCanvas under GTK+

Postby jojosoto on Sat Mar 26, 2011 2:55 pm

qcp wrote:Hi
I encounter the same problem with wxAuiManager and dockage wxGLCanvas under wxGTK. The proposed solution (SetCurrent() on saved opengl context) does not work for me.
Did you manage to solve your problem ? If so, could you please help me ?

Thanks


worked for me qcp, make sure to double check and make sure all of your numbers match up etc.
jojosoto
Registered User
 
Posts: 6
Joined: Fri Mar 25, 2011 12:39 pm

Re: X Window System error with wxGLCanvas under GTK+

Postby scarlett45 on Thu Aug 18, 2011 5:15 am

Thank you very much your solution worked and it will help me!!!!!!!
scarlett45
Registered User
 
Posts: 1
Joined: Thu Aug 18, 2011 5:12 am

Re: X Window System error with wxGLCanvas under GTK+

Postby Jinky on Mon Aug 22, 2011 4:22 am

I've just come across this problem in wxGTK 2.8.10, so I suppose it still hasn't been resolved? Has anyone added submitted a ticket for this? Any comments on scpmdu's patch?

Thanks
Jinky
Registered User
 
Posts: 1
Joined: Mon Aug 22, 2011 4:21 am

Re: X Window System error with wxGLCanvas under GTK+

Postby patricia34 on Thu Oct 20, 2011 8:03 am

I've been wrestling with this problem for a while now. I have an application that runs just fine under MSW, but crashes immediately under GTK. I believe the problem is that my call to IsShownOnScreen() is returning true before the wxCanvas is actually shown on the screen, but this is difficult to debug, so I am not sure. What I am sure of, is that the application crashes on the first call to openGL.

I've tested with wx 2.8.11 and 2.8.12 in both MSW and GTK.
patricia34
Registered User
 
Posts: 1
Joined: Thu Oct 20, 2011 7:59 am

Re: X Window System error with wxGLCanvas under GTK+

Postby Ben on Mon Oct 24, 2011 12:01 pm

This issue has remained the same for some years. I believe it's a window re-parenting issue either in wxGTK or wxGLCanvas. I don't believe the error actually lies within the realm of wxAUI, but it is important to note that wxAUI reparents windows all the time.

Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Return to wxAUI Questions, Thoughts & Feedback