Previous: 4.51.2.4.12. ogCopyPal() To the Table of Contents Next: 4.51.2.4.14. ogCubicBezierCurve()
4.51.2.4.12. ogCopyPal() Table of Contents 4.51.2.4.14. ogCubicBezierCurve()

- 4.51.2.4.13. -
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.13. ogCreate()


4.51.2.4.13. ogCreate()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Allocates memory for a ogSurface buffer.

Declaration:
  function ogCreate(xRes, yRes: uInt32; pixFormat:ogPixelFmt):boolean; virtual;
Remarks:

If enough memory is available, creates a surface of xRes by yRes resolution using the pixel format defined in pixFormat.

For the screen object, this function will search through the list of available modes and choose one that best fits the requested resolution and pixel format. Only the bitdepth of the pixel format is used.

The surface will be cleared with colour ogRGB(0, 0, 0).

Return value:

Returns TRUE if successful, FALSE if failure.

Restrictions:

Available RAM limits how large the surface may be. On a test machine with 384MB RAM, a 8192x8192x32BPP (256MB) buffer was successfully created.

Pixel format isn't limited to what the video card can do. However, all colour channels are 8-bits wide. Colour channels greater than 8-bits will be supported in a future version.

See also:

Sample code:
{ogCreate.pas}

uses
 ObjGfx40;

const 
  response:array[ boolean ] of string=('failed!','done.');

var 
  buf:^ogSurface;

begin
  new(buf, ogInit);

  write('Creating a 2048x2048x32BPP buffer... ');
  writeln(pesponse[buf^.ogCreate(2048, 2048, OG_PIXFMT_32BPP)]);

  write('Clearing buffer... ');
  buf^.ogClear(buf^.ogRGB(0,0,0));
  writeln('done.');

  {A second call to ogCreate() will free the previously used buffer}
  write('Resizing to a 100x100x8bpp buffer... ');
  writeln(response[buf^.ogCreate(100, 100, OG_PIXFMT_8BPP)]);
  write('Clearing buffer... ');
  buf^.ogClear(0);
  writeln('done.');
  
  dispose(buf, ogDone);
end.



Previous: 4.51.2.4.12. ogCopyPal() To the Table of Contents Next: 4.51.2.4.14. ogCubicBezierCurve()
4.51.2.4.12. ogCopyPal() Table of Contents 4.51.2.4.14. ogCubicBezierCurve()

- 4.51.2.4.13. -