Re: OpenGL, GtkGlArea, GtkGLExt




On Tue, 2008-03-04 at 19:37 +0000, Jon Harrop wrote:

2) change the name, for example to Gtkglarea 2.0*, the legitimate
sucessor to Gtkglarea 1 (the last version of Gtkglarea that I downloaded
last week is 1.99 and still comes with gtk_signal_connect and other Gtk
1.2* functions deprecated long ago)

No, gtkglarea is dead.

GlArea still has many users and is the defacto standard for some languages.

it may have many users, but it's unmaintained, so it is ipso facto
"dead".

We don't want a new widget.  We want being able 
to render to widgets using OpenGL as an alternative to using cairo.
That is, the GtkGlExt approach.

I'm not sure who you are referring to as "we" but many people need little 
beyond GlArea. I have no desire to create Gtk-compatible widgets. I only want 
to render general graphics quickly and easily using OpenGL.

on the bug linked in the thread, and in many gtk+ developers team
meetings it was reached a consensus for an integration towards a
cairo-style approach: inside the ::expose-event handlers you can
retrieve a GL context, draw on it using the GL API and the result will
be rendered on the widget's window.

that's what "we" means.

If anyone is interested in improving the situation for scientists and 
engineers then I would recommend taking this into account: keep it simple to 
bind.

you can't really get much simpler than a:

  GLXContext gl_context;

  gl_context = gdk_glx_create_context (GDK_DRAWABLE (widget->window));

or, since it should be portable across various backends:

static gboolean
widget_expose (GtkWidget      *widget,
               GdkExposeEvent *event)
{
  GdkGLContext *gl_context;

  /* creates or returns the (backend-dependent) GL context, which is
   * made current to the widget's GdkWindow - for instance, on GLX it
   * will create a context if not already present, and will call
   * glXMakeCurrent() for the display and window.
   */
  gl_context = gdk_gl_create_context (GDK_DRAWABLE (widget->window));

  /* ... draw using GL API ... */

  /* retrieve the platform-dependent implementation for mad crack */
  GLXContext glx_context = GDK_GLX_CONTEXT (gl_context);

  /* waits for vblank, calls glXSwapBuffers(), and unrefs the
   * GdkGLContext - but it does not destroy it.
   */
  g_object_unref (gl_context);
}

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]