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

Load fpg

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 15:22, 17 May 2007 (edit)
G105b (Talk | contribs)
(Notes)
← Previous diff
Current revision (22:17, 25 July 2007) (edit) (undo)
Sandman (Talk | contribs)
m
 
(2 intermediate revisions not shown.)
Line 3: Line 3:
==Definition== ==Definition==
-'''INT''' load_fpg ( <'''STRING''' file> )+'''INT''' load_fpg ( <'''STRING''' filename> )
Loads a graphics library into your program. Loads a graphics library into your program.
-This function loads the whole contents of a [[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.+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.
== Parameters == == Parameters ==
{| {|
-| '''STRING''' file || - The file name of the FPG that you wish to load (including extension).+| '''STRING''' filename || - The filename of the FPG that you wish to load (including extension and possible path).
|} |}
== Returns == == Returns ==
-'''INT''' : A numerical identifier for the FPG file.+'''INT''' : [[FileID]]
 +{|
 +| -1 || - The specified archive could not be loaded.
 +|-
 +| >=0 || - The [[FileID]] assigned to the archive.
 +|}
 + 
 +== Errors ==
 +{|
 +| Archive not found || - The specified archive could not be found.
 +|}
== Notes == == 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 an ID starting at 1000, this is because Fenix pre-allocates room for the first FPG loaded (FPG files can contain 999 different graphics max.), sometimes referred to as the environment FPG.+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 pre-allocated by Fenix for use as the environment FPG. All extra FPG files loaded will have a different FileID, progressing from 1 upwards.+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. 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 loaded within Fenix, even at the termination of a program. Fenix always releases all used memory at the end of program execution.+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.
== Example == == Example ==
Line 30: Line 40:
Program example; Program example;
Global Global
- my_fpg;+ int my_fpg;
Begin Begin
my_fpg=load_fpg("test.fpg"); //Loads the FPG file into memory my_fpg=load_fpg("test.fpg"); //Loads the FPG file into memory
put_screen(my_fpg,1); //Puts graphic with code 1 onto screen put_screen(my_fpg,1); //Puts graphic with code 1 onto screen
- Loop+ Repeat
frame; frame;
- End+ Until(key(_esc))
 + unload_fpg(my_fpg);
End End
</pre> </pre>
 +Used in example: [[put_screen]](), [[unload_fpg]]()

Current revision


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