Unit CastleGLUtils

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Various low-level utilities for working with OpenGL.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class EOpenGLError OpenGL error.
Class EOpenGLOutOfMemoryError GPU memory is not sufficient.
Class EOpenGLNoMoreDisplayLists  
Class TGLFeatures OpenGL features, analyzed based on OpenGL extensions and version.
Class EGenerateMipmapNotAvailable Part of CastleGLUtils unit: mipmaps utils.
Class TScissor Scissor to clip displayed things, in addition to the global scissor affected by TRenderContext.ScissorEnable / TRenderContext.ScissorDisable.
Class TRenderContext The OpenGL / OpenGLES context state.

Functions and Procedures

procedure GLOutOfMemory(const AdditionalComment: string = '');
function GLErrorString(const ErrorCode: TGLenum; const AdditionalComment: string = ''): string;
procedure CheckGLErrors(const AdditionalComment: string = '');
procedure GLErrorRaise(ErrorCode: TGLenum); cdecl;
function glGetFloat(pname: TGLEnum): TGLfloat;
function glGetInteger(pname: TGLEnum): TGLint;
function glGetBoolean(pname: TGLEnum): TGLboolean;
procedure glColorv(const v: TVector3ub); overload;
procedure glColorv(const v: TVector4ub); overload;
procedure glColorv(const v: TVector3f); overload;
procedure glColorv(const v: TVector4f); overload;
procedure glTranslatev(const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glTranslatev(const V: TVector3_Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glScalev(const V: Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glScalev(const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glScalev(const V: TVector3_Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glRotatev(const Angle: TGLfloat; const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';
procedure glClipPlane(plane: GLenum; const V: TVector4d); overload;
procedure glNormalv(const v: TVector3f); overload;
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4f); overload;
procedure glVertexv(const v: TVector2f); overload;
procedure glVertexv(const v: TVector2i); overload;
procedure glVertexv(const v: TVector3f); overload;
procedure glVertexv(const v: TVector3i); overload;
procedure glVertexv(const v: TVector4f); overload;
procedure glVertexv(const v: TVector4i); overload;
procedure glVertexv(const v: TVector2_Single); overload;
procedure glVertexv(const v: TVector3_Single); overload;
procedure glVertexv(const v: TVector4_Single); overload;
procedure glTexCoordv(const v: TVector2f); overload;
procedure glTexCoordv(const v: TVector3f); overload;
procedure glTexCoordv(const v: TVector4f); overload;
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4f); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector4f); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector3f); overload;
procedure glLightModelv(pname: TGLenum; const params: TVector4f); overload;
procedure glFogv(pname: TGLEnum; const params: TVector4f); overload;
procedure glMultMatrix(const m: TMatrix4f); overload;
procedure glLoadMatrix(const m: TMatrix4f); overload;
procedure glTexEnvv(target, pname: TGLEnum; const params: TVector4f); overload;
procedure GLViewport(const Rect: TRectangle);
function GetCurrentColor: TCastleColor; deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';
procedure SetCurrentColor(const Value: TCastleColor); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';
function GetProjectionMatrix: TMatrix4Single;
procedure SetProjectionMatrix(const Value: TMatrix4Single);
function PerspectiveProjection(const fovy, aspect, ZNear, ZFar: Single): TMatrix4Single;
function OrthoProjection(const Dimensions: TFloatRectangle; const ZNear: Single = -1; const ZFar: Single = 1): TMatrix4Single;
function FrustumProjection(const Dimensions: TFloatRectangle; const ZNear, ZFar: Single): TMatrix4Single;
procedure GLSetEnabled(value: TGLenum; isEnabled: boolean);
procedure GLVerticalLine(x, y1, y2: TGLfloat); deprecated 'use DrawPrimitive2D';
procedure GLHorizontalLine(x1, x2, y: TGLfloat); deprecated 'use DrawPrimitive2D';
procedure GLDrawArrow(HeadThickness: TGLfloat = 0.4; HeadLength: TGLfloat = 0.5); deprecated 'use DrawPrimitive2D to draw shapes';
function NewGLUQuadric( Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL): PGLUQuadric; deprecated 'use TCastleScene to draw 3D stuff';
procedure CastleGluSphere( const Radius: TGLdouble; const Slices, Stacks: TGLint; Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL); deprecated 'use TCastleScene to draw 3D stuff';
procedure glDrawAxisWire(const Position: TVector3Single; Size: Single); deprecated 'use TCastleScene to draw 3D stuff';
procedure glColorOpacity(const Color: TVector3Single; const Opacity: Single); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';
procedure glColorOpacity(const Color: TVector3Byte; const Opacity: Single); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';
function glGenListsCheck(range: TGLsizei; const Place: string): TGLuint; deprecated 'do not use display lists; they are not available on OpenGLES and modern OpenGL';
procedure glFreeDisplayList(var list: TGLuint); deprecated 'do not use display lists; they are not available on OpenGLES and modern OpenGL';
procedure glFreeBuffer(var Buffer: TGLuint);
procedure glSetDepthAndColorWriteable(Writeable: TGLboolean);
procedure SetWindowPos(const X, Y: TGLint); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
procedure SetWindowPos(const Value: TVector2i); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
procedure SetWindowPosF(const X, Y: TGLfloat); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
procedure SetWindowPosZero; deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
function GetWindowPos: TVector2i; deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
function GetDepthRange: TDepthRange;
procedure SetDepthRange(const Value: TDepthRange);
function GLEnableTexture(const Target: TEnableTextureTarget): boolean;
procedure GLInformationInitialize;
procedure DrawRectangle(const R: TRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);
procedure DrawRectangleOutline(const R: TRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);
procedure DrawCircle(const Middle: TVector2Integer; const HorizontalRadius, VerticalRadius: Integer; const Color: TCastleColor; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);
procedure DrawCircleOutline(const Middle: TVector2Integer; const HorizontalRadius, VerticalRadius: Integer; const Color: TCastleColor; const LineWidth: Single = 1; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);
procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const Points: array of TVector2SmallInt; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1);
procedure GLFadeRectangleDark(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3Single; const FadeIntensity: Single);
procedure GLFadeRectangleDark(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3Single; const FadeIntensity: Single); deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';
procedure GLFadeRectangle(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';
procedure GLBlendRectangle(const X1, Y1, X2, Y2: Integer; const SourceFactor: TBlendingSourceFactor; const DestinationFactor: TBlendingDestinationFactor; const Color: TVector4Single); deprecated 'use DrawRectangle';
procedure GLBlendRectangle(const Rect: TRectangle; const Color: TVector4Single); deprecated 'use DrawRectangle';
procedure GLBlendFunction(const SourceFactor: TBlendingSourceFactor; const DestinationFactor: TBlendingDestinationFactor);
function GLInformationString: string;
function HasGenerateMipmap: boolean;
procedure GenerateMipmap(target: TGLenum);
procedure GLClear(const Buffers: TClearBuffers; const ClearColor: TCastleColor); deprecated 'use RenderContext.Clear';

Types

TGLenum = GLenum;
TGLboolean = GLboolean;
TGLbitfield = GLbitfield;
TGLbyte = GLbyte;
TGLshort = GLshort;
TGLint = GLint;
TGLsizei = GLsizei;
TGLubyte = GLubyte;
TGLushort = GLushort;
TGLuint = GLuint;
TGLfloat = GLfloat;
TGLclampf = GLclampf;
TGLdouble = GLdouble;
TGLclampd = GLclampd;
TVector2f = TVector2Single;
PVector2f = PVector2Single;
TVector2d = TVector2Double;
PVector2d = PVector2Double;
TVector2ub = TVector2Byte;
PVector2ub = PVector2Byte;
TVector2i = TVector2LongInt;
PVector2i = PVector2LongInt;
TVector3f = TVector3Single;
PVector3f = PVector3Single;
TVector3d = TVector3Double;
PVector3d = PVector3Double;
TVector3ub = TVector3Byte;
PVector3ub = PVector3Byte;
TVector3i = TVector3LongInt;
PVector3i = PVector3LongInt;
TVector4f = TVector4Single;
PVector4f = PVector4Single;
TVector4d = TVector4Double;
PVector4d = PVector4Double;
TVector4ub = TVector4Byte;
PVector4ub = PVector4Byte;
TVector4i = TVector4LongInt;
PVector4i = PVector4LongInt;
TMatrix2f = TMatrix2Single;
PMatrix2f = PMatrix2Single;
TMatrix2d = TMatrix2Double;
PMatrix2d = PMatrix2Double;
TMatrix3f = TMatrix3Single;
PMatrix3f = PMatrix3Single;
TMatrix3d = TMatrix3Double;
PMatrix3d = PMatrix3Double;
TMatrix4f = TMatrix4Single;
PMatrix4f = PMatrix4Single;
TMatrix4d = TMatrix4Double;
PMatrix4d = PMatrix4Double;
TDepthRange = (...);
TEnableTextureTarget = (...);
TGLSupport = (...);
TPrimitiveMode = (...);
TBlendingSourceFactor = (...);
TBlendingDestinationFactor = (...);
TClearBuffer = (...);
TClearBuffers = set of TClearBuffer;

Constants

GLSupportNames: array [TGLSupport] of string = ( 'None', 'Extension', 'Standard' );
DefaultCircleSlices = 32;

Variables

GLOutOfMemoryError: boolean = false;
property CurrentColor: TCastleColor read GetCurrentColor write SetCurrentColor;
property ProjectionMatrix: TMatrix4Single read GetProjectionMatrix write SetProjectionMatrix;
Viewport2DSize: TVector2Single;
property WindowPos: TVector2i read GetWindowPos write SetWindowPos;
property DepthRange: TDepthRange read GetDepthRange write SetDepthRange;
GLFeatures: TGLFeatures;
RenderContext: TRenderContext;

Description

Functions and Procedures

procedure GLOutOfMemory(const AdditionalComment: string = '');
 
function GLErrorString(const ErrorCode: TGLenum; const AdditionalComment: string = ''): string;
 
procedure CheckGLErrors(const AdditionalComment: string = '');

Check are any OpenGL errors recorded (in glGetError). If there are errors, our behavior depends on whether we were compiled with -dRELEASE. With -dRELEASE, we make WritelnWarning. This way eventual errors in release builds don't completely abort your program.

Note that the behavior on GL_OUT_OF_MEMORY is different. -dRELEASE does not matter here. Only GLOutOfMemoryError boolean dictates if we should raise an exception or merely make warning, regardless of -dRELEASE state.

Without -dRELEASE, we raise EOpenGLError. So a developer is strongly suggested to fix the code to not produce OpenGL errors, never ever.

Exceptions raised
EOpenGLError
procedure GLErrorRaise(ErrorCode: TGLenum); cdecl;

Raise EOpenGLError for given OpenGL error code. This has calling convention suitable for registering this procedure as GLU_TESS_ERROR for gluTessCallback, or GLU_ERROR for gluQuadricCallback.

function glGetFloat(pname: TGLEnum): TGLfloat;

Comfortable wrappers for OpenGL glGet* that return a single value.

Guarantee that result is zero in case of OpenGL error. (Otherwise, OpenGL could leave them undefined and only set glGetError.)

function glGetInteger(pname: TGLEnum): TGLint;
 
function glGetBoolean(pname: TGLEnum): TGLboolean;
 
procedure glColorv(const v: TVector3ub); overload;
 
procedure glColorv(const v: TVector4ub); overload;
 
procedure glColorv(const v: TVector3f); overload;
 
procedure glColorv(const v: TVector4f); overload;
 
procedure glTranslatev(const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glTranslatev(const V: TVector3_Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glScalev(const V: Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glScalev(const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glScalev(const V: TVector3_Single); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glRotatev(const Angle: TGLfloat; const V: TVector3f); overload; deprecated 'use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or T3DTransform for TCastleScene, or TTransformNode in X3D

 
procedure glClipPlane(plane: GLenum; const V: TVector4d); overload;
 
procedure glNormalv(const v: TVector3f); overload;
 
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4f); overload;
 
procedure glVertexv(const v: TVector2f); overload;
 
procedure glVertexv(const v: TVector2i); overload;
 
procedure glVertexv(const v: TVector3f); overload;
 
procedure glVertexv(const v: TVector3i); overload;
 
procedure glVertexv(const v: TVector4f); overload;
 
procedure glVertexv(const v: TVector4i); overload;
 
procedure glVertexv(const v: TVector2_Single); overload;
 
procedure glVertexv(const v: TVector3_Single); overload;
 
procedure glVertexv(const v: TVector4_Single); overload;
 
procedure glTexCoordv(const v: TVector2f); overload;
 
procedure glTexCoordv(const v: TVector3f); overload;
 
procedure glTexCoordv(const v: TVector4f); overload;
 
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4f); overload;
 
procedure glLightv(light, pname: TGLEnum; const params: TVector4f); overload;
 
procedure glLightv(light, pname: TGLEnum; const params: TVector3f); overload;
 
procedure glLightModelv(pname: TGLenum; const params: TVector4f); overload;
 
procedure glFogv(pname: TGLEnum; const params: TVector4f); overload;
 
procedure glMultMatrix(const m: TMatrix4f); overload;
 
procedure glLoadMatrix(const m: TMatrix4f); overload;
 
procedure glTexEnvv(target, pname: TGLEnum; const params: TVector4f); overload;
 
procedure GLViewport(const Rect: TRectangle);
 
function GetCurrentColor: TCastleColor; deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';

Warning: this symbol is deprecated: instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color

 
procedure SetCurrentColor(const Value: TCastleColor); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';

Warning: this symbol is deprecated: instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color

 
function GetProjectionMatrix: TMatrix4Single;

Projection matrix ——————————————————–

procedure SetProjectionMatrix(const Value: TMatrix4Single);
 
function PerspectiveProjection(const fovy, aspect, ZNear, ZFar: Single): TMatrix4Single;

Set ProjectionMatrix to given value.

For PerspectiveProjection, ZFar may have special ZFarInfinity value to create a perspective projection with far plane set at infinity. Useful e.g. for z-fail shadow volumes.

function OrthoProjection(const Dimensions: TFloatRectangle; const ZNear: Single = -1; const ZFar: Single = 1): TMatrix4Single;
 
function FrustumProjection(const Dimensions: TFloatRectangle; const ZNear, ZFar: Single): TMatrix4Single;
 
procedure GLSetEnabled(value: TGLenum; isEnabled: boolean);
 
procedure GLVerticalLine(x, y1, y2: TGLfloat); deprecated 'use DrawPrimitive2D';

Warning: this symbol is deprecated: use DrawPrimitive2D

Draw vertical line using OpenGL. Uses current OpenGL color.

Deprecated, do not draw lines directly like this, instead use DrawPrimitive2D or UI interface drawing like Theme.Draw and TGLImageCore.Draw.

procedure GLHorizontalLine(x1, x2, y: TGLfloat); deprecated 'use DrawPrimitive2D';

Warning: this symbol is deprecated: use DrawPrimitive2D

Draw horizontal line using OpenGL. Uses current OpenGL color.

Deprecated, do not draw lines directly like this, instead use DrawPrimitive2D or UI interface drawing like Theme.Draw and TGLImageCore.Draw.

procedure GLDrawArrow(HeadThickness: TGLfloat = 0.4; HeadLength: TGLfloat = 0.5); deprecated 'use DrawPrimitive2D to draw shapes';

Warning: this symbol is deprecated: use DrawPrimitive2D to draw shapes

Draw arrow shape. Arrow is placed on Z = 0 plane, points to the up, has height = 2 (from y = 0 to y = 2) and width 1 (from x = -0.5 to 0.5).

Everything is drawn CCW when seen from standard view (x grows right, y up). Uses current OpenGL color.

function NewGLUQuadric( Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL): PGLUQuadric; deprecated 'use TCastleScene to draw 3D stuff';

Warning: this symbol is deprecated: use TCastleScene to draw 3D stuff

Comfortable wrapper for gluNewQuadric. Sets all quadric parameters. Sets also the GLU_ERROR callback to ReportGLerror.

Exceptions raised
Exception
If gluNewQuadric fails (returns nil).
procedure CastleGluSphere( const Radius: TGLdouble; const Slices, Stacks: TGLint; Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL); deprecated 'use TCastleScene to draw 3D stuff';

Warning: this symbol is deprecated: use TCastleScene to draw 3D stuff

Render sphere in OpenGL. Radius, Slices, Stacks have the same meaning as for gluSphere (in case they are not self-explanatory...). Other parameters set glu quadric parameters, see glu quadric documentation.

procedure glDrawAxisWire(const Position: TVector3Single; Size: Single); deprecated 'use TCastleScene to draw 3D stuff';

Warning: this symbol is deprecated: use TCastleScene to draw 3D stuff

Draw axis (3 lines) around given position. Nothing is generated besides vertex positions — no normal vectors, no texture coords, nothing.

procedure glColorOpacity(const Color: TVector3Single; const Opacity: Single); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';

Warning: this symbol is deprecated: instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color

Call glColor, taking Opacity as separate Single argument. Deprecated, do not use colors like that, instead pass TCastleColor to appropriate routines like TCastleFont.Print.

procedure glColorOpacity(const Color: TVector3Byte; const Opacity: Single); deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';

Warning: this symbol is deprecated: instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color

 
function glGenListsCheck(range: TGLsizei; const Place: string): TGLuint; deprecated 'do not use display lists; they are not available on OpenGLES and modern OpenGL';

Warning: this symbol is deprecated: do not use display lists; they are not available on OpenGLES and modern OpenGL

Call glGenLists(range) and checks the result.

Exceptions raised
EOpenGLNoMoreDisplayLists
When glGenLists(Range) returned zero for non-zero Range. The exception's Message shows Place, which may describe where this is called — makes it easier to debug.
procedure glFreeDisplayList(var list: TGLuint); deprecated 'do not use display lists; they are not available on OpenGLES and modern OpenGL';

Warning: this symbol is deprecated: do not use display lists; they are not available on OpenGLES and modern OpenGL

If List <> 0 then it does glDeleteList on List and sets List to 0. In other words this is simply glDeleteList but

  1. only if List really should be deleted

  2. sets List to 0 after deletion

procedure glFreeBuffer(var Buffer: TGLuint);

If Buffer <> 0 then it does glDeleteBuffers and sets Buffer to 0.

procedure glSetDepthAndColorWriteable(Writeable: TGLboolean);

Set color and depth buffers writeable or not. This is just a shortcut for

    glDepthMask(Writeable);
    glColorMask(Writeable, Writeable, Writeable, Writeable);
  

procedure SetWindowPos(const X, Y: TGLint); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

Warning: this symbol is deprecated: instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)

Draw the 2D GUI stuff (like following GUI images and TCastleFont) with lower-left corner in the X,Y pixel.

procedure SetWindowPos(const Value: TVector2i); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

Warning: this symbol is deprecated: instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)

 
procedure SetWindowPosF(const X, Y: TGLfloat); deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

Warning: this symbol is deprecated: instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)

 
procedure SetWindowPosZero; deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

Warning: this symbol is deprecated: instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)

 
function GetWindowPos: TVector2i; deprecated 'instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

Warning: this symbol is deprecated: instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)

 
function GetDepthRange: TDepthRange;
 
procedure SetDepthRange(const Value: TDepthRange);
 
function GLEnableTexture(const Target: TEnableTextureTarget): boolean;

Enable exactly one (or none, for Target=etNone) OpenGL texture target. Always use this instead of manually calling glDisable(GL_TEXTURE_2D), glEnable(GL_TEXTURE_2D) and such. This makes sure to have at most one texture target enabled, and disable others.

Remember that this state is different for every texture unit in OpenGL, in case you use multi-texturing.

Remember that not all texture targets are guaranteed to be supported by OpenGL. Target=etNone and Target=et2D are always supported. For the rest, check appropriate GLFeatures property (before even creating a texture with such type). If you pass an unsupported target type to this procedure, it will be ignored (all targets will be disabled, like for Target=etNone).

Note that this is only for fixed-function OpenGL pipeline. Shader pipeline completely ignores the enabled state of texture units.

procedure GLInformationInitialize;

Initialize GLVersion and GLUVersion and GLFeatures.

procedure DrawRectangle(const R: TRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);

Draw a rectangle filled with a color.

Like with DrawPrimitive2D: Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.

procedure DrawRectangleOutline(const R: TRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);

Draw a rectangle frame.

Like with DrawPrimitive2D: Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.

procedure DrawCircle(const Middle: TVector2Integer; const HorizontalRadius, VerticalRadius: Integer; const Color: TCastleColor; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);

Draw a circle. It may be scaled differently in X than Y, thus resembling an ellipse.

Like with DrawPrimitive2D: Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.

procedure DrawCircleOutline(const Middle: TVector2Integer; const HorizontalRadius, VerticalRadius: Integer; const Color: TCastleColor; const LineWidth: Single = 1; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false);

Draw a circle outline. It may be scaled differently in X than Y, thus resembling an ellipse.

Like with DrawPrimitive2D: Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.

procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const Points: array of TVector2SmallInt; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1);

Draw a simple 2D primitive with a given color. This can be used to draw a series of points, lines or triangles, depending on the Mode parameter.

Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.

Parameters
LineWidth
Line width, only used when Mode indicates lines.

Note that values other than 1 are not guaranteed to be supported. While it's a fast method to have thick lines, it is implementation-limited in case of

  1. desktop OpenGL with anti-aliasing, see https://www.opengl.org/sdk/docs/man/html/glLineWidth.xhtml

  2. mobile OpenGLES, with or without anti-aliasing, see https://www.khronos.org/opengles/sdk/docs/man/xhtml/glLineWidth.xml

PointSize
Point size, only used when Mode indicates points.

Note that values other than 1 are not guaranteed to be supported. Mobile OpenGLES does not support setting point size like this. And desktop OpenGL limits point size in case anti-aliasing is used, see https://www.opengl.org/sdk/docs/man2/xhtml/glPointSize.xml .

procedure GLFadeRectangleDark(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3Single; const FadeIntensity: Single);

Draw a rectangle that modulates colors underneath, making nice animation to AFadeColor while FadeIntensity changes from 1.0 down to 0.0.

The GLFadeRectangleLight version makes a flash to AFadeColor, then goes back to normal. It works reasonably with any color (light or dark).

The GLFadeRectangleDark version makes additional flash to blackness in the middle (so it goes from no modulation, to AFadeColor, to pure black, and then back to normal). So the "Dark" version is a little more impressive when you're flashing with a dark color.

These are nice as a screen effect, to flash some color (e.g. flash red color when the player is hurt).

Only RGB portion of AFadeColor is used.

procedure GLFadeRectangleDark(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
 
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
 
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3Single; const FadeIntensity: Single); deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';

Warning: this symbol is deprecated: use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true

 
procedure GLFadeRectangle(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';

Warning: this symbol is deprecated: use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true

 
procedure GLBlendRectangle(const X1, Y1, X2, Y2: Integer; const SourceFactor: TBlendingSourceFactor; const DestinationFactor: TBlendingDestinationFactor; const Color: TVector4Single); deprecated 'use DrawRectangle';

Warning: this symbol is deprecated: use DrawRectangle

Draw a rectangle with blending. Deprecated, use DrawRectangle instead.

procedure GLBlendRectangle(const Rect: TRectangle; const Color: TVector4Single); deprecated 'use DrawRectangle';

Warning: this symbol is deprecated: use DrawRectangle

 
procedure GLBlendFunction(const SourceFactor: TBlendingSourceFactor; const DestinationFactor: TBlendingDestinationFactor);
 
function GLInformationString: string;

Multiline string describing attributes of current OpenGL library. This simply queries OpenGL using glGet* functions about many things. Does not change OpenGL state in any way.

Note that the last line of returned string does not terminate with a newline character (so e.g. you may want to do Writeln(GLInformationString) instead of just Write(GLInformationString)).

function HasGenerateMipmap: boolean;

Is GenerateMipmap avaiable. This checks some GL extensions/versions that give us glGenerateMipmap or glGenerateMipmapEXT call, used by GenerateMipmap.

procedure GenerateMipmap(target: TGLenum);

Call glGenerateMipmap (or analogous function from some OpenGL extension).

Exceptions raised
EGenerateMipmapNotAvailable
If no glGenerateMipmap version is available on this OpenGL version. If you don't want to get this exception, you can always check HasGenerateMipmap before calling this.
procedure GLClear(const Buffers: TClearBuffers; const ClearColor: TCastleColor); deprecated 'use RenderContext.Clear';

Warning: this symbol is deprecated: use RenderContext.Clear

 

Types

TGLenum = GLenum;
 
TGLboolean = GLboolean;
 
TGLbitfield = GLbitfield;
 
TGLbyte = GLbyte;
 
TGLshort = GLshort;
 
TGLint = GLint;
 
TGLsizei = GLsizei;
 
TGLubyte = GLubyte;
 
TGLushort = GLushort;
 
TGLuint = GLuint;
 
TGLfloat = GLfloat;
 
TGLclampf = GLclampf;
 
TGLdouble = GLdouble;
 
TGLclampd = GLclampd;
 
TVector2f = TVector2Single;
 
PVector2f = PVector2Single;
 
TVector2d = TVector2Double;
 
PVector2d = PVector2Double;
 
TVector2ub = TVector2Byte;
 
PVector2ub = PVector2Byte;
 
TVector2i = TVector2LongInt;
 
PVector2i = PVector2LongInt;
 
TVector3f = TVector3Single;
 
PVector3f = PVector3Single;
 
TVector3d = TVector3Double;
 
PVector3d = PVector3Double;
 
TVector3ub = TVector3Byte;
 
PVector3ub = PVector3Byte;
 
TVector3i = TVector3LongInt;
 
PVector3i = PVector3LongInt;
 
TVector4f = TVector4Single;
 
PVector4f = PVector4Single;
 
TVector4d = TVector4Double;
 
PVector4d = PVector4Double;
 
TVector4ub = TVector4Byte;
 
PVector4ub = PVector4Byte;
 
TVector4i = TVector4LongInt;
 
PVector4i = PVector4LongInt;
 
TMatrix2f = TMatrix2Single;
 
PMatrix2f = PMatrix2Single;
 
TMatrix2d = TMatrix2Double;
 
PMatrix2d = PMatrix2Double;
 
TMatrix3f = TMatrix3Single;
 
PMatrix3f = PMatrix3Single;
 
TMatrix3d = TMatrix3Double;
 
PMatrix3d = PMatrix3Double;
 
TMatrix4f = TMatrix4Single;
 
PMatrix4f = PMatrix4Single;
 
TMatrix4d = TMatrix4Double;
 
PMatrix4d = PMatrix4Double;
 
TDepthRange = (...);

Possible values of DepthRange.

Values
  • drFull:  
  • drNear:  
  • drFar:  
TEnableTextureTarget = (...);
 
Values
  • etNone:  
  • et2D:  
  • etCubeMap:  
  • et3D:  
TGLSupport = (...);

Part of CastleGLUtils unit: TGLFeatures and friends.

Values
  • gsNone:  
  • gsExtension:  
  • gsStandard:  
TPrimitiveMode = (...);

Primitive to draw using DrawPrimitive2D. The modes correspond to OpenGL drawing modes, see https://www.opengl.org/wiki/Primitive https://www.opengl.org/sdk/docs/man2/xhtml/glBegin.xml

Values
  • pmPoints:  
  • pmLineStrip:  
  • pmLineLoop:  
  • pmLines:  
  • pmTriangleStrip:  
  • pmTriangleFan:  
  • pmTriangles:  
TBlendingSourceFactor = (...);
 
Values
  • bsSrcAlpha:  
  • bsOneMinusSrcAlpha:  
  • bsZero:  
  • bsOne:  
  • bsDstColor:  
  • bsSrcColor: As a source factor only since GL 1.4, check GLFeatures.Version_1_4
  • bsDstAlpha:  
  • bsOneMinusDstColor:  
  • bsOneMinusSrcColor: As a source factor only since GL 1.4, check GLFeatures.Version_1_4
  • bsOneMinusDstAlpha:  
  • bsSrcAlphaSaturate:  
  • bsConstantColor:  
  • bsOneMinusConstantColor:  
  • bsConstantAlpha:  
  • bsOneMinusConstantAlpha:  
TBlendingDestinationFactor = (...);
 
Values
  • bdSrcAlpha:  
  • bdOneMinusSrcAlpha:  
  • bdZero:  
  • bdOne:  
  • bdDstColor: As a destination factor only since GL 1.4, check GLFeatures.Version_1_4
  • bdSrcColor:  
  • bdDstAlpha:  
  • bdOneMinusDstColor: As a destination factor only since GL 1.4, check GLFeatures.Version_1_4
  • bdOneMinusSrcColor:  
  • bdOneMinusDstAlpha:  
  • bdConstantColor:  
  • bdOneMinusConstantColor:  
  • bdConstantAlpha:  
  • bdOneMinusConstantAlpha:  
TClearBuffer = (...);

Part of CastleGLUtils unit: TRenderContext and friends.

Values
  • cbColor:  
  • cbDepth:  
  • cbStencil:  
TClearBuffers = set of TClearBuffer;
 

Constants

GLSupportNames: array [TGLSupport] of string = ( 'None', 'Extension', 'Standard' );
 
DefaultCircleSlices = 32;
 

Variables

GLOutOfMemoryError: boolean = false;

When GPU runs out of memory, raise exception (EOpenGLOutOfMemoryError) or merely make a warning. Merely making a warning is very risky (you risk all kinds of rendering artifacts), but sometimes the rendering is actually smooth even though GPU complains.

property CurrentColor: TCastleColor read GetCurrentColor write SetCurrentColor;

Warning: this symbol is deprecated.

Current color, set by glColorv and used for TCastleFont font printing (in case you use deprecated TCastleFont.Print overloads without explicit colors).

Instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color.

property ProjectionMatrix: TMatrix4Single read GetProjectionMatrix write SetProjectionMatrix;

Current projection matrix.

For OpenGLES, this is merely a global ProjectionMatrix variable. It must be passed to various shaders to honour the projection.

For desktop OpenGL, setting this also sets fixed-function projection matrix. The OpenGL matrix mode is temporarily changed to GL_PROJECTION, then changed back to GL_MODELVIEW.

Viewport2DSize: TVector2Single;

Viewport size for 2D rendering functions: DrawRectangle and TGLImageCore.Draw. UI container (like TCastleWindowCustom or TCastleControlCustom) must take care to set this before rendering.

property WindowPos: TVector2i read GetWindowPos write SetWindowPos;

Warning: this symbol is deprecated.

Global position for drawing 2D stuff. Do this use this. Instead of this, use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...).

property DepthRange: TDepthRange read GetDepthRange write SetDepthRange;

Use this to operate on OpenGL glDepthRange. For now, our engine has very simple use for this, for TPlayer.RenderOnTop.

GLFeatures: TGLFeatures;
 
RenderContext: TRenderContext;

Current OpenGL / OpenGLES context state. Only access it during the rendering, i.e. in TUIControl.Render.


Generated by PasDoc 0.14.0.