## gtk_openGLWidget

gtk_openGLWidget — defines an OpenGL capable GtkWidget.

## Synopsis

                        OpenGLWidget;
                        OpenGLWidgetClass;
    void                (*RedrawMethod)                     (const char **lists,
                                                             VisuData *data);
    #define             TYPE_OPENGL_WIDGET
    #define             OPENGL_WIDGET                       (obj)
    #define             OPENGL_WIDGET_CLASS                 (obj)
    #define             IS_OPENGL_WIDGET                    (obj)
    #define             IS_OPENGL_WIDGET_CLASS              (obj)
    #define             OPENGL_WIDGET_GET_CLASS             (obj)
    GType               openGLWidget_get_type               (void);
    GtkWidget*          openGLWidgetNew                     (gboolean contextIsDirect);
    gboolean            openGLWidgetSet_current             (OpenGLWidget *render,
                                                             gboolean force);
    void                openGLWidgetSet_redraw              (OpenGLWidget *render,
                                                             RedrawMethod method,
                                                             VisuData *data);
    void                openGLWidgetRedraw                  (OpenGLWidget *render);
    void                openGLWidgetSwap_buffers            (OpenGLWidget *render);
    GArray*             openGLWidgetGet_pixmapData          (OpenGLWidget *render,
                                                             int *width,
                                                             int *height,
                                                             gboolean offScreen,
                                                             gboolean hasAlpha);
    OpenGLWidget*       openGLWidgetClassGet_currentContext ();

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----OpenGLWidget

## Implemented Interfaces

OpenGLWidget 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 `RedrawMethod()` 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

### OpenGLWidget

    typedef struct _OpenGLWidget OpenGLWidget;

Short name to address OpenGLWidget_struct objects.

### OpenGLWidgetClass

    typedef struct _OpenGLWidgetClass OpenGLWidgetClass;

Short name to address OpenGLWidgetClass_struct objects.

### RedrawMethod ()

    void                (*RedrawMethod)                     (const char **lists,
                                                             VisuData *data);

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

`lists` : | a string array, NULL terminated.
`data` : | the VisuData to draw.

### TYPE_OPENGL_WIDGET

    #define TYPE_OPENGL_WIDGET           (openGLWidget_get_type())

The type of OpenGLWidget objects.

### OPENGL_WIDGET()

    #define             OPENGL_WIDGET(obj)

Cast `obj` to OpenGLWidget if possible.

`obj` : | a pointer.

### OPENGL_WIDGET_CLASS()

    #define             OPENGL_WIDGET_CLASS(obj)

Cast `obj` to OpenGLWidgetClass if possible.

`obj` : | a pointer.

### IS_OPENGL_WIDGET()

    #define             IS_OPENGL_WIDGET(obj)

Return TRUE is `obj` is an OpenGLWidget object (or inherit from).

`obj` : | a pointer.

### IS_OPENGL_WIDGET_CLASS()

    #define             IS_OPENGL_WIDGET_CLASS(obj)

Return TRUE is `obj` is an OpenGLWidgetClass object (or inherit from).

`obj` : | a pointer.

### OPENGL_WIDGET_GET_CLASS()

    #define             OPENGL_WIDGET_GET_CLASS(obj)

Return the class of the given OpenGLWidget object.

`obj` : | a pointer.

### openGLWidget_get_type ()

    GType               openGLWidget_get_type               (void);

Retrive the type of OpenGLWidget objects.

Returns : | the id used by OBjects for OpenGLWidget objects.

### openGLWidgetNew ()

    GtkWidget*          openGLWidgetNew                     (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.

### openGLWidgetSet_current ()

    gboolean            openGLWidgetSet_current             (OpenGLWidget *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 OpenGLWidget object ;
`force` : | a boolean.
Returns : | TRUE if succeed.

### openGLWidgetSet_redraw ()

    void                openGLWidgetSet_redraw              (OpenGLWidget *render,
                                                             RedrawMethod method,
                                                             VisuData *data);

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 `openGLWidgetSet_current()` ; and after it calls `openGLWidgetSwap_buffers()`.

`render` : | a OpenGLWidget object ;
`method` : | a redraw method ;
`data` : | the VisuData to draw.

### openGLWidgetRedraw ()

    void                openGLWidgetRedraw                  (OpenGLWidget *render);

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

`render` : | a OpenGLWidget object.

### openGLWidgetSwap_buffers ()

    void                openGLWidgetSwap_buffers            (OpenGLWidget *render);

Swap the buffers of the OpenGL area.

`render` : | a OpenGLWidget object.

### openGLWidgetGet_pixmapData ()

    GArray*             openGLWidgetGet_pixmapData          (OpenGLWidget *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 OpenGLWidget 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.

### openGLWidgetClassGet_currentContext ()

    OpenGLWidget*       openGLWidgetClassGet_currentContext ();

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

Returns : | the OpenGLWidget with the current OpenGL context.