Fpg load

From Bennu Wiki
Jump to: navigation, search


Definition

INT fpg_load ( <STRING filename>, [<INT POINTER> complete>] )

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.

The previous name load_fpg() is deprecated.

Parameters

STRING filename - The filename of the FPG that you wish to load (including extension and possible path).
[INT POINTER complete] - If this argument is specified the FPG is loaded asynchroneous, setting complete to FileID on completion.

Returns

INT : graphID

-2 - Waiting for the file to be loaded, see notes.
-1 - There was an error loading the file.
>=0 - The FileID assigned to the archive.


the following applies for versions prior rc282:

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

Using an FPG file to contain all or some of the graphics used in a Bennu 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 mod_map 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 using mod_map returns and uses the FileID 0, which is reserved by mod_map 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 cause a slowdown.

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 Bennu always releases all used memory at the end of program execution.


Notes

The optional parameter id was introduced in version rc282 and allows you to load resources in the background. It used with the Offset operator. See example below:

     load_fpg("archivo_gordo.fpg", &idFpg);
      while(idFpg==-2)
            say("Big File Loading ....");
            frame;
      end
      if(idFpg==-1)
          say("Something went wrong!!");
          exit(); // o return
      end

      say("Big file loaded ok!!");

      file=idFpg;

      graph = 7;


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()


Mod_map
Globals None
Imported:
FullscreenGraphmodeM7ScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants BCLEARCHARSETCP850CHARSETISO8859GANIMATIONSPEEDGANIMATIONSTEPGANIMATIONSTEPSGCENTERXGCENTERYGDEPTHGFRAMESGHEIGHTGPITCHGWIDEGWIDTHGXCENTERGYCENTERNFBFIXEDWIDTHNFBVARIABLEWIDTH
Imported:
BABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOW
Functions Bdfload()Centerset()Colorfind()Colorsget()Colorsset()Fade()Fadeoff()Fadeon()Fntload()Fntnew()Fntsave()Fntunload()Fpgadd()Fpgdel()Fpgexists()Fpgload()Fpgnew()Fpgsave()Fpgunload()Getpixel()Glyphget()Glyphset()Graphicinfo()Graphicset()Mapblockcopy()Mapbuffer()Mapclear()Mapclone()Mapdel()Mapexists()Mapgetpixel()Mapinfo()Mapinfoget()Mapinfoset()Mapload()Mapname()Mapnew()Mapput()Mapputpixel()Mapsave()Mapsetname()Mapunload()Mapxput()Mapxputnp()Palclone()Paldel()Palget()Palload()Palmapassign()Palmapgetid()Palmapremove()Palnew()Palrefresh()Palsave()Palset()Palunload()Paletteconvert()Paletteroll()Pcxload()Pngload()Pngsave()Pointget()Pointset()Putpixel()Rgb()Rgbget()Rgba()Rgbaget()