![]() |
![]() |
![]() |
| 4.51.2.2.14. ogSetRGBAPalette() | Table of Contents | 4.51.2.2.16. ogVSync() |
procedure ogSetRGBPalette(colour, red, green, blue:uInt8); virtual;Remarks:
Colour defines the palette entry to be set, while red, green, and blue define the component colours of the palette entry.
The red, green, and blue values are with a range of 0..255, where 0 is minimum and 255 is maximum.
Modifies the hardware palette with the new entry.
Restrictions:Palettes are only relevant to 8BPP modes.
See also:
{ogSetRGBPalette.pas}
uses
ObjGfx40, CRT;
var
xx, yy, zz:uInt32;
begin
if not screen^.ogCreate(800, 600, OG_PIXFMT_8BPP) then
begin
writeln('Error setting video mode');
halt
end;
{Set up an optimized palette for 256 colours if dealing with 8bpp}
with screen^ do
if (ogGetBPP = 8) then
begin
for xx:=0 to 15 do
ogSetRGBPalette(xx, (xx+1)*16-1, 255, 0);
for xx:=0 to 15 do
ogSetRGBPalette(xx+16, 255, 255-((xx+1)*16-1), 0);
for xx:=0 to 15 do
ogSetRGBPalette(xx+32, 255, 0, (xx+1)*16-1);
for xx:=0 to 15 do
ogSetRGBPalette(xx+48, 255-((xx+1)*16-1), 0, 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+64, 0, ((xx+1)*16-1), 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+80, 0, 255, 255-((xx+1)*16-1));
for xx:=0 to 15 do
ogSetRGBPalette(xx+96, 255-((xx+1)*16-1), 255, 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+112, 255, 255-((xx+1)*16-1), 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+128, 255, 255, 255-((xx+1)*16-1));
for xx:=0 to 15 do
ogSetRGBPalette(xx+144, 255, (xx+1)*16-1, (xx+1)*16-1);
for xx:=0 to 15 do
ogSetRGBPalette(xx+160, (xx+1)*16-1, 255, (xx+1)*16-1);
for xx:=0 to 15 do
ogSetRGBPalette(xx+176, (xx+1)*16-1, (xx+1)*16-1, 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+192, (xx+1)*16-1, 255-((xx+1)*16-1), 255);
for xx:=0 to 15 do
ogSetRGBPalette(xx+208, 255, (xx+1)*16-1, 255-((xx+1)*16-1));
for xx:=0 to 15 do
ogSetRGBPalette(xx+224, (xx+1)*16-1, 255, 255-((xx+1)*16-1));
for xx:=0 to 15 do
ogSetRGBPalette(xx+240, (xx+1)*16-1, (xx+1)*16-1, (xx+1)*16-1);
ogSetRGBPalette(0, 0, 0, 0);
for xx:=0 to 255 do
ogVLine(xx, 0, 63, xx);
end; {if bpp=8}
zz:=1;
repeat
with screen^ do
for yy:=0 to 255 do
for xx:=0 to 255 do
if (yy=0) or (xx=255) or (zz=255) then
ogSetPixel(256+128+xx-(zz div 2), 128+yy+(zz div 2),
ogRGB(xx, 255-yy, zz));
inc(zz,2);
until (keyPressed) or (zz>255);
while keyPressed do readKey;
readKey;
end.
![]() |
![]() |
![]() |
| 4.51.2.2.14. ogSetRGBAPalette() | Table of Contents | 4.51.2.2.16. ogVSync() |