## visu_dump

visu_dump — Some resources to add the ability to export the rendered data to an other format (usually image format).

## Synopsis

    gboolean            (*VisuDumpWriteFunc)                (FileFormat *format,
                                                             const char *fileName,
                                                             int width,
                                                             int height,
                                                             VisuData *dataObj,
                                                             guchar *image,
                                                             GError **error,
                                                             voidDataFunc functionWait,
                                                             gpointer data);
    DumpType*           (*VisuDumpInitFunc)                 ();
    enum                DumpErrorFlag;
    GList*              visuDumpGet_allModules              ();
    int                 visuDumpGet_nModules                ();
    void                visuDumpAbort                       (GObject *obj,
                                                             gpointer data);

    int                 visuDumpInit                        ();

## Description

V_Sim can export loaded data to othe formats. This module descibes the methods and structure to create a dumping extension. Basically, a dumping extension is just a FileFormat and a method that is called when exporting is required. No method exists to create a dumping extension, just allocate and initialize the DumpType structure.

The writeDumpFunc should suspend its process to allow the calling program to refresh itself if the dump process is slow. Ideally, the argument `waitFunction` should be called exactly 100 times.

## Details

### VisuDumpWriteFunc ()

    gboolean            (*VisuDumpWriteFunc)                (FileFormat *format,
                                                             const char *fileName,
                                                             int width,
                                                             int height,
                                                             VisuData *dataObj,
                                                             guchar *image,
                                                             GError **error,
                                                             voidDataFunc functionWait,
                                                             gpointer data);

This is a prototype of a method implemented by a dumping extension that is called when the current rendering must be dumped to a file.

`format` : | a FileFormat object, corresponding to the write method ;
`fileName` : | a string that defined the file to write to ;
`width` : | an integer ;
`height` : | an integer.
`dataObj` : | the VisuData to be exported ;
`image` : | the data to be written ;
`error` : | a location to store some error (not NULL) ;
`functionWait` : | a method to call periodically during the dump ;
`data` : | some pointer on object to be passed to the wait function.
Returns : | TRUE if everything went right.

### VisuDumpInitFunc ()

    DumpType*           (*VisuDumpInitFunc)                 ();

This protoype defines initializing function for dumping extension. Create such a funcction an add its name in the list listInitDumpModuleFunc defined in dumpModules/externalDumpModules.h thus the new dumping extension will be initialized on startup.

Returns : | a newly allocated DumpType.

### enum DumpErrorFlag

    typedef enum
      {
        DUMP_ERROR_OPENGL,
        DUMP_ERROR_FILE,
        DUMP_ERROR_ENCODE
      } DumpErrorFlag;

These are flags used when dumping to a file.

`DUMP_ERROR_OPENGL` | Error with OpenGL dumping.
`DUMP_ERROR_FILE` | Error when opening.
`DUMP_ERROR_ENCODE` | Wrongness when computing the encoding format.

### visuDumpGet_allModules ()

    GList*              visuDumpGet_allModules              ();

All dumping extensions are stored in an opaque way in V_Sim. But they can be listed by a call to this method.

Returns : | a list of all the known dumping extensions. This list is own by V_Sim and should be considered read-only.

### visuDumpGet_nModules ()

    int                 visuDumpGet_nModules                ();

A convenient way to know how many dumping extensions are registered.

Returns : | the number of known dumping extensions.

### visuDumpAbort ()

    void                visuDumpAbort                       (GObject *obj,
                                                             gpointer data);

Does nothing for the moment.

`obj` : | an object ;
`data` : | some data.

### visuDumpInit ()

    int                 visuDumpInit                        ();

This method is used to initialized the system of dumping extension. It should not be called after startup process is finished.

Returns : | 0 if everything ran smoothly.