gtk_openGLWidget

gtk_openGLWidget — defines an OpenGL capable GtkWidget.

Synopsis

                    VisuUiGlWidget;
                    VisuUiGlWidgetClass;
void                (*VisuUiGlWidgetRedrawMethod)       (VisuGlView *view,
                                                         GList *lists);
VisuUiGlWidget *    visu_ui_gl_widget_class_getCurrentContext
                                                        ();
GArray *            visu_ui_gl_widget_getPixmapData     (VisuUiGlWidget *render,
                                                         int *width,
                                                         int *height,
                                                         gboolean offScreen,
                                                         gboolean hasAlpha);
GtkWidget *         visu_ui_gl_widget_new               (gboolean contextIsDirect);
void                visu_ui_gl_widget_redraw            (VisuUiGlWidget *render);
gboolean            visu_ui_gl_widget_setCurrent        (VisuUiGlWidget *render,
                                                         gboolean force);
void                visu_ui_gl_widget_setRedraw         (VisuUiGlWidget *render,
                                                         VisuUiGlWidgetRedrawMethod method,
                                                         VisuGlView *view);
void                visu_ui_gl_widget_swapBuffers       (VisuUiGlWidget *render);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkWidget
               +----VisuUiGlWidget

Implemented Interfaces

VisuUiGlWidget implements AtkImplementorIface and GtkBuildable.

Description

This is a simple implementation of GtkGlExt to create an OpenGL surface that is a full GtkWidget. When creating such a widget, one should give then a VisuUiGlWidgetRedrawMethod() to tell the widget how to redraw itself when needed.

The current implementation is working on X11 (built-in or with GtkGlExt) and Win32.

Details

VisuUiGlWidget

typedef struct _VisuUiGlWidget VisuUiGlWidget;

Short name to address VisuUiGlWidget_struct objects.


VisuUiGlWidgetClass

typedef struct _VisuUiGlWidgetClass VisuUiGlWidgetClass;

Short name to address VisuUiGlWidgetClass_struct objects.


VisuUiGlWidgetRedrawMethod ()

void                (*VisuUiGlWidgetRedrawMethod)       (VisuGlView *view,
                                                         GList *lists);

Methods of this prototype are called when the redraw of the OpenGL zone should be done.

view :

a VisuGlView object with the camera settings.

lists :

a VisuGlExt array or NULL. [allow-none][type VisuGlExt*]

visu_ui_gl_widget_class_getCurrentContext ()

VisuUiGlWidget *    visu_ui_gl_widget_class_getCurrentContext
                                                        ();

Class routine that returns the OpenGL widget which has the current context.

Returns :

the VisuUiGlWidget with the current OpenGL context. [transfer none]

visu_ui_gl_widget_getPixmapData ()

GArray *            visu_ui_gl_widget_getPixmapData     (VisuUiGlWidget *render,
                                                         int *width,
                                                         int *height,
                                                         gboolean offScreen,
                                                         gboolean hasAlpha);

Create an image from the OpenGL area. The size can be changed, using width and height. If these pointers contains positive values, then they are used to set the size for the image. If not, the current size is used and stored in these pointers. The boolean offScreen is used to tell if the image is taken from current context or if an offscreen pixmap is created for the rendering.

render :

a VisuUiGlWidget object ;

width :

a pointer to the desired width or -1 ;

height :

a pointer to the desired height or -1 ;

offScreen :

a boolean ;

hasAlpha :

if TRUE, the returned data is RGBA, else only RGB.

Returns :

image data, row by row. [transfer full]

visu_ui_gl_widget_new ()

GtkWidget *         visu_ui_gl_widget_new               (gboolean contextIsDirect);

Create a new OpenGL area inside a GTK widget. If contextIsDirect then it tries to initialise the OpenGL context to a direct one.

contextIsDirect :

a boolean.

Returns :

a newly created widget.

visu_ui_gl_widget_redraw ()

void                visu_ui_gl_widget_redraw            (VisuUiGlWidget *render);

Force redraw on the given surface, if a redraw method have been given (see visu_ui_gl_widget_setRedraw()).

render :

a VisuUiGlWidget object.

visu_ui_gl_widget_setCurrent ()

gboolean            visu_ui_gl_widget_setCurrent        (VisuUiGlWidget *render,
                                                         gboolean force);

Make this object current. This means that all future OpenGL primitive will be rendered on this surface. If force is TRUE, the GL routine is actually called whereas in other cases, if render believe being already current, nothing is done.

render :

a VisuUiGlWidget object ;

force :

a boolean.

Returns :

TRUE if succeed.

visu_ui_gl_widget_setRedraw ()

void                visu_ui_gl_widget_setRedraw         (VisuUiGlWidget *render,
                                                         VisuUiGlWidgetRedrawMethod method,
                                                         VisuGlView *view);

This method is used to defined a redraw method for the OpenGL area. By doing this the area will automatically redraw itself when necessary. Before doing it it calls visu_ui_gl_widget_setCurrent(), and after it calls visu_ui_gl_widget_swapBuffers().

render :

a VisuUiGlWidget object ;

method :

a redraw method ;. [scope call]

view :

the VisuGlView object.

visu_ui_gl_widget_swapBuffers ()

void                visu_ui_gl_widget_swapBuffers       (VisuUiGlWidget *render);

Swap the buffers of the OpenGL area.

render :

a VisuUiGlWidget object.