Re: OpenGL support in GTK+
- From: Naofumi Yasufuku <naofumi yasufuku net>
- To: Tristan Van Berkom <vantr touchtunes com>
- Cc: Owen Taylor <otaylor redhat com>, gtk-devel-list gnome org
- Subject: Re: OpenGL support in GTK+
- Date: Tue, 23 Sep 2003 02:58:03 +0900
At Mon, 22 Sep 2003 08:27:55 -0400,
Tristan Van Berkom wrote:
>
> Naofumi Yasufuku wrote:
>
[snip]
> >
> >Basically, GdkGLExt API follows GLX 1.3 API (however, current internal
> >code uses GLX 1.2 for portability).
> >
> > X11
> > ----------------------------------------------------------------
> > Display *display;
> > Window window;
> > GLXFBConfig fbconfig;
> > GLXWindow glxwindow;
> >
> > window = XCreateWindow (display, parent, ...);
> > glxwindow = glXCreateWindow (display, fbconfig, window, NULL);
> > ----------------------------------------------------------------
> > GDK
> > ----------------------------------------------------------------
> > GdkWindow *window;
> > GdkGLConfig *glconfig;
> > GdkGLWindow *glwindow;
> >
> > window = gdk_window_new (parent, ...);
> > glwindow = gdk_gl_window_new (glconfig, window, NULL);
> > ----------------------------------------------------------------
> >
> >Programmer have to take care to keep a pair of window and glwindow, so
> >GdkGLExt library provides gdk_window_*() extension functions which
> >add OpenGL support to GdkWindow.
> >
> > ----------------------------------------------------------------
> > GdkWindow *window;
> > GdkGLConfig *glconfig;
> > GdkGLWindow *glwindow;
> >
> > window = gdk_window_new (parent, ...);
> > glwindow = gdk_window_set_gl_capability (window, glconfig, NULL);
> >
> > ....
> >
> > void a_func (GdkWindow *window)
> > {
> > GdkGLWindow *glwindow = gdk_window_get_gl_window (window);
> > }
> > ----------------------------------------------------------------
> >
> >gdk_window_set_gl_capability() creates new GdkGLWindow, then set it to
> >GdkWindow's qdata. GdkWindow supports OpenGL, and programmer can add
> >OpenGL-capability using set_gl_capability(). If GdkWindow is
> >OpenGL-capable, get_gl_window() returns GdkGLWindow. The same thing is
> >also provided for GdkPixmap and GdkGLPixmap.
> >
[snip]
Hi, Tristan. Thank you for your comments.
>
> > Programmer have to take care to keep a pair of window and glwindow, so
> > GdkGLExt library provides gdk_window_*() extension functions which
> > add OpenGL support to GdkWindow.
>
> I dont understand why the application programmer should have to manage 2
> GdkWindow's.
> Why not have a GdkGLWindow that derives from the GdkWindow and
> implements the
> GdkWindow in an OpenGL fashion ?
1. I developed GdkGL* objects to be able to use with *EXISTING* code.
If GdkGLWindow is a subclass of GdkWindow, we have to override
realize method of existing widget classes. It means that OpenGL can
be used only with widgets specialized for OpenGL.
2. I think it is hard to derive from GdkWindow. GdkWindow is not
simple new(type, properties...) style GObject in contrast with
GTK+ widgets. GdkWindow is not intended to be a base class. At
least, deriving from GdkWindow is impossible in external library
without duplicating gdkwindow-x11.c code - it will be a nightmare.
(Owen, is it right? correct me if I'm wrong.)
So GdkGLWindow is not GdkWindow (but another GdkDrawable for
convenience. In current GdkGLWindow implementation, GdkWindow is a
delegate object for GDK drawing.), and simply follows GLX 1.3 API.
>
> Could the same be done for a GdkGLGC ? (and a GdkGLConfig could be a
> delagate
> of the derived GdkGLGC ?)
I don't understand. We cannot set colormap, foreground/background
color, fill style, and so on, to the OpenGL rendering context.
GdkGLContext is not GdkGC.
Regards,
--Naofumi
>
> This way GdkGL could be integrated into Gdk without any extra mucking
> around with
> numerous drawables and extention functions, There would be little or no
> need for
> Gtk+ widgets to have a dependancy (if theese objects were implemented as
> a seperate
> library which extends gdk), And an already existant gtk+ application
> could become
> OpenGL driven after a little mucking around in the theeme engines
> (styles and gtkrc's
> etc..).
>
> basicly, if you want to know if your widget has OpenGL capability:
>
> if (GDK_IS_GLWINDOW(widget->window)) {
> /* I have a gl window */
> }
>
> I have to admit, I only sifted through this code a little (just the
> headers and a few examples)
> so maybe I missed something that makes this approach impossible but it
> seems to me to be
> the most intuitive way.
>
> Cheers,
> -Tristan
>
> PS.
> I must of overshot the subject scope, maybe this mail should be
> "OpenGL in Gtk+ implementation RFC" ?
>
>
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]