Re: [GtkGLExt] off-screen rendering



Hmm, this looks like the code I use. It works fine with nvidia cards (my
two machines have nvidia cards), but crashes with others, apparently,
see http://bugs.debian.org/452939.

Thanks for the answer. I think I'll use OSMesa instead.

Jean

Le vendredi 30 novembre 2007 à 17:16 +0100, Christophe Dehais a écrit :
> Hi Jean,
> 
> You can use a GdkPixmap as the "support" for offline rendering (thus
> no window at all need to be opened).
> With the combo Nvidia card/proprietary drivers, direct rendering
> contexts (ie accelerated) are available for GdkPixmap. I don't know
> how well this works with other cards and drivers.
> 
> I use the following function that returns a GdkGLDrawable * wrapping a
> GdkDrawable of the specified size:
> 
> GdkGLDrawable * init_offline_context (int width, int height)
> {
> 
>     GdkGLConfig *glconfig;
>     GdkPixmap *pixmap;
>     GdkGLPixmap *glpixmap;
>     GdkGLContext *context;
>     g_print ("configuring GL viewport\n");
> 
>     /* try double-buffered visual */
>     glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA |
>                                           GDK_GL_MODE_DEPTH |
>                                           GDK_GL_MODE_DOUBLE);
>     if (glconfig == NULL) {
>       g_print ("*** Cannot find the double-buffered visual.\n");
>       g_print ("*** Trying single-buffered visual.\n");
> 
>       /* try single-buffered visual */
>       glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA   |
>                                             GDK_GL_MODE_DEPTH);
>       if (glconfig == NULL) {
>           g_print ("*** No appropriate OpenGL-capable visual found.\n");
>           exit (EXIT_FAILURE);
>         }
>     }
> 
>     pixmap = gdk_pixmap_new (NULL, width, height, 24);
>     if (pixmap == NULL) {
>         g_print ("*** Could not create the GdkPixmap\n");
>         exit (EXIT_FAILURE);
>     }
>     glpixmap = gdk_pixmap_set_gl_capability (pixmap, glconfig, NULL);
>     if (glpixmap == NULL) {
>         g_print ("*** Could not create the GdkGLPixmap\n");
>         exit (EXIT_FAILURE);
>     }
> 
>     context = gdk_gl_context_new (GDK_GL_DRAWABLE (glpixmap), NULL,
> TRUE, GDK_GL_RGBA_TYPE);
>     if (context == NULL) {
>         g_print ("*** Could not create a direct context for the pixmap\n");
>         exit (EXIT_FAILURE);
>     }
> 
>     if (!gdk_gl_drawable_make_current (GDK_GL_DRAWABLE (glpixmap), context)) {
>         g_print ("*** Could not attach the context to the pixmap\n");
>         exit (EXIT_FAILURE);
>     }
> 
>     return GDK_GL_DRAWABLE (glpixmap);
> }
> 
> Then something like this in my main() does what I need:
> 
>     context = gdk_gl_context_get_current();
>     if (!gdk_gl_drawable_gl_begin (pixmap, context)) {
>         printf ("*** problem beginning OpenGL operations\n");
>         return 0;
>     }
>     printf ("Direct rendering ?: %d\n", gdk_gl_context_is_direct (context));
> 
>     do_some_processing_or_drawing_using_opengl ();
> 
>     gdk_gl_drawable_gl_end (pixmap);
> 
> 
> hope this helps,
> Christophe
> 
> 
> On Nov 30, 2007 4:40 PM, Jean Bréfort <jean brefort normalesup org> wrote:
> > Hi,
> >
> > Does anybody knows if and how it is possible to do off-screen rendering
> > using gtkglext? I tested using a pixbuf as a drawable, but seems it
> > crashes during gdk_gl_drawable_gl_begin with some video cards.
> >
> > Best regards,
> > Jean Brefort
> >
> > _______________________________________________
> > gtkglext-list mailing list
> > gtkglext-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkglext-list
> >
> 



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