tinker-time
As promised the source to these examples…

(click for full size)
… can be obtained with these commands…
bzr branch http://bazaar.launchpad.net/~macslow/gtk-offscreen-1/trunk gtk-offscreen-1 bzr branch http://bazaar.launchpad.net/~macslow/gtk-gl-offscreen-1/trunk gtk-gl-offscreen-1 bzr branch http://bazaar.launchpad.net/~macslow/gtk-gl-offscreen-2/trunk gtk-gl-offscreen-2 bzr branch http://bazaar.launchpad.net/~macslow/gtk-gl-rgba-1/trunk gtk-gl-rgba-1 |
If you have gtk+ 2.12.x, libglade 2.6.x and gtkglext 1.0.6 and their respective development files installed, the not so usual…
./autogen.sh ; make |
… in each directory will create the binaries. They all work under metacity, but usually look nicer under compiz.
This stuff is still very rough around the edges, so you will certainly run into one or more issues. But that last sentence probably nobody will ever read *sigh*
December 20th, 2007 at 10:04 am
Marco,
thank you so much for releasing your code - awesome what easy way you and Ryan (the author of GTK+ composite support) found, to allow this awesome effects. People looking at the gtk-offscreen-1 code should not underestimate the effort needed to come to such a trivial looking solution. Wow! I am really impressed what’s possible those days, what rocking framework we’ve got. Exciting times.
PS: What do you think about moving at least the gtk-offscreen-1 example into gtk-demo? Didn’t look at the other examples yet.
PPS: No flickering on the brand new compositor enabled Metacity.
PPPS: Did you try playing with cairo’s double buffering support to avoid flickering on non-compositing Metacity after disabling GTK+ double buffering?
December 20th, 2007 at 10:21 am
H,
I tried using Metacity’s compositor and here is what I get:
zdra@zdra-laptop:~/gtk-gl-rgba-1$ ./gtk-gl-rgba-1
The program ‘gtk-gl-rgba-1′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 244 error_code 8 request_code 128 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Locking assertion failure. Backtrace:
#0 /usr/lib/libxcb-xlib.so.0 [0x2b6fb204297c]
#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_lock+0×15) [0x2b6fb2042a15]
#2 /usr/lib/libX11.so.6 [0x2b6faed8d543]
#3 /usr/lib/libX11.so.6(XESetCloseDisplay+0×3f) [0x2b6faed7102f]
#4 /usr/lib/libGL.so.1 [0x2b6faddbdf5d]
gtk-gl-rgba-1: xcb_xlib.c:73: xcb_xlib_lock: l’assertion « !c->xlib.lock » a échoué.
Any idea?
December 20th, 2007 at 11:06 am
Wait, this isn’t true gtk GL integration (i.e the gtk widgets are not really rendered offscreen themselves to GL textures) but `just’ a gtk-gl demo in that the demos are gtk widgets on argb drawables (on X primitives, not textures) with a seperate gtkgl area also rendered in the app (containing no actual GTK widgets) ?
Sorry a bit confused here.
December 20th, 2007 at 2:24 pm
@Xavier: Had the same issues, start it like this:
./gtk-gl-rgba-1 –sync
It solved it for me.
December 20th, 2007 at 6:13 pm
@ Mathias: Yes, I can write a patch for the "composited window"-example and suggest it to the gtk+-maintainers. Of course it should not flicker under a composited environment… otherwise this metacity-compositor would not be worth much. What do you mean by "cairo’s double-buffering suppport". Normal surface-buffering? BTW, I’m called Mirco not Marco (i and a are very far apart on the qwertz-keyboard so it doesn’t count as a typo :).
@ Xavier: You should run it with –sync like suggested and the serial code can ignored. Nevertheless "error_code 8 request_code 128 minor_code 5" would mean BadMatch-error for the call XShapeQueryExtents().
@ mallum: It is in the visual sense
I did not imply to have done a GL-based gdk-backend, if you assumed that. The approach used is like "compiz, but for widgets" due to the same GLX-extension used… and input only works for the non-transformed state of the widget. I have not yet started thinking about toolkit-level input-redirection. There are only totally vague ideas.
@ Neil: Syncing the X11-request fixes a BadMatch-error?! Gee, I still have much to learn about X11! But glad to hear you have it working.
December 21st, 2007 at 10:34 am
Mirco, pardon - and this happens to me!
With cairo’s double-buffering support I refer to cairo_push_group/cairo_pop_group_to_source. When using them in your expose handler, the flickering disappears:
=== modified file ‘main.c’
— main.c 2007-12-19 20:57:30 +0000
+++ main.c 2007-12-21 09:27:31 +0000
@@ -47,6 +47,9 @@
/* create a cairo context to draw to the window */
pContext = gdk_cairo_create (pWidget->window);
+ /* redirect output for double-buffering */
+ cairo_push_group (pContext);
+
/* write/paint over everything else */
cairo_set_operator (pContext, CAIRO_OPERATOR_OVER);
@@ -136,6 +139,10 @@
cairo_pattern_destroy (pMask);
cairo_restore (pContext);
+ /* draw the buffered contents */
+ cairo_pop_group_to_source (pContext);
+ cairo_paint (pContext);
+
/* we’re done */
cairo_destroy (pContext);
PS: Still have to figure out how you handle your captcha. It always rejects my first post.
December 22nd, 2007 at 7:48 am
@ Mathias: Patch verified, applied and pushed upstream.
December 28th, 2007 at 4:42 pm
Wow, these look nice!
However, I get some errors. Posting them with and without sync, so that you can check!
jean@Admin-PC:~/software/test/gtk-gl-rgba-1$ ./gtk-gl-rgba-1
The program ‘gtk-gl-rgba-1′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 187 error_code 8 request_code 144 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
jean@Admin-PC:~/software/test/gtk-gl-rgba-1$ ./gtk-gl-rgba-1 –sync
The program ‘gtk-gl-rgba-1′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 410 error_code 8 request_code 144 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
jean@Admin-PC:~/software/test/gtk-gl-offscreen-2$ ./gtk-gl-offscreen-2
11/179:
succeeded with visual-id check (depth 24)
red-size = 8
green-size = 8
blue-size = 8
alpha-size = 8
buffer-size = 32
stencil-size = 0
depth-size = 24
double-buffer = 1
color-buffer can be bound to rgb-texture
color-buffer can be bound to rgba-texture
1D texture-target supported
2D texture-target supported
rectangular texture-target supported
window drawable-type supported
pixmap drawable-type supported
pbuffer drawable-type supported
The program ‘gtk-gl-offscreen-2′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 268 error_code 8 request_code 144 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
jean@Admin-PC:~/software/test/gtk-gl-offscreen-2$ ./gtk-gl-offscreen-2 –sync
11/179:
succeeded with visual-id check (depth 24)
red-size = 8
green-size = 8
blue-size = 8
alpha-size = 8
buffer-size = 32
stencil-size = 0
depth-size = 24
double-buffer = 1
color-buffer can be bound to rgb-texture
color-buffer can be bound to rgba-texture
1D texture-target supported
2D texture-target supported
rectangular texture-target supported
window drawable-type supported
pixmap drawable-type supported
pbuffer drawable-type supported
The program ‘gtk-gl-offscreen-2′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 454 error_code 8 request_code 144 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
January 9th, 2008 at 8:13 am
Mirco, pardon - and this happens to me!
When i run the program gtk-gl-offscreen-2,an eoror hanpened:
Unable to find GLX_EXT_texture_from_pixmap!
January 12th, 2008 at 11:30 pm
I have the same "Unable to find GLX_EXT_texture_from_pixmap!" problem.
It seems AIGLX only returns texture_from_pixmap support in the server.
There are some workarounds here: http://lists.freedesktop.org/archives/compiz/2007-April/001918.html
I solved by changing the code in opengl.c from:
pcDummy = glXQueryExtensionsString (GDK_DISPLAY_XDISPLAY
(gdk_display_get_default ()), 0);
to:
pcDummy = glXQueryServerString (GDK_DISPLAY_XDISPLAY
(gdk_display_get_default ()), 0, GLX_EXTENSIONS);
It finds the texture_from_pixmap, but doesnt work very well to me, I can only see the background.
January 14th, 2008 at 9:45 am
Wow ! Your work should be diffused !
January 17th, 2008 at 8:12 pm
Hey Marco,
Thanks so much for publishing the code, especially the rgb visual one.. I’ve been trying to figure out how to implemennt a CoverFlow like like interface, and I used your example while stripping out all the GTK code and porting it to GLUT. I even managed to to port it python. THanks again
infinite8s
By the way, something is seriously wrong with this comment box in OS X’s Firefox.
January 17th, 2008 at 9:00 pm
Nice!
but i have a problem to run it:
guillaume@portable-gui:~/Bordel/gtk-gl-offscreen-2$ ‘/home/guillaume/Bordel/gtk-gl-offscreen-2/gtk-gl-offscreen-2′ –sync
(gtk-gl-offscreen-2:19092): Gtk-WARNING **: Theme directory 24×24/stock/object of theme Powered has no size field
11/179:
succeeded with visual-id check (depth 24)
red-size = 8
green-size = 8
blue-size = 8
alpha-size = 8
buffer-size = 32
stencil-size = 0
depth-size = 24
double-buffer = 1
color-buffer can be bound to rgb-texture
color-buffer can be bound to rgba-texture
1D texture-target supported
2D texture-target supported
rectangular texture-target supported
window drawable-type supported
pixmap drawable-type supported
pbuffer drawable-type supported
The program ‘gtk-gl-offscreen-2′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 418 error_code 8 request_code 143 minor_code 5)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
gtk-gl-offscreen-2: xcb_xlib.c:41: xcb_xlib_lock: l’assertion « !c->xlib.lock » a échoué.
Abandon (core dumped)
Any idea to solve it?
Thx
January 18th, 2008 at 4:21 am
looking forward to sparkle, oh…. in the mock ups for sparkle below the playlists I noticed some sort of way to organize music by the amount of stars you gave it… Is that a real plugin or was it just part of the sparkle mockup?
January 18th, 2008 at 11:01 am
@ John McHugh: That’s a couple of "automatic playlists" I created myself. Instead of a name with normal letters I used these star-characters. This is a normal feature of rhythmbox available right now.
January 18th, 2008 at 9:22 pm
I was looking over your blueprints for hardy.. Some very cool stuff there, Had a similar idea for the avatar creation some time ago.. I was thinking how the about me window could be improved… Maybe it could be used to hold telepathy account settings
Trailing off the point, have you looked to see if it were possible to create a rhythmbox plugin out of the example above yet? Id help but I\\\\\\\\\\\\\\\’m only a Java student atm so my skills are absolutely useless in all of those cool open source projects out there
you might find this guy interesting though, http://wisniowy.blogspot.com/2007/12/cover-art-with-some-clutter.html He was the guy that worked of the cover fleow plugin for rhythmbox before it slowly died and recently enough was messing around with clutter and rhythmbox
January 18th, 2008 at 9:23 pm
sorry, cover fleow was for banshee
February 13th, 2008 at 8:16 am
hi
while trying to run it i get error mesage
Unable to find GLX_EXT_texture_from_pixmap!
thanks
February 13th, 2008 at 8:36 am
hi
just after posting my previous comment i read Alexandre’s post
and made the changes but didn’t work .
I can only see an undecorated top-level-window with only background
thanks
February 13th, 2008 at 9:07 am
@ Varun: If you’re running this on anything but nvidia-hardware, using the proprietary driver, you’re in for this kind of trouble. Although I followed the spec of GLX_EXT_texture_from_pixmap as good as examples (the spec at OpenGL.org and compiz’ sources) and documentation allow, there are unresolved issues like the one you’re experiencing. I cannot get the GL-based examples to work on my i915- and i965-based computers too. My earlier efforts asking for help on the Xorg-mailing-list were unsuccessful. At the moment my job is keeping me busy in other areas, keeping me away from working more on this.
February 15th, 2008 at 5:49 am
hi
Nice work there but i am a newbee in this
and want some information regarding basics of the OPENGL.
Is it important to have information about which hardware accelerator you are using.
So what are the things i need to pay attention before starting programming in OpenGL?
OpenGL do not provide any event handling or windowing mechanism, but you used
Gtk windowing and event handling mechanism smartly, and I have also heard about "mesa". so how about mesa, as it has its own event handling and windowing mechanism, can it be configured according to the hardware, as by reading through above discussions i get the feeling that OpenGl depends on the hardware support.
Any suggestions are welcome
thanks
September 19th, 2008 at 11:36 pm
Hi
First of all, thank you for your contribution. Your work helped me a lot in understanding composite UI.
I had to apply the following changes (diff below) in order for it to work on my machines
(ubuntu 7.10 with intel graphics, ubuntu 7.10 with nvidia graphics)
without the changes, X reported BadSomething and killed my app.
———————start diff—————————————-
diff -ur glo2/opengl.c gtk-gl-offscreen-2/opengl.c
— glo2/opengl.c 2008-09-19 18:38:10.000000000 +0300
+++ gtk-gl-offscreen-2/opengl.c 2008-09-20 01:05:31.000000000 +0300
@@ -709,7 +707,7 @@
GLX_DOUBLEBUFFER,
&iValue);
g_print (" double-buffer = %2d\n", iValue);
-#if 0
+
/* check for bindable color-buffers */
glXGetFBConfigAttrib (pDisplay,
pFBConfigs[i],
@@ -720,7 +718,6 @@
iBindable = 1;
g_print (" color-buffer can be bound to rgb-texture\n");
}
-#endif
glXGetFBConfigAttrib (pDisplay,
pFBConfigs[i],
GLX_BIND_TO_TEXTURE_RGBA_EXT,
@@ -997,12 +994,11 @@
/* bind widget’s texture */
glBindTexture (pWidget->pTexture->iTarget,
pWidget->pTexture->uiTextureId);
-#if 0
glXBindTexImageEXT (pWidget->pTexture->pDisplay,
pWidget->pTexture->glxpixmap,
GLX_FRONT_LEFT_EXT,
NULL);
-#endif
+
/* draw the widget */
glPushMatrix ();
glTranslatef (afPosition[X] + fOffsetX,
@@ -1055,12 +1051,10 @@
glEnd ();
glPopMatrix ();
-#if 0
glXReleaseTexImageEXT (pWidget->pTexture->pDisplay,
pWidget->pTexture->glxpixmap,
GLX_FRONT_LEFT_EXT);
-#endif
}
void
—————————end diff————————————
In order to learn the technology I took one of the examples from GtkGlExt (coolview.c)
and modified it to have two buttons floating on top of it. It is a lot less fancy but it is much shorter. if anyone is interested, please respond and I will post it.
This is the first step on the way to an application that will be implemented on an embedded board (TI omap 3430 based). I will report if it works on OpenGL-ES as well.
Thanks,
Yanir
March 1st, 2009 at 1:39 pm
Hi,
it’s possible to have a direct link to get the code, please?
I don’t use linux.
Congratulation for your works.
Best regards
Davide
March 1st, 2009 at 9:09 pm
@Davide: http://bazaar.launchpad.net/%7Emacslow/gtk-offscreen-1/trunk/files, http://bazaar.launchpad.net/%7Emacslow/gtk-gl-rgba-1/trunk/files, http://bazaar.launchpad.net/%7Emacslow/gtk-gl-offscreen-2/trunk/files, http://bazaar.launchpad.net/%7Emacslow/gtk-gl-offscreen-1/trunk/files
June 29th, 2009 at 9:10 pm
Hi, stumbled about this while looking for a way to do transparent rendering with the combination of GTK+,
gtkglext & compiz. Your old rgba-glx works perfectly on my system (debian, nVidia GeForce FX 5700LE),
but the gtk-gl-rgba example causes a BadMatch error, just like some of the other commenters noted.
A little debugging with xtrace shows that the window is correctly created using a 32-bit visual:
000:<:007a: 52: Request(1): CreateWindow depth=0×20 window=0×02c00004 parent=0×00000189 x=0 y=0 width=400 height=300 border-width=0 class=InputOutput(0×0001) visual=0×00000098 value-list={background-pixel=0×00000000 border-pixel=0×00000000 bit-gravity=NorthWest(0×01) event-mask=KeyPress,KeyRelease,ButtonPress,ButtonRelease,EnterWindow,LeaveWindow,PointerMotion,Exposure,StructureNotify,FocusChange,PropertyChange colormap=0×02c00003}
The BadMatch seems to occur at the first call to glXMakeCurrent:
000::b7:Error 8=Match: major=5, minor=144, bad=46137348
The “bad=46137348″ here is actually the window ID, 0×02c00004.
I suspect that gtkglext is picking the wrong visual and/or colormap. Any idea how to fix this,
or at least how to debug further? (And why is it working for some people, but not some others?)
June 29th, 2009 at 9:42 pm
To follow up on my own question: I got this to work (in my own program, not the demo).
The trick is to use gdk_x11_gl_config_new_from_visualid() with (the ID of) a 32-bit visual.
If I have some time tomorrow I can try to create a patch, if you’re interested.
June 29th, 2009 at 10:41 pm
I wouldn’t be able to sleep anyway without getting this over with
http://home.bawue.de/~jjk/download/gtk-gl-rgba.patch
HTH, Jens.
June 29th, 2009 at 10:46 pm
@ Jens: Ah cool, thanks for looking into this. Of course I gladly take a patch for this!
June 29th, 2009 at 11:06 pm
@ Jens: Applied to trunk. Thanks again!
September 6th, 2009 at 10:35 am
I was looking for an integration of GTK into OpenGL and very glad to stumple upon your work, the screenshots and videos look very great, thx for your work!
However I do not get the relevant examples gtk-gl-offscreen-* to run… not even with the –sync option:
$ ./gtk-gl-offscreen-2 –sync
81/149:
succeeded with visual-id check (depth 32)
red-size = 8
green-size = 8
blue-size = 8
alpha-size = 0
buffer-size = 32
stencil-size = 8
depth-size = 24
double-buffer = 1
color-buffer can be bound to rgb-texture
1D texture-target supported
rectangular texture-target supported
window drawable-type supported
pixmap drawable-type supported
pbuffer drawable-type supported
The program ‘gtk-gl-offscreen-2′ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘BadMatch (invalid parameter attributes)’.
(Details: serial 555 error_code 8 request_code 128 minor_code 22)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
September 9th, 2009 at 8:12 am
Was running into issues until I made this change (around line 567 of opengl.c in gtk-gl-offscreen-1):
g_print (” alpha-size = %2d\n”, iValue);
+if (iValue == 0)
+ continue;
I was getting a BadMatch. I guess one of the configs on the card I’m using had an alpha-size = 0 and that was throwing things off later with the call to glxCreatePixmap. Sorry if this is unclear. I definitely appreciate all of Macslow’s work! Thanks!
September 9th, 2009 at 5:25 pm
One more quick little mod to gtk-gl-offscreen-2 that helped a BadValue on my box. YMMV. For some reason my card (8800 GTS / x driver 180.51 Apr 16 2009 — not sure if that’s relevant) doesn’t seem to like multiple calls to glXBindTexImageEXT with the same glx pixmap. At least I think that’s what’s happening. Anyway, happy it’s running. Very awesome demo.
— clean/gtk-gl-offscreen-2/opengl.c 2009-09-09 09:16:09.000000000 -0700
+++ gtk-gl-offscreen-2/opengl.c 2009-09-09 09:14:21.000000000 -0700
@@ -529,6 +529,9 @@
glTexParameteri (pPixmapTexture->iTarget,
GL_TEXTURE_MAG_FILTER,
pPixmapTexture->iFilter);
+ glXReleaseTexImageEXT (pPixmapTexture->pDisplay,
+ pPixmapTexture->glxpixmap,
+ GLX_FRONT_LEFT_EXT);
return pPixmapTexture;
}