## visu_rendering visu_rendering — Methods to create and add new rendering methods. |

## Synopsis

    #define             VISU_ERROR_RENDERING
    gboolean            (*renderingFormatLoadFunc)          (VisuData *data,
                                                             const gchar *filename,
                                                             FileFormat *format,
                                                             int nSet,
                                                             GError **error);
    enum                RenderingErrorFlag;
    typedef             RenderingFormatLoad;

## Description

The way visu renders its data is done by modules. They are called rendering methods and they describes how data are drawn on the screen. Many can be defined but only one is used at a time to render the data.

One or more file type are associated with a rendering method. And a rendering method must specify the way to load the data it needs. Taking the example of a spin system representation, there are two kinds of file. The first kind describes the position the spin and the second contains their orientations.

To create a new rendering method, use `renderingMethod_new()`. The name is mandatory and must be unique. The description is not compulsory. The number of file kinds is also required. Use `renderingMethodSet_fileType()` to associated a GList of FileFormat. In our example of spin system, the first kind of file is about positions, and the associated file formats are *.ascii, *.d3 and *.xyz.

The VisuRendering_struct has to two pointers on methods that are important. The first, `createOpenGLElementFunc()` is called when V_Sim needs to create an OpenGL list corresponding to the VisuElement given as argument. This list then can be used to render each node and thus accelerating the rendering operations. The second method is `createOpenGLNodeFunc()` and is called by V_Sim for each node of the system when the main OpenGL list (the one for the nodes) is created. Thus, in the contrary of the first method, thios one should not create an OpenGL list but directly call OpenGL routines to draw the node. This method is also responsible to put the node at the right position. Use `visuDataGet_nodePosition()` to retrieve the position and translate the node accordingly.

## Details

### VISU_ERROR_RENDERING

    #define VISU_ERROR_RENDERING visuRenderingClassGet_quark()

### renderingFormatLoadFunc ()

    gboolean            (*renderingFormatLoadFunc)          (VisuData *data,
                                                             const gchar *filename,
                                                             FileFormat *format,
                                                             int nSet,
                                                             GError **error);

This is an interface for a generic load method. This method read the file positionned on `filename` and populate or change the arrays in `data`. When enter this method, the `data` argument is already allocated but its arrays may be empty and unallocated (depending on context). If the load method fails (because the format is wrong or anything else), the `data` argument should not be modified. If some errors occur, the pointer `error` will be instanciated. A VisuRendering can have several renderingFormatLoadFunc methods for each format they support. The `nSet` argument is used to load a specific set of nodes if the input format supports it. If `nSet` is 0, then the default set of nodes is loaded.

`data` : | a VisuData object ;
`filename` : | the access to the file to load ;
`format` : | a FileFormat object (can be NULL) ;
`nSet` : | an integer ;
`error` : | a pointer to store possible errors.
Returns : | FALSE if `data` is unchanged (wrong format), TRUE otherwise (even if some minor errors have happened).

### enum RenderingErrorFlag

    typedef enum
      {
        RENDERING_ERROR_METHOD,   /* Error from the rendering method. */
        RENDERING_ERROR_FILE,     /* Error when opening. */
        RENDERING_ERROR_FORMAT    /* Wrongness in format. */
      } RenderingErrorFlag;

Thiese are flags used when reading a file with a rendering method.

`RENDERING_ERROR_METHOD` | Error from the rendering method.
`RENDERING_ERROR_FILE` | Error when opening.
`RENDERING_ERROR_FORMAT` | Wrongness in format.

### RenderingFormatLoad

    typedef struct RenderingFormatLoad_struct RenderingFormatLoad;

Short way to address RenderingFormatLoad_struct objects.