Unit CastleGLUtils
Description
Various utilities for OpenGL(ES) rendering.
Source: src/base_rendering/castleglutils.pas (line 17).
Uses
- SysUtils
- Math
- Generics.Collections
- Classes
- CastleGL
- CastleImages
- CastleUtils
- CastleVectors
- CastleRectangles
- CastleColors
- CastleProjection
- CastleRenderOptions
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Class TGLMemoryInfo |
OpenGL memory information. |
Class TGLFeatures |
OpenGL(ES) features, analyzed based on extensions and version. |
Record TLineStipple |
|
Class TVertexArrayObject |
Vertex array object. |
Functions and Procedures
procedure GLInformationInitialize; |
function StrToCapabilities(const S: String): TGLRequestCapabilities; |
procedure DrawRectangle(const R: TRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
procedure DrawRectangle(const R: TFloatRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
procedure DrawRectangleOutline(const R: TRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
procedure DrawRectangleOutline(const R: TFloatRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
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); overload; |
procedure DrawCircle(const Middle: TVector2; const HorizontalRadius, VerticalRadius: Single; const Color: TCastleColor; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
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); overload; |
procedure DrawCircleOutline(const Middle: TVector2; const HorizontalRadius, VerticalRadius: Single; const Color: TCastleColor; const LineWidth: Single = 1; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
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); overload; |
procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const Points: array of TVector2; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1); overload; |
procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const LineStipple: TLineStipple; const Points: array of TVector2; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1); overload; |
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 GLFadeRectangleDark(const Rect: TFloatRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
procedure GLFadeRectangleLight(const Rect: TFloatRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
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( SourceFactor: TBlendingSourceFactor; DestinationFactor: TBlendingDestinationFactor); deprecated 'use RenderContext.BlendingEnable'; |
function GLInformationString: String; |
function GLInformationStringSummary: String; |
Types
TGLBuffer = TGLuint ; |
TGLFramebuffer = TGLuint ; |
TGLRenderbuffer = TGLuint ; |
TGLProgram = TGLuint ; |
TGLShader = TGLuint ; |
TGLTexture = TGLuint ; |
TGLVertexArrayObject = TGLuint ; |
TGLQuery = TGLuint ; |
TGLUniformLocation = TGLint ; |
TGLAttribLocation = TGLint; |
TGLRequestCapabilities = (...); |
TPrimitiveMode = (...); |
Constants
GLObjectNone = 0 ; |
GLUniformLocationNone = -1 ; |
GLAttribLocationNone = -1; |
CapabilitiesStr: array [TGLRequestCapabilities] of String = (
'automatic',
'force-fixed-function',
'force-modern'
); |
DefaultCircleSlices = 32; |
Variables
GLFeatures: TGLFeatures; |
LogGLInformationVerbose: Boolean = false; |
Description
Functions and Procedures
procedure GLInformationInitialize; |
|
Initialize GLVersion and GLFeatures. Source: src/base_rendering/castleglutils_features.inc (line 629). |
function StrToCapabilities(const S: String): TGLRequestCapabilities; |
|
Convert a string (like command-line argument) to TGLRequestCapabilities. Source: src/base_rendering/castleglutils_features.inc (line 638). |
procedure DrawRectangle(const R: TRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
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 Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 55). |
procedure DrawRectangle(const R: TFloatRectangle; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 59). |
procedure DrawRectangleOutline(const R: TRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
Draw a rectangle frame. Like with DrawPrimitive2D: Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 70). |
procedure DrawRectangleOutline(const R: TFloatRectangle; const Color: TCastleColor; const LineWidth: Single = 1; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 75). |
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); overload; |
|
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 Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 87). |
procedure DrawCircle(const Middle: TVector2; const HorizontalRadius, VerticalRadius: Single; const Color: TCastleColor; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 94). |
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); overload; |
|
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 Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 108). |
procedure DrawCircleOutline(const Middle: TVector2; const HorizontalRadius, VerticalRadius: Single; const Color: TCastleColor; const LineWidth: Single = 1; const CircleSlices: Cardinal = DefaultCircleSlices; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 116). |
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); overload; |
|
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 Blending is automatically used if Color alpha < 1. ForceBlending forces the usage of blending. When it is
Parameters
Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 151). |
procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const Points: array of TVector2; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 159). |
procedure DrawPrimitive2D(const Mode: TPrimitiveMode; const LineStipple: TLineStipple; const Points: array of TVector2; const Color: TCastleColor; const BlendingSourceFactor: TBlendingSourceFactor = bsSrcAlpha; const BlendingDestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha; const ForceBlending: boolean = false; const LineWidth: Single = 1; const PointSize: Cardinal = 1); overload; |
|
Draw primitive, using a stipple (pattern) for line rendering. Note that the stipple is ignored on mobile (OpenGLES). Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 170). |
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. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 197). |
procedure GLFadeRectangleDark(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 200). |
procedure GLFadeRectangleDark(const Rect: TFloatRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 203). |
procedure GLFadeRectangleLight(const Rect: TRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 206). |
procedure GLFadeRectangleLight(const Rect: TFloatRectangle; const AFadeColor: TCastleColor; const FadeIntensity: Single); overload; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 209). |
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 This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 212). |
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 This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 215). |
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. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 221). |
procedure GLBlendRectangle(const Rect: TRectangle; const Color: TVector4); overload; deprecated 'use DrawRectangle'; |
|
Warning: this symbol is deprecated: use DrawRectangle This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 225). |
procedure GLBlendFunction( SourceFactor: TBlendingSourceFactor; DestinationFactor: TBlendingDestinationFactor); deprecated 'use RenderContext.BlendingEnable'; |
|
Warning: this symbol is deprecated: use RenderContext.BlendingEnable Call OpenGL glBlendFunc. Accepts parameters as enumerated types TBlendingSourceFactor, TBlendingDestinationFactor. Secures from using source or destination factor unsupported on current OpenGL version: makes a warnings and falls back on a sensible default (so it will always call glBlendFunc anyway). Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 233). |
function GLInformationString: String; |
|
Multiline string describing attributes of current OpenGL(ES) library. This simply queries OpenGL(ES) using glGet* functions about many things. Does not change OpenGL(ES) 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( Source: src/base_rendering/castleglutils_information.inc (line 28). |
function GLInformationStringSummary: String; |
|
One-line string summarizing current OpenGL(ES). Source: src/base_rendering/castleglutils_information.inc (line 31). |
Types
TGLBuffer = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 25). |
TGLFramebuffer = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 26). |
TGLRenderbuffer = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 27). |
TGLProgram = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 28). |
TGLShader = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 29). |
TGLTexture = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 30). |
TGLVertexArrayObject = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 31). |
TGLQuery = TGLuint ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 32). |
TGLUniformLocation = TGLint ; |
|
Uniform location in WebGL / OpenGL / OpenGLES. Note: This is *signed*, TGLint, deliberately. glGetUniformLocation returns -1 when uniform not found ( https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGetUniformLocation.xhtml ), and our API in CastleGLShaders checks for it. Source: src/base_rendering/castleglutils_types.inc (line 40). |
TGLAttribLocation = TGLint; |
|
Attribute location in WebGL / OpenGL / OpenGLES. Note: Attribute location is TGLint in both WebGL and OpenGL / OpenGLES and can be -1. See https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getAttribLocation . So it's inconsistent with uniform location in WebGL. We define Source: src/base_rendering/castleglutils_types.inc (line 49). |
TGLRequestCapabilities = (...); |
|
OpenGL(ES) capabilities to request at context creation. Use with TGLFeatures.RequestCapabilities. Values
Source: src/base_rendering/castleglutils_features.inc (line 95). |
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
Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 26). |
Constants
GLObjectNone = 0 ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 52). |
GLUniformLocationNone = -1 ; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 53). |
GLAttribLocationNone = -1; |
|
This item has no description. Source: src/base_rendering/castleglutils_types.inc (line 54). |
CapabilitiesStr: array [TGLRequestCapabilities] of String = (
'automatic',
'force-fixed-function',
'force-modern'
); |
|
This item has no description. Source: src/base_rendering/castleglutils_features.inc (line 151). |
DefaultCircleSlices = 32; |
|
This item has no description. Source: src/base_rendering/castleglutils_draw_primitive_2d.inc (line 47). |
Variables
GLFeatures: TGLFeatures; |
|
This item has no description. Source: src/base_rendering/castleglutils_features.inc (line 632). |
LogGLInformationVerbose: Boolean = false; |
|
Much more verbose logging of current context capabilities in GLInformationInitialize. Source: src/base_rendering/castleglutils_features.inc (line 635). |
Generated by PasDoc 0.17.0.snapshot.