BRender Tutorial Guide:2 Getting Started:More About Background Colour

More About Background Colour

In 8-bit colour mode, 256 colours are available at any time. Which 256 colours are available is determined by the contents of the hardware palette (or CLUT). In this case, the palette supplied with BRender (std.pal) has been loaded into the CLUT.

The 256 colours in std.pal are divided into seven ranges, or `colour ramps'. The first 64 colours represent shades of grey ranging from very dark grey (black) to very light grey (white). The following colours are 32-element ramps for six colours as shown below.

BrPixelmapFill(back_buffer,0) sets the background to black. The background colour can easily be changed. In std.pal, colour 88 is a deep blue. Substitute 88 (or 0x55) for 0 in the above function call to change the background colour to blue. If you would prefer a red background, try 180 (0xB4).

Note that in 8-bit colour mode, only the least significant 8 bits of information in the colour argument are used by BrPixelmapFill to determine the colour - all others are ignored. So 0xFF is taken as white, as is 0xFFFFFFFF or 0x123FF or 255. 0xFFFFFF00, 0 and 256 are all black.

In true-colour mode, either 15-, 16-, 24- or 32- bit colour information is assumed (refer to your installation guide for details of which colour modes are supported by your version of BRender). In 15bit colour mode, five bits are used for each of the R, G and B components of a pixel's colour - the least significant five bits for blue, the most significant five bits for red. 0x1F therefore represents fully saturated blue. Try setting the background to blue using this value. Remember to select 15-bit colour mode. If you are running BRender under DOS, for instance, you could substitute an appropriate string (e.g. VESA,W:320,H:200,B:15) in place of NULL in DOSgfxBegin(NULL) or set the BRENDER_DOS_GFX environment variable. Use 0x1F<<5 to change the background to green, or 0x1F<<10 to change it to red.

Generated with CERN WebMaker