## opengl

opengl — This part is responsible for the pseudo3D rendering through OpenGl and gives methods to adapt the view.

## Synopsis

    void        openGL_reDraw                   (guint width,
                                                 guint height,
                                                 gpointer data);
    void        openGL_drawToEmpty              (guint width,
                                                 guint height,
                                                 gpointer data);

    int         setAntialias                    (int value);
    int         getAntialias                    ();
    void        setImmediateDrawing             (int bool);
    int         getImmediateDrawing             ();
    const char** openGLGet_allRenderingModesI18n
                                                ();
    void        openGLInit_context              ();
    void        setOpenGlMaterial               (float *material,
                                                 float *rgba);

    int         initOpengl                      ();

## Description

There is a last parameter which controls when render is done. There are two states : whenever a changing occurs (in fact when the OpenGLAskForReDraw signal is received) or only the OpenGLForceReDraw is received.

Except when high performances are required, this module never makes a redraw by itself, even when parameters such as the camera position are changed. The redraw must be asked by the client by emitting the OpenGLAskForReDraw signal or the OpenGLForceReDraw signal. This is to avoid situations when the client makes different changes but want just only one redraw at the end. All set methods return a boolean which informs the client of the opportunity to redraw after the set occurs. For example, if the client call a set change on theta or phi but the server returns FALSE, it means that not emission of OpenGLAskForReDraw is needed (for example because theta or phi had already these values).

## Details

### openGL_reDraw ()

    void        openGL_reDraw                   (guint width,
                                                 guint height,
                                                 gpointer data);

Basic drawing method : it clears the OpenGL area and call all lists.

`width` : | with of the OpenGL area ;
`height` : | with of the OpenGL area ;
`data` : | some user defined data.

### openGL_drawToEmpty ()

    void        openGL_drawToEmpty              (guint width,
                                                 guint height,
                                                 gpointer data);

Basic drawing method when no data is loaded: it draws the V_Sim logo.

`width` : | with of the OpenGL area ;
`height` : | with of the OpenGL area ;
`data` : | some user defined data.

### setAntialias ()

    int         setAntialias                    (int value);

To set the antialiasing on lines.

`value` : | a boolean to activate or not the lines antialias.
Returns : | TRUE if the signal OpenGLAskForReDraw should be emitted.

### getAntialias ()

    int         getAntialias                    ();

Get the value of the antialiasing parameter.

Returns : | wether or not the antialising for lines is activated.

### setImmediateDrawing ()

    void        setImmediateDrawing             (int bool);

If true all changes are applied only when the refresh button is pushed.

`bool` : | a boolean to set or not the immediateDrawing option.

### getImmediateDrawing ()

    int         getImmediateDrawing             ();

Get the value of the immediateDrawing option.

Returns : | the value of the immediateDrawing option.

### openGLGet_allRenderingModesI18n ()

    const char** openGLGet_allRenderingModesI18n
                                                ();

This function retrieve al the names (translated) of available rendering modes.

Returns : | an array of string, NULL terminated that is private (not to be freed).

### openGLInit_context ()

    void        openGLInit_context              ();

This method is called when an OpenGL surface is created for the first time. It sets basic OpenGL options and calls other OpenGLFunctions used in V_Sim.

### setOpenGlMaterial ()

    void        setOpenGlMaterial               (float *material,
                                                 float *rgba);

This method call glMaterial to create the right shiningness, emission, diffuse...

`material` : | a 5 elements array with the material properties ;
`rgba` : | a 4 elements array with the color values.

### initOpengl ()

    int         initOpengl                      ();

This initialises the drawing window and all the variables used by this module. It must be called once by the main program and should not be used otherwise.

Returns : | 1 if everything goes right.