Unit CastleGLUtils

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 TGLMemoryInfo OpenGL memory information.
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; deprecated 'this function is no longer useful, as you should not use GLU in cross-platform programs';
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 TCastleTransform 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 TCastleTransform 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 TCastleTransform 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 TCastleTransform 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 TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';
procedure glClipPlane(plane: GLenum; const V: TVector4Double); overload;
procedure glNormalv(const v: TVector3); 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);
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: TVector3; Size: Single); deprecated 'use TCastleScene to draw 3D stuff';
procedure glColorOpacity(const Color: TVector3; const Opacity: Single); overload; 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); overload; 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(const Writeable: boolean);
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: TVector3; const FadeIntensity: Single); overload;
procedure GLFadeRectangleDark(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload;
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3; const FadeIntensity: Single); overload; deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';
procedure GLFadeRectangle(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; deprecated 'use GLFadeRectangleDark, or TCastleFlashEffect with Dark = true';
procedure GLBlendRectangle(const X1, Y1, X2, Y2: Integer; const SourceFactor: TBlendingSourceFactor; const DestinationFactor: TBlendingDestinationFactor; const Color: TVector4); overload; deprecated 'use DrawRectangle';
procedure GLBlendRectangle(const Rect: TRectangle; const Color: TVector4); overload; 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';
function GetProjectionMatrix: TMatrix4; deprecated 'use RenderContext.ProjectionMatrix';
procedure SetProjectionMatrix(const Value: TMatrix4); deprecated 'use RenderContext.ProjectionMatrix';
function PerspectiveProjection(const fovy, aspect, ZNear, ZFar: Single): TMatrix4;
function OrthoProjection(const Dimensions: TFloatRectangle; const ZNear: Single = -1; const ZFar: Single = 1): TMatrix4;
function FrustumProjection(const Dimensions: TFloatRectangle; const ZNear, ZFar: Single): TMatrix4;
function GetDepthRange: TDepthRange; deprecated 'use RenderContext.DepthRange';
procedure SetDepthRange(const Value: TDepthRange); deprecated 'use RenderContext.DepthRange';

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 = TVector2 deprecated 'use TVector2';
PVector2f = PVector2 deprecated 'use PVector2';
TVector2ub = TVector2Byte deprecated 'use TVector2Byte';
PVector2ub = PVector2Byte deprecated 'use PVector2Byte';
TVector2i = TVector2Integer deprecated 'use TVector2Integer';
PVector2i = PVector2Integer deprecated 'use PVector2Integer';
TVector3f = TVector3 deprecated 'use TVector3';
PVector3f = PVector3 deprecated 'use PVector3';
TVector3ub = TVector3Byte deprecated 'use TVector3Byte';
PVector3ub = PVector3Byte deprecated 'use PVector3Byte';
TVector3i = TVector3Integer deprecated 'use TVector3Integer';
PVector3i = PVector3Integer deprecated 'use PVector3Integer';
TVector4f = TVector4 deprecated 'use TVector4';
PVector4f = PVector4 deprecated 'use PVector4';
TVector4ub = TVector4Byte deprecated 'use TVector4Byte';
PVector4ub = PVector4Byte deprecated 'use PVector4Byte';
TVector4i = TVector4Integer deprecated 'use TVector4Integer';
PVector4i = PVector4Integer deprecated 'use PVector4Integer';
TMatrix2f = TMatrix2 deprecated 'use TMatrix2';
PMatrix2f = PMatrix2 deprecated 'use PMatrix2';
TMatrix3f = TMatrix3 deprecated 'use TMatrix3';
PMatrix3f = PMatrix3 deprecated 'use PMatrix3';
TMatrix4f = TMatrix4 deprecated 'use TMatrix4';
PMatrix4f = PMatrix4 deprecated 'use PMatrix4';
TEnableTextureTarget = (...);
TGLSupport = (...);
TPrimitiveMode = (...);
TBlendingSourceFactor = (...);
TBlendingDestinationFactor = (...);
TClearBuffer = (...);
TClearBuffers = set of TClearBuffer;
TDepthRange = (...);

Constants

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

Variables

GLOutOfMemoryError: boolean = false;
CurrentColor: TCastleColor deprecated 'instead of this, use drawing routines that take Color from parameters or properties, like TCastleFont.Print(X,Y,Color,...) or TGLImage.Color';
WindowPos: TVector2Integer deprecated 'use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';
GLFeatures: TGLFeatures;
Viewport2DSize: TVector2;
RenderContext: TRenderContext;
property ProjectionMatrix: TMatrix4 read GetProjectionMatrix write SetProjectionMatrix;
property DepthRange: TDepthRange read GetDepthRange write SetDepthRange;

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; deprecated 'this function is no longer useful, as you should not use GLU in cross-platform programs';

Warning: this symbol is deprecated: this function is no longer useful, as you should not use GLU in cross-platform programs

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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

Warning: this symbol is deprecated: use other methods to transform things, e.g. TUIControl position / anchors, or TCastleTransform 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 TCastleTransform for TCastleScene, or TTransformNode in X3D';

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

 
procedure glClipPlane(plane: GLenum; const V: TVector4Double); overload;
 
procedure glNormalv(const v: TVector3); 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);
 
procedure GLSetEnabled(Value: TGLenum; IsEnabled: boolean);

Enable or disable given OpenGL flag.

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: TVector3; 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: TVector3; const Opacity: Single); overload; 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); overload; 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(const Writeable: boolean);

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

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

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: TVector3; const FadeIntensity: Single); overload;

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); overload;
 
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single);
 
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const AFadeColor: TVector3; const FadeIntensity: Single); overload; 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); overload; 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: TVector4); overload; 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: TVector4); overload; 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

 
function GetProjectionMatrix: TMatrix4; deprecated 'use RenderContext.ProjectionMatrix';

Warning: this symbol is deprecated: use RenderContext.ProjectionMatrix

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

procedure SetProjectionMatrix(const Value: TMatrix4); deprecated 'use RenderContext.ProjectionMatrix';

Warning: this symbol is deprecated: use RenderContext.ProjectionMatrix

 
function PerspectiveProjection(const fovy, aspect, ZNear, ZFar: Single): TMatrix4;

Calculate projection matrix, and set RenderContext.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): TMatrix4;
 
function FrustumProjection(const Dimensions: TFloatRectangle; const ZNear, ZFar: Single): TMatrix4;
 
function GetDepthRange: TDepthRange; deprecated 'use RenderContext.DepthRange';

Warning: this symbol is deprecated: use RenderContext.DepthRange

depth range —————————————————————-

procedure SetDepthRange(const Value: TDepthRange); deprecated 'use RenderContext.DepthRange';

Warning: this symbol is deprecated: use RenderContext.DepthRange

 

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 = TVector2 deprecated 'use TVector2';

Warning: this symbol is deprecated: use TVector2

 
PVector2f = PVector2 deprecated 'use PVector2';

Warning: this symbol is deprecated: use PVector2

 
TVector2ub = TVector2Byte deprecated 'use TVector2Byte';

Warning: this symbol is deprecated: use TVector2Byte

 
PVector2ub = PVector2Byte deprecated 'use PVector2Byte';

Warning: this symbol is deprecated: use PVector2Byte

 
TVector2i = TVector2Integer deprecated 'use TVector2Integer';

Warning: this symbol is deprecated: use TVector2Integer

 
PVector2i = PVector2Integer deprecated 'use PVector2Integer';

Warning: this symbol is deprecated: use PVector2Integer

 
TVector3f = TVector3 deprecated 'use TVector3';

Warning: this symbol is deprecated: use TVector3

 
PVector3f = PVector3 deprecated 'use PVector3';

Warning: this symbol is deprecated: use PVector3

 
TVector3ub = TVector3Byte deprecated 'use TVector3Byte';

Warning: this symbol is deprecated: use TVector3Byte

 
PVector3ub = PVector3Byte deprecated 'use PVector3Byte';

Warning: this symbol is deprecated: use PVector3Byte

 
TVector3i = TVector3Integer deprecated 'use TVector3Integer';

Warning: this symbol is deprecated: use TVector3Integer

 
PVector3i = PVector3Integer deprecated 'use PVector3Integer';

Warning: this symbol is deprecated: use PVector3Integer

 
TVector4f = TVector4 deprecated 'use TVector4';

Warning: this symbol is deprecated: use TVector4

 
PVector4f = PVector4 deprecated 'use PVector4';

Warning: this symbol is deprecated: use PVector4

 
TVector4ub = TVector4Byte deprecated 'use TVector4Byte';

Warning: this symbol is deprecated: use TVector4Byte

 
PVector4ub = PVector4Byte deprecated 'use PVector4Byte';

Warning: this symbol is deprecated: use PVector4Byte

 
TVector4i = TVector4Integer deprecated 'use TVector4Integer';

Warning: this symbol is deprecated: use TVector4Integer

 
PVector4i = PVector4Integer deprecated 'use PVector4Integer';

Warning: this symbol is deprecated: use PVector4Integer

 
TMatrix2f = TMatrix2 deprecated 'use TMatrix2';

Warning: this symbol is deprecated: use TMatrix2

 
PMatrix2f = PMatrix2 deprecated 'use PMatrix2';

Warning: this symbol is deprecated: use PMatrix2

 
TMatrix3f = TMatrix3 deprecated 'use TMatrix3';

Warning: this symbol is deprecated: use TMatrix3

 
PMatrix3f = PMatrix3 deprecated 'use PMatrix3';

Warning: this symbol is deprecated: use PMatrix3

 
TMatrix4f = TMatrix4 deprecated 'use TMatrix4';

Warning: this symbol is deprecated: use TMatrix4

 
PMatrix4f = PMatrix4 deprecated 'use PMatrix4';

Warning: this symbol is deprecated: use PMatrix4

 
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;
 
TDepthRange = (...);

Possible values of TRenderContext.DepthRange.

Values
  • drFull
  • drNear
  • drFar

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.

CurrentColor: 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

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.

WindowPos: TVector2Integer deprecated 'use drawing routines that take position as parameters, like TGLImageCore.Draw(X,Y) or TCastleFont.Print(X,Y,...)';

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

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,...).

GLFeatures: TGLFeatures;
 
Viewport2DSize: TVector2;

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

RenderContext: TRenderContext;

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

TODO: In the future, this global singleton may be removed, and this may be accessible instead through a new TUIControl.Render parameter.

property ProjectionMatrix: TMatrix4 read GetProjectionMatrix write SetProjectionMatrix;

Current projection matrix.

For OpenGLES, this is merely a global ProjectionMatrix variable. It must be passed to shaders used by TCastleScene rendering 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.

property DepthRange: TDepthRange read GetDepthRange write SetDepthRange;
 

Generated by PasDoc 0.15.0.