
Problem with context & GLWidget in Ubuntu 9.04
Posted Saturday, 2 May, 2009 - 23:56 by ITel inHello!
In Ubuntu 8.10, I use GLControl to make a context for GLWidget, but now, in Ubuntu 9.04 it doesn't work!
example:
... public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); GLControl gc = new GLControl(); GL.LoadAll(); Glu.LoadAll(); gc.Dispose(); } ...
And now application crashed with:
Stacktrace: at (wrapper managed-to-native) Gtk.Application.gtk_main () <0x00004> at (wrapper managed-to-native) Gtk.Application.gtk_main () <0xffffffff> at Gtk.Application.Run () <0x00007> at Test.MainClass.Main (string[]) [0x00011] in .../Test/Test/Main.cs:16 at (wrapper runtime-invoke) Test.MainClass.runtime_invoke_void_string[] (object,intptr,intptr,intptr) <0xffffffff> Native stacktrace: /usr/bin/mono [0x806d944] /usr/bin/mono [0x808616b] [0xb7f8e410] /usr/lib/libX11.so.6 [0xb67e121f] /usr/lib/libX11.so.6(XrmQGetResource+0x3e) [0xb67f7dce] /usr/lib/libX11.so.6(XGetDefault+0xcb) [0xb67d745b] /usr/lib/libcairo.so.2 [0xb675d978] /usr/lib/libcairo.so.2 [0xb675dca4] /usr/lib/libcairo.so.2 [0xb675e5bc] /usr/lib/libcairo.so.2(cairo_xlib_surface_create+0x10a) [0xb675ed6a] /usr/lib/libgdk-x11-2.0.so.0 [0xb693eeb1] /usr/lib/libgdk-x11-2.0.so.0 [0xb6912923] /usr/lib/libgdk-x11-2.0.so.0 [0xb691eb60] /usr/lib/libgdk-x11-2.0.so.0 [0xb6912923] /usr/lib/libgdk-x11-2.0.so.0(gdk_window_begin_paint_region+0x11e) [0xb692b9ee] /usr/lib/libgtk-x11-2.0.so.0(gtk_main_do_event+0x51e) [0xb6ab755e] /usr/lib/libgdk-x11-2.0.so.0 [0xb692be95] /usr/lib/libgdk-x11-2.0.so.0(gdk_window_process_all_updates+0xff) [0xb692c4af] /usr/lib/libgdk-x11-2.0.so.0 [0xb692c4db] /usr/lib/libgdk-x11-2.0.so.0 [0xb690f8fb] /usr/lib/libglib-2.0.so.0 [0xb7ef8c81] /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1e8) [0xb7efab88] /usr/lib/libglib-2.0.so.0 [0xb7efe0eb] /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca) [0xb7efe5ba] /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xb9) [0xb6ab77d9] [0xb48d6ec6] [0xb48d6e90] [0xb7a05259] [0xb7a051b3] /usr/bin/mono(mono_runtime_exec_main+0xe5) [0x80bad75] /usr/bin/mono(mono_runtime_run_main+0x16b) [0x80bb4eb] /usr/bin/mono(mono_main+0x1727) [0x805c917] /usr/bin/mono [0x805ac62] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7d27775] /usr/bin/mono [0x805aba1]
Have you any ideas? Or may be there are one more way (more correctly, this way was the simplest for me) to create this context?
P.s: sorry for my English..


Comments
Re: Problem with context & GLWidget in Ubuntu 9.04
Does the GLWidget not create its own context? You shouldn't have to use the GLControl at all.
If you are using a recent OpenTK version, you can use
GraphicsContext.CreateDummyContextinstead. Simply create a dummy context along with the GLWidget and store it as long as the GLWidget exists (i.e. don't Dispose() it). In pseudocode:The dummy context simply informs OpenTK that an external (i.e. not OpenTK-controlled) OpenGL context exists. You cannot use it to control the external context - swapping buffers, etc, should be done through the GLWidget interface.
Edit: The stacktrace points to a crash inside Mono. Which is the line in your program that triggers this crash? Can you post an isolated test case to confirm this, so we can log a bug to Mono?
Re: Problem with context & GLWidget in Ubuntu 9.04
Nothing understand...
Now I create a new gtk# 2.0 project, add references (GLWidget.dll, OpenTK,dll, OpenTK.Utils.dll), and add a GLWidget (by Designer).
If I use (see attachment)
GraphicsContext.CreateDummyContext(); (line 15)application has crashed with:
But if I use
GLControl gc = new GLControl(); (line 16)it works! (yesterday I tried to compile the same code and it didn't work)
But now it crashed when I resize window :-) (log in attachment)
Can you edit my solution to taught me how to use the correct context with GLWidget?
Re: Problem with context & GLWidget in Ubuntu 9.04
The null reference exception looks like an OpenTK bug, could you please enter it into the bug tracker (so it doesn't get lost)?
The GTK crash may be a Mono bug, I will try to reproduce and forward it upstream.
Re: Problem with context & GLWidget in Ubuntu 9.04
Ok, wrote a bug report, but may be I do something wrong?
Re: Problem with context & GLWidget in Ubuntu 9.04
Pardon my ignorance - What is GLWidget..? Is this some new thing of OpenTK?
Re: Problem with context & GLWidget in Ubuntu 9.04
@objarni
it is a gtk# widget for use openGL in gtk# application (analogy GLControl for WinForms)
It was created by JTalton and isn't a part of OpenTK (correct me, if I'm mistaken)
Home page
Re: Problem with context & GLWidget in Ubuntu 9.04
Thanks. I can't see anything wrong with your code, but I won't be able to test it until tomorrow.
Re: Problem with context & GLWidget in Ubuntu 9.04
@ITel
OK cool, that might prove useful since Winforms is not included in mono.. (simplifying cross-platform deployment of OpenTK-based app')
Re: Problem with context & GLWidget in Ubuntu 9.04
@the Fiddler
Thanks for the excellent work!
In OpenTK 0.9.8 GraphicsContext.CreateDummyContext() no longer causes a NullReferenceException, but now I can't create a context :-(
Using
GraphicsContext.CreateDummyContext()leads to:Can you help me?
Re: Problem with context & GLWidget in Ubuntu 9.04
As the exception says, you need to create an OpenGL context before calling
GraphicsContext.CreateDummyContext. The sequence of steps should look similar to this:I have tested OpenTK 0.9.8 with GLWidget on Linux and it works flawlessly on Linux. The only caveat is that you have to call
GLWidget.MakeCurrent()before usingGraphicsContext.CreateDummyContext().Note that you cannot actually use this dummy context to control the external context. You have to do this manually - calling
IGraphicsContext.SwapBuffersand similar functions won't have any effect.