Revision history for FaqPggfxlib2


Revision [20801]

Last edited on 2016-03-12 14:10:45 by fxm [Formatting]

No Differences

Revision [20009]

Edited on 2016-02-10 15:52:24 by DkLwikki [Update link format]
Additions:
Gfxlib is "built in" into the language, it is not necessary to include any .bi file or to link any library explicitly. ""FreeBASIC"" detects you want to use Gfxlib when you use the [[KeyPgScreengraphics|Screen]] or [[KeyPgScreenres|Screenres]] statements. So to use Gfxlib, just start a graphics screen mode and use the graphics commands.
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. It contains the constants for the mode flags that can be passed to [[KeyPgScreengraphics|Screen]] and [[KeyPgScreenres|Screenres]], and also definitions of [[GfxScancodes|Keyboard scancodes]] and the [[GfxInternalFormats|fb.Image buffer structure]].
Bsave/Bload can only be used to load and save graphics screens in ""FreeBASIC"". It can't be used to save a text mode screen. To load and save an array check this [[FaqPgbloadworkaround|snippet using file Get/Put]] .
In windowed graphics mode you can test for the press of the window's X (close) button with ##[[KeyPgInkey|Inkey]]##, checking for the value Chr( 255 ) + "k" (which is also the code returned for Alt+F4). This applies to ""Win32"" and Linux, in DOS there is no "X" button.
[[KeyPgImagecreate|Imagecreate]] needs to create an image buffer that fits the current screen's pixel format, and it cannot do so if there is no screen mode setup yet, so it returns NULL, very likely resulting in a NULL pointer access later on that crashes the program.
This is known to happen when Imagecreate is called //before// the graphics library was initialized with a call to [[KeyPgScreengraphics|Screen]] or [[KeyPgScreenres|Screenres]], as may happen when Imagecreate is called in a global constructor that is invoked before the Screen or Screenres call in the main part of the program. In such a case it is necessary to move the screen initialization into a constructor too, and have it execute before the image-creating constructors.
- [[CompilerFAQ|Compiler FAQ]]
- [[FaqPgrtlib|FB Runtime Library FAQ]]
- [[FaqPggfxlib2|Frequently Asked FreeBASIC Graphics Library Questions]]
Deletions:
Gfxlib is "built in" into the language, it is not necessary to include any .bi file or to link any library explicitly. ""FreeBASIC"" detects you want to use Gfxlib when you use the [[KeyPgScreengraphics Screen]] or [[KeyPgScreenres Screenres]] statements. So to use Gfxlib, just start a graphics screen mode and use the graphics commands.
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. It contains the constants for the mode flags that can be passed to [[KeyPgScreengraphics Screen]] and [[KeyPgScreenres Screenres]], and also definitions of [[GfxScancodes Keyboard scancodes]] and the [[GfxInternalFormats fb.Image buffer structure]].
Bsave/Bload can only be used to load and save graphics screens in ""FreeBASIC"". It can't be used to save a text mode screen. To load and save an array check this [[FaqPgbloadworkaround snippet using file Get/Put]] .
In windowed graphics mode you can test for the press of the window's X (close) button with ##[[KeyPgInkey Inkey]]##, checking for the value Chr( 255 ) + "k" (which is also the code returned for Alt+F4). This applies to ""Win32"" and Linux, in DOS there is no "X" button.
[[KeyPgImagecreate Imagecreate]] needs to create an image buffer that fits the current screen's pixel format, and it cannot do so if there is no screen mode setup yet, so it returns NULL, very likely resulting in a NULL pointer access later on that crashes the program.
This is known to happen when Imagecreate is called //before// the graphics library was initialized with a call to [[KeyPgScreengraphics Screen]] or [[KeyPgScreenres Screenres]], as may happen when Imagecreate is called in a global constructor that is invoked before the Screen or Screenres call in the main part of the program. In such a case it is necessary to move the screen initialization into a constructor too, and have it execute before the image-creating constructors.
- [[CompilerFAQ Compiler FAQ]]
- [[FaqPgrtlib FB Runtime Library FAQ]]
- [[FaqPggfxlib2 Frequently Asked FreeBASIC Graphics Library Questions]]


Revision [16835]

Edited on 2013-06-15 02:01:53 by DoS386 [kicked obsolete note]
Deletions:
Note: If you use an old version of ""FreeBASIC"", you may have to use Chr( 255 ) + "X".


Revision [15285]

Edited on 2011-10-01 07:05:03 by CountingPine [Mention chr(255)+"k" in text; remove some CamelCase links]
Additions:
In windowed graphics mode you can test for the press of the window's X (close) button with ##[[KeyPgInkey Inkey]]##, checking for the value Chr( 255 ) + "k" (which is also the code returned for Alt+F4). This applies to ""Win32"" and Linux, in DOS there is no "X" button.
It's a hardware/driver limitation (""Win32"" and Linux only?). Video cards don't implement those low resolution graphic modes nowadays. If full-screen is required you should rewrite it using at least Screen 17 or 18, or a resolution of 640x480 or higher to be sure modern hardware can handle it.
Deletions:
In windowed graphics mode you can test for the press of the window's X (close) button with ##[[KeyPgInkey Inkey]]##. This applies to Win32 and Linux, in DOS there is no "X" button.
It's a hardware/driver limitation (Win32 and Linux only?). Video cards don't implement those low resolution graphic modes nowadays. If full-screen is required you should rewrite it using at least Screen 17 or 18, or a resolution of 640x480 or higher to be sure modern hardware can handle it.


Revision [15277]

Edited on 2011-09-30 14:33:30 by DkLwikki [Add <Why does Imagecreate return NULL?>]
Additions:
**""FreeBASIC"" Graphics Library questions:**
==- {{anchor name="item3|How are Get/Put arrays managed?"}}==
==- {{anchor name="item4|Why is Bsave/Bload crashing?"}}==
==- {{anchor name="item7|Can't run programs using Screen 13 or 14 in fullscreen !"}}==
==- {{anchor name="item8|Why does Imagecreate return a NULL pointer?"}}==
@@**""FreeBASIC"" Graphics Library questions**@@
Gfxlib is "built in" into the language, it is not necessary to include any .bi file or to link any library explicitly. ""FreeBASIC"" detects you want to use Gfxlib when you use the [[KeyPgScreengraphics Screen]] or [[KeyPgScreenres Screenres]] statements. So to use Gfxlib, just start a graphics screen mode and use the graphics commands.
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. It contains the constants for the mode flags that can be passed to [[KeyPgScreengraphics Screen]] and [[KeyPgScreenres Screenres]], and also definitions of [[GfxScancodes Keyboard scancodes]] and the [[GfxInternalFormats fb.Image buffer structure]].
{{anchor name="item3"}}==How are Get/Put arrays managed?==
In ""FreeBASIC"", images can be used as arrays (as in QB) or as pointers. Either way, the image data is contained in one continuous chunk. The chunk consists of an header followed by the image data. The header can be of two types (old-style and new-style) and determines the format of the following image data, for details see [[GfxInternalFormats]] .
{{anchor name="item4"}}==Why is Bsave/Bload crashing?==
Bsave/Bload can only be used to load and save graphics screens in ""FreeBASIC"". It can't be used to save a text mode screen. To load and save an array check this [[FaqPgbloadworkaround snippet using file Get/Put]] .
Note: If you use an old version of ""FreeBASIC"", you may have to use Chr( 255 ) + "X".
{{anchor name="item7"}}==Can't run programs using Screen 13 or 14 in full-screen!==
It's a hardware/driver limitation (Win32 and Linux only?). Video cards don't implement those low resolution graphic modes nowadays. If full-screen is required you should rewrite it using at least Screen 17 or 18, or a resolution of 640x480 or higher to be sure modern hardware can handle it.
{{anchor name="item8"}}==Why does Imagecreate return a NULL pointer?==
[[KeyPgImagecreate Imagecreate]] needs to create an image buffer that fits the current screen's pixel format, and it cannot do so if there is no screen mode setup yet, so it returns NULL, very likely resulting in a NULL pointer access later on that crashes the program.
This is known to happen when Imagecreate is called //before// the graphics library was initialized with a call to [[KeyPgScreengraphics Screen]] or [[KeyPgScreenres Screenres]], as may happen when Imagecreate is called in a global constructor that is invoked before the Screen or Screenres call in the main part of the program. In such a case it is necessary to move the screen initialization into a constructor too, and have it execute before the image-creating constructors.
- [[CompilerFAQ Compiler FAQ]]
- [[FaqPgrtlib FB Runtime Library FAQ]]
Deletions:
**FreeBASIC Graphics Library questions:**
==- {{anchor name="item3|How are GET/PUT arrays managed?"}}==
==- {{anchor name="item4|Why is BSAVE/BLOAD crashing?"}}==
==- {{anchor name="item7|Can't run programs using SCREEN 13 or 14 in fullscreen !"}}==
@@**FreeBASIC Graphics Library questions**@@
Gfxlib is "built in" into the language, it is not necessary to include any .bi file or to link any library explicitly. FreeBASIC detects you want to use Gfxlib when it finds a [[KeyPgScreengraphics SCREEN]] or [[KeyPgScreenres SCREENRES]] instruction. So to use Gfxlib, just start a graphics screen mode and use the graphics commands.
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. Contents include [[KeyPgScreengraphics SCREEN]] / [[KeyPgScreenres SCREENRES]] mode flag constants, definitions of [[GfxScancodes Keyboard scancodes]] and more.
{{anchor name="item3"}}==How are GET/PUT arrays managed?==
In FreeBASIC, images can be used as arrays (as in QB) or as pointers. Either way, the image data is contained in one continuous chunk. The chunk consists of an header followed by the image data. The header can be of two types (old-style and new-style) and determines the format of the following image data, for details see [[GfxInternalFormats]] .
{{anchor name="item4"}}==Why is BSAVE/BLOAD crashing?==
BSAVE/BLOAD can only be used to load and save graphics screens in FreeBASIC. It can't be used to save a text mode screen. To load and save an array check this [[FaqPgbloadworkaround snippet using file GET/PUT]] .
NOTE: If you use an old version of FreeBASIC, you may have to use Chr( 255 ) + "X"
{{anchor name="item7"}}==Can't run programs using SCREEN 13 or 14 in fullscreen !==
It's a hardware/driver limitation (Win32 and Linux only ?). Video cards don't implement those low resolution graphic modes nowadays. If fullscreen is required you should rewrite it using at least SCREEN 17 or 18, or a resolution of 640x480 or higher to be sure modern hardware can handle it.
- [[CompilerFAQ Compiler FAQ]].
- [[FaqPgrtlib FB Runtime Library FAQ]].


Revision [14796]

Edited on 2010-08-21 02:45:13 by GaLeon [Changed run-time to runtime]
Additions:
- [[FaqPgrtlib FB Runtime Library FAQ]].
Deletions:
- [[FaqPgrtlib FB Run-Time Library FAQ]].


Revision [14233]

Edited on 2009-08-20 02:56:22 by CountingPine [updated]
Additions:


Revision [13783]

Edited on 2008-10-12 06:27:13 by DoS386 [moved out, see]
Additions:
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. Contents include [[KeyPgScreengraphics SCREEN]] / [[KeyPgScreenres SCREENRES]] mode flag constants, definitions of [[GfxScancodes Keyboard scancodes]] and more.
In FreeBASIC, images can be used as arrays (as in QB) or as pointers. Either way, the image data is contained in one continuous chunk. The chunk consists of an header followed by the image data. The header can be of two types (old-style and new-style) and determines the format of the following image data, for details see [[GfxInternalFormats]] .
{{fbdoc item="see"}}
Deletions:
The ##fbgfx.bi## header file is available for inclusion by your program, and contains constant and type definitions that may be helpful to the programmer when using Gfxlib. You do not have to explicitly include this file to use Gfxlib however; the header is only available as an aid. Contents include [[KeyPgScreengraphics SCREEN]]/[[KeyPgScreenres SCREENRES]] mode flag constants, definitions of [[GfxScancodes Keyboard scancodes]] and more.
In FreeBASIC, images can be used as arrays (as in QB) or as pointers. Either way, the image data is contained in one continuous chunk. The chunk consists of an header followed by the image data. The header can be of two types (old-style and new-style) and determines the format of the following image data.
**Old-style** chunk header consists of 4 bytes (32 bits). The first 3 bits contain the image color depth in bytes per pixel (8-bit color, depth = 1; 16-bit color, depth = 2; 32-bit color, depth = 4). The next 13 bits contain the image width. The last 16 bits contain the image's height. Please note the intrinsic nature of the header allows only for images of sizes up to 8191x65535. The actual pixel data follows the header, and is compacted one row of pixels after another; no data alignment is assumed. The final size of the chunk can then be computed using the formula:
##size = 4 + ( width * height * bytes_per_pixel )##
**New-style** chunk header consists of 32 bytes. The first word (32 bits) must be equal to the value &h7, allowing Gfxlib to identify the new type of chunk. The second word contains the image color depth in bytes per pixel. The third and fourth words contain the image width and height respectively, effectively removing the image size limit enforced by the old-style image chunks. The fifth word contains the pixel row pitch in bytes; this tells how many bytes a row of pixels of the image is long. The pitch in new-style chunks is always a multiple of 16, to allow pixels row data to be aligned on the paragraph boundary. The other 3 remaining words (12 bytes) of the header are currently unused and reserved for future use. The final size of the image is:
##size = 32 + ( ( ( ( width * bytes_per_pixel ) + &hF ) and not &hF ) * height )##
The [[KeyPgGetgraphics GET]] and [[KeyPgImagecreate IMAGECREATE]] functions both create a new-style image chunk, with an exception: [[KeyPgGetgraphics GET]] creates an old-style chunk when working in a graphics mode with a color depth equal or less than 8 bits per pixel; this was made to preserve compatibility with old QuickBasic sources, as the old-style chunks use the same internal format as used in QB.
All graphics primitives can work with both old-style and new-style image chunks. For more informations on the GET/PUT structure, please refer to [[FaqPggetputstructure this example]].
See also:


Revision [13276]

The oldest known version of this page was created on 2008-04-27 21:04:25 by DoS386 [moved out, see]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode