This wiki is out of date, use the continuation of this wiki instead

Load fpg

From FenixWiki

Jump to: navigation, search


Contents

[edit] Definition

INT load_fpg ( <STRING filename> )

Loads a graphics library into your program.

This function loads the whole contents of an FPG graphics library into your project, enabling the contained graphics to be used in your program as process' graphs, screen backgrounds (put_screen()) or other graphics.

[edit] Parameters

STRING filename - The filename of the FPG that you wish to load (including extension and possible path).

[edit] Returns

INT : FileID

-1 - The specified archive could not be loaded.
>=0 - The FileID assigned to the archive.

[edit] Errors

Archive not found - The specified archive could not be found.

[edit] Notes

Using an FPG file to contain all or some of the graphics used in a Fenix program is convenient, but isn't always the best way to load graphics. Other methods of loading graphics into your program include load_map() and load_png() which load individual graphic files. Graphics loaded individually will be given FileID 0 and a GraphID starting at 1000. This is because Fenix reserves room for the first FPG loaded (FPG files can contain 999 different graphics max.), sometimes referred to as the system file or environment file.

The first FPG file loaded into a Fenix program returns and uses the FileID 0, which is reserved by Fenix for use as the system file. All extra FPG files loaded will have a different FileID, progressing from 1 upwards.

An FPG file holds all its contained graphs in memory simultaneously. Having a lot of large graphs being read from a single FPG file at once has been known to slow down Fenix programs.

Once an FPG file is no longer necessary to be held in the memory, its memory space can be released by using the function unload_fpg(). It is not necessary to unload files at the termination of a program, as Fenix always releases all used memory at the end of program execution.

[edit] Example

Program example;
Global
    int my_fpg;
Begin
    my_fpg=load_fpg("test.fpg");   //Loads the FPG file into memory
    put_screen(my_fpg,1);          //Puts graphic with code 1 onto screen
    Repeat
        frame;
    Until(key(_esc))
    unload_fpg(my_fpg);
End

Used in example: put_screen(), unload_fpg()

Personal tools