Previous: 4.51.2.4.49. ogSetAlpha() To the Table of Contents Next: 4.51.2.4.51. ogSetBlending()
4.51.2.4.49. ogSetAlpha() Table of Contents 4.51.2.4.51. ogSetBlending()

- 4.51.2.4.50. -
Table of Contents
4. Standard Units
4.51. ObjGfx40 - ObjectGraphics 4.0 Unit
4.51.2. ObjGfx40 Unit Object Types
4.51.2.4. ogSurface object
4.51.2.4.50. ogSetAntiAliasing()


4.51.2.4.50. ogSetAntiAliasing()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Sets the state of antialiasing.

Declaration:
  function ogSetAntiAliasing:boolean;
Remarks:

Sets whether the surface should use antialiasing on lines. Returns the previous state of antialiasing.

Restrictions:

By default antialiasing will be turned off in 8BPP buffers due to speed considerations. Antialiasing does work in 8BPP modes, but is incredibly slow. This will be fixed in the next revision.

See also: Sample code:
{ogSetAntiAliasing.pas}

uses
  ObjGfx40, CRT;

var
  oldAntiAliasState:boolean;
  xx, yy:uInt32;
  
begin

  {set the video card to be 800x600 in true colour}
  if not screen^.ogCreate(800, 600, OG_PIXFMT_32BPP) then
    begin
      writeln('Error setting video mode');
      halt
    end;

  {Draw a line in white using the default anti alias state (TRUE for bit
   depths greater than 8bpp)}
  with screen^ do
    for xx:=0 to (ogGetMaxX+1) div 10 do
      ogLine(xx*10,0,(ogGetMaxX+1) div 2,(ogGetMaxY+1) div 2,
             ogRGB(255, 255, 255));

  {Get the old anti alias state}
  oldAntiAliasState := screen^.ogIsAntiAliasing;

  {set the new anti alias state to false}
  screen^.ogSetAntiAliasing(FALSE);

  {Draw lines in blue without anti aliasing}
  with screen^ do
    for yy:=0 to (ogGetMaxY+1) div 10 do
      ogLine(ogGetMaxX, yy*10, (ogGetMaxX+1) div 2, (ogGetMaxY+1) div 2,
             ogRGB(0, 0, 255));

  {Restore the previous anti alias state}
  screen^.ogSetAntiAliasing(oldAntiAliasState);

  {This is an alternative to using ogGetAntiAlias}
  oldAntiAliasState := screen^.ogSetAntiAliasing(FALSE);

  {Draw a non anti-aliased line in green}
  with screen^ do
    for yy:=0 to (ogGetMaxY+1) div 10 do
      ogLine(0,yy*10, (ogGetMaxX+1) div 2, (ogGetMaxY+1) div 2,
             ogRGB(0, 255, 0));

  screen^.ogSetAntiAlias(oldAntiAliasState);

  {Draw a anti-aliased line in red}
  with screen^ do
    for xx:=0 to (ogGetMaxX+1) div 10 do
      ogLine(xx*10,ogGetMaxY, (ogGetMaxX+1) div 2, ogGetMaxY div 2,
             ogRGB(255, 0, 0));
  readKey;
  while keyPressed do readKey;
end.



Previous: 4.51.2.4.49. ogSetAlpha() To the Table of Contents Next: 4.51.2.4.51. ogSetBlending()
4.51.2.4.49. ogSetAlpha() Table of Contents 4.51.2.4.51. ogSetBlending()

- 4.51.2.4.50. -