## opengl

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

## Synopsis

    void                openGLSet_color                     (float *material,
                                                             float *rgba);
    void                openGLSet_highlightColor            (float material[5],
                                                             float rgb[3],
                                                             float alpha);
    void                initOpengl                          ();
    void                initOpenglGraphics                  ();
    LightEnvironnement* openGLGet_currentLights             ();
    int                 openGLSet_antialias                 (int value);
    int                 openGLGet_antialias                 ();
    void                openGLSet_immediate                 (int bool);
    int                 openGLGet_immediate                 ();
    gboolean            openGLSet_trueTransparency          (gboolean status);
    gboolean            openGLGet_trueTransparency          ();
    gboolean            openGLSet_stereoAngle               (float angle);
    float               openGLGet_stereoAngle               ();
    gboolean            openGLGet_stereoCapability          ();
    void                openGLSet_stereo                    (gboolean status);
    gboolean            openGLGet_stereo                    ();
    void                openGL_reDraw                       (const char **lists,
                                                             VisuData *data);
    void                openGLInit_context                  ();

## 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

### openGLSet_color ()

    void                openGLSet_color                     (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.

### openGLSet_highlightColor ()

    void                openGLSet_highlightColor            (float material[5],
                                                             float rgb[3],
                                                             float alpha);

This method try to set a colour that will contrast with `rgb`.

`material` : | a 5 elements array with the material properties ;
`rgb` : | a 3 elements array with the color values.
`alpha` : | the alpha channel.

### initOpengl ()

    void                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.

### initOpenglGraphics ()

    void                initOpenglGraphics                  ();

Internal use only. Call at startup to call OpenGL initialisation routines.

Since 3.6

### openGLGet_currentLights ()

    LightEnvironnement* openGLGet_currentLights             ();

V_Sim proposes a wrapper around the OpenGL light definitions.

Returns : | the set of current lights.

### openGLSet_antialias ()

    int                 openGLSet_antialias                 (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.

### openGLGet_antialias ()

    int                 openGLGet_antialias                 ();

Get the value of the antialiasing parameter.

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

### openGLSet_immediate ()

    void                openGLSet_immediate                 (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.

### openGLGet_immediate ()

    int                 openGLGet_immediate                 ();

Get the value of the immediateDrawing option.

Returns : | the value of the immediateDrawing option.

### openGLSet_trueTransparency ()

    gboolean            openGLSet_trueTransparency          (gboolean status);

If true the rendering is done twice to respect the transparency.

`status` : | a boolean.
Returns : | TRUE if redraw should be done.

### openGLGet_trueTransparency ()

    gboolean            openGLGet_trueTransparency          ();

The drawing can be done in one pass or two to respect transparency.

Returns : | TRUE if the drawing is done twice.

### openGLSet_stereoAngle ()

    gboolean            openGLSet_stereoAngle               (float angle);

Change the angle of the eyes in the stereo output.

`angle` : | a positive floating point value.
Returns : | TRUE if redraw should be done.

### openGLGet_stereoAngle ()

    float               openGLGet_stereoAngle               ();

Retrieve the angle of the eyes in the stereo output.

Returns : | the angle.

### openGLGet_stereoCapability ()

    gboolean            openGLGet_stereoCapability          ();

Retrieve if the OpenGL window can render in stereo or not.

Returns : | TRUE if the OpenGL surface can draw in stereo.

### openGLSet_stereo ()

    void                openGLSet_stereo                    (gboolean status);

Change the type of rendering. The surface can be switch to stereo, only if the OpenGL has stereo capabilities (see `openGLGet_stereoCapability()`).

`status` : | a boolean.

### openGLGet_stereo ()

    gboolean            openGLGet_stereo                    ();

Retrieve the status of the OpenGL surface.

Returns : | TRUE if the surface try to draw in stereo (may be TRUE, even if `openGLGet_stereoCapability()` returns FALSE, in that case the stereo capability is not used).

### openGL_reDraw ()

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

Basic drawing method : it clears the OpenGL area and call all lists if `lists` is NULL, or draw only the given lists.

`lists` : | a string array, NULL terminated.. array zero-terminated=1. allow-none zero-terminated=1.
`data` : | the VisuData to redraw.

### 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.