DEMO version ! After registering you will receive a complete version.
Description
This function sets the right video mode.
This mode switching is fundamental to the operation of Ferns' Graphics
Library because it also sets all the internal variables.
If called with no parameters, this function will return information about
the current mode.
If you call the function with a negative Modenum value, the function checks
if the mode is available.
For a list of the available modes, see "About Ferns' Graphics Library";
"Different Modes".
Syntax
FGLSetMode([ Modenum ]) -> OldmodeArray.
[ Modenum ] : The desired (graphic) mode. See "About Ferns' Graphics
Library";"Different Modes".
Return value
This function returns information about the old graphic mode when [ Modenum ]
is passed as parameter, or information about the current mode when no
parameter is passed.
The OldmodeArray has the following meaning :
OldmodeArray[_OPTION_], where _OPTION_ can be (defined in fgl.ch) :
FGL_MODE_TEXT_ROW = Number of text rows.
FGL_MODE_TEXT_COL = Number of text colomns.
FGL_MODE_GRAPH_MAXY = Number of pixels on a graphical scanline-1.
So in 640x480 mode, this option returns 639.
FGL_MODE_GRAPH_MAXX = Number of graphical scanlines-1.
So in 640x480 mode, this option returns 479.
FGL_MODE_FONT_HEIGHT = Fontheight.
FGL_MODE_FONT_WIDTH = FontWidth.
FGL_MODE_NUMCOLORS = Number of bits used to represent a color in
the current mode. 2[this value] gives the number
of available colors.
Possible values are : 4,8,15 or 16.
FGL_MODE_IN_USE = Mode in use. The value of the current mode that is
set (the mode used with FGLSetMode()).
FGL_MODE_GRAPHIC = Graphic mode or not.
FGL_TEXT if textmode.
FGL_GRAPH if graphic mode.
FGL_MODE_FOREGROUND = Last color setting for the foreground color for
standard output (output which is done via the GT).
This color setting is only relevant in graphic
mode.
FGL_MODE_BACKGROUND = Last color setting for the background color for
standard output (output which is done via the GT).
This color setting is only relevant in graphic
mode.
If the mode is not available, the function will return NIL.
Advanced features
Just like with Light Lib Graphics it is possible to test if a mode is
available. The mode doesn't switch to it. You can test for the availability
of a mode by calling FGLSetMode with the negative value of the mode number.
If the mode is available, you will get an array with 7 elements. These
seven elements are the same as the first seven elements of the OldmodeArray,
which is returned if you try to switch to a mode (so FGL_MODE_IN_USE,
FGL_MODE_GRAPHIC, FGL_MODE_BACKGROUND and FGL_MODE_FOREGROUND aren't
available).
If the mode is not available, you will get the NIL value as return.
This special feature allows you to check available modes before to try to
switch to them.
Example
#include "fgl.ch"
local mode;
// Test if we have VGA.
IF (FGLSetMode(-FGL_GRAPHICS_640_480_16) == NIL)
? "You'll have to have at least VGA to execute this program"
QUIT
ENDIF
mode := FGL_GRAPHICS_640_480_16
IF (FGLSetMode(-FGL_GRAPHICS_640_480_256) != NIL)
mode := FGL_GRAPHICS_640_480_256
ENDIF
// Right, now safely switch to 16 or 256 color mode.
FGLSetMode(mode)
// begin your program here...