Class TRenderContext
Unit
Declaration
type TRenderContext = class(TComponent)
Description
The OpenGL / OpenGLES context state. We try hard to make this a very, very small class, because usually it's better to introduce a clean higher-level API than to track the OpenGL context state in a simple global RenderContext instance.
Use the methods and properties of this class only when this context is current, which means it's set as RenderContext value.
Do not depend on the context state being persistent. The RenderContext does not change during a single TCastleUserInterface.OnRender method (with all 2D and 3D stuff rendered inside), but that's all we guarantee. On desktops, you control the context creation / destruction explicitly (by opening / closing the TCastleWindow). But on mobile devices – the context may get destroyed and created at almost any moment. So do not use the instance of RenderContext to store anything you rely on being stored. Instead, use your own variables for this, and only synchronize RenderContext with your variables.
Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 101).
Hierarchy
- TObject
- TPersistent
- TComponent
- TRenderContext
Overview
Fields
| Public | InternalClearColorsByDraw: Boolean; |
Methods
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | procedure Clear(Buffers: TClearBuffers; const ClearColor: TCastleColor); |
| Public | procedure ScissorEnable(const Rect: TRectangle); |
| Public | procedure ScissorDisable; |
| Public | function FinalScissor(out Rect: TRectangle): Boolean; |
| Public | function ColorBufferHasAlpha: Boolean; deprecated 'use GLFeatures.AlphaBits > 0'; |
| Public | procedure BlendingEnable( const SourceFactor: TBlendingSourceFactor = bsSrcAlpha; const DestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha); |
| Public | procedure BlendingDisable; |
| Public | procedure FixedFunctionAlphaTestEnable(const AlphaCutoff: Single = 0.5); |
| Public | procedure FixedFunctionAlphaTestDisable; |
| Public | procedure PolygonOffsetEnable(const Scale, Bias: Single); |
| Public | procedure PolygonOffsetDisable; |
Properties
| Public | property LineWidth: Single read FLineWidth write SetLineWidth default 1; |
| Public | property PointSize: Single read FPointSize write SetPointSize default 1; |
| Public | property GlobalAmbient: TCastleColorRGB read FGlobalAmbient write SetGlobalAmbient; |
| Public | property ProjectionMatrix: TMatrix4
read FProjectionMatrix write SetProjectionMatrix; |
| Public | property DepthRange: TDepthRange read FDepthRange write SetDepthRange; |
| Public | property CullFace: boolean read FCullFace write SetCullFace
default false; |
| Public | property FrontFaceCcw: boolean read FFrontFaceCcw write SetFrontFaceCcw
default true; |
| Public | property DepthTest: Boolean read FDepthTest write SetDepthTest default false; |
| Public | property DepthFunc: TDepthFunction read FDepthFunc write SetDepthFunc default dfLess; |
| Public | property ColorMask: boolean
read GetColorMask write SetColorMask default true; deprecated 'use ColorChannels'; |
| Public | property ColorChannels: TColorChannels
read FColorChannels write SetColorChannels default AllColorChannels; |
| Public | property DepthBufferUpdate: Boolean
read FDepthBufferUpdate write SetDepthBufferUpdate default true; |
| Public | property Viewport: TRectangle read FViewport write SetViewport; |
| Public | property ViewportDelta: TVector2Integer read FViewportDelta write SetViewportDelta; |
| Public | property CurrentProgram: TGLSLProgram read FCurrentProgram write SetCurrentProgram; |
| Public | property CurrentVao: TVertexArrayObject read FCurrentVao write SetCurrentVao; |
| Public | property FixedFunctionLighting: boolean read FFixedFunctionLighting write SetFixedFunctionLighting; |
| Public | property LineType: TLineType read FLineType write SetLineType; |
| Public | property PolygonOffset: TPolygonOffset read FPolygonOffset write SetPolygonOffset; |
| Public | property BindBuffer[const Target: TBufferTarget]: TGLBuffer
read GetBoundBuffer write SetBoundBuffer; |
Description
Fields
| Public | InternalClearColorsByDraw: Boolean; |
|
If Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 167). | |
Methods
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 169). | |
| Public | destructor Destroy; override; |
|
This item has no description. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 170). | |
| Public | procedure Clear(Buffers: TClearBuffers; const ClearColor: TCastleColor); |
|
Clear the whole buffer contents. Never call OpenGL glClear or glClearColor, always use this method. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 175). | |
| Public | procedure ScissorEnable(const Rect: TRectangle); |
|
Enable or disable scissor. Never call OpenGL glScissor or glEnable(GL_SCISSOR_TEST) / glDisable(GL_SCISSOR_TEST) directly, or push/pop the related attrib (in case of fixed-function pipeline). Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 207). | |
| Public | procedure ScissorDisable; |
|
This item has no description. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 208). | |
| Public | function FinalScissor(out Rect: TRectangle): Boolean; |
|
Scissor rectangle to which we clip the view. This is determined by all TScissor that are currently enabled. Returns Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 290). | |
| Public | function ColorBufferHasAlpha: Boolean; deprecated 'use GLFeatures.AlphaBits > 0'; |
|
Warning: this symbol is deprecated: use GLFeatures.AlphaBits > 0 Does the current color buffer have any alpha channel. Some blending features depend on storing alpha in the color channel. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 303). | |
| Public | procedure BlendingEnable( const SourceFactor: TBlendingSourceFactor = bsSrcAlpha; const DestinationFactor: TBlendingDestinationFactor = bdOneMinusSrcAlpha); |
|
Enable blending, sets also blending function. See https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml for blending equations. You must use this to change blending parameters, this class assumes it knows the blending state always. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 310). | |
| Public | procedure BlendingDisable; |
|
This item has no description. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 313). | |
| Public | procedure FixedFunctionAlphaTestEnable(const AlphaCutoff: Single = 0.5); |
|
Enable alpha test with old/buggy OpenGL implementations that use deprecated fixed-function pipeline. This is simply ignored on modern GPUs when "not GLFeatures.EnableFixedFunction". Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 317). | |
| Public | procedure FixedFunctionAlphaTestDisable; |
|
This item has no description. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 318). | |
| Public | procedure PolygonOffsetEnable(const Scale, Bias: Single); |
|
Shortcut for setting PolygonOffset with PolygonOffset.Enabled = Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 331). | |
| Public | procedure PolygonOffsetDisable; |
|
Shortcut for setting PolygonOffset with PolygonOffset.Enabled = Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 333). | |
Properties
| Public | property LineWidth: Single read FLineWidth write SetLineWidth default 1; |
|
The rendered line width. Never call OpenGL glLineWidth directly. Do not access this property directly, unless you make direct OpenGL/OpenGLES calls. In normal circumstances, engine API (like DrawPrimitive2D or TCastleScene) set this automatically. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 183). | |
| Public | property PointSize: Single read FPointSize write SetPointSize default 1; |
|
The rendered point size. Never call OpenGL glPointSize directly. Do not access this property directly, unless you make direct OpenGL/OpenGLES calls. In normal circumstances, engine API (like DrawPrimitive2D or TCastleScene) set this automatically. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 191). | |
| Public | property GlobalAmbient: TCastleColorRGB read FGlobalAmbient write SetGlobalAmbient; |
|
Global ambient lighting. This is added to every 3D object color, multiplied by material ambient. The default value is (0.2, 0.2, 0.2). It matches default GL_LIGHT_MODEL_AMBIENT in fixed-function OpenGL. It also matches the required value of VRML 1.0 specification. For VRML 2.0 / X3D, lighting equations suggest that it should be zero. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 200). | |
| Public | property ProjectionMatrix: TMatrix4
read FProjectionMatrix write SetProjectionMatrix; |
|
Current projection matrix. When GLFeatures.EnableFixedFunction = true, setting this also sets fixed-function projection matrix. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 215). | |
| Public | property DepthRange: TDepthRange read FDepthRange write SetDepthRange; |
|
Use this to operate on OpenGL glDepthRange. For now, our engine has very simple use for this, for TPlayer.RenderOnTop. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 220). | |
| Public | property CullFace: boolean read FCullFace write SetCullFace
default false; |
|
Should we use backface-culling (ignore some faces during rendering). Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 223). | |
| Public | property FrontFaceCcw: boolean read FFrontFaceCcw write SetFrontFaceCcw
default true; |
|
Is the front face ordered counter-clockwise. The "front face" is important to interpreting the CullFace and to interpret the normal vectors (they point outward from front face). Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 229). | |
| Public | property DepthTest: Boolean read FDepthTest write SetDepthTest default false; |
|
Depth testing means we reject things that don't pass DepthFunc. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 233). | |
| Public | property DepthFunc: TDepthFunction read FDepthFunc write SetDepthFunc default dfLess; |
|
Function to use when comparing depth, only if DepthTest. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 236). | |
| Public | property ColorMask: boolean
read GetColorMask write SetColorMask default true; deprecated 'use ColorChannels'; |
|
Warning: this symbol is deprecated: use ColorChannels Are color buffer channels changed by rendering. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 240). | |
| Public | property ColorChannels: TColorChannels
read FColorChannels write SetColorChannels default AllColorChannels; |
|
Which color buffer channels are written by rendering. This affects all rendering, including TDrawableImage.Draw. Note that this state may be internally modified by various engine rendering functions too, e.g. by TCastleScene.LocalRender, depending on rendering attributes. So it is only reliable for you to modify this temporarily, and during your own rendering. E.g. change Example uses:
Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 270). | |
| Public | property DepthBufferUpdate: Boolean
read FDepthBufferUpdate write SetDepthBufferUpdate default true; |
|
Is depth buffer updated by rendering. This affects all rendering that enables depth testing (which in practice means only TCastleScene in CGE). Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 276). | |
| Public | property Viewport: TRectangle read FViewport write SetViewport; |
|
Controls OpenGL viewport. This is always shifted by ViewportDelta. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 280). | |
| Public | property ViewportDelta: TVector2Integer read FViewportDelta write SetViewportDelta; |
|
Shifts the rectangle passed to Viewport. Only the TCastleScreenEffects should control this. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 284). | |
| Public | property CurrentProgram: TGLSLProgram read FCurrentProgram write SetCurrentProgram; |
|
Currently enabled GLSL program. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 295). | |
| Public | property CurrentVao: TVertexArrayObject read FCurrentVao write SetCurrentVao; |
|
Currently bound vertex array object. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 299). | |
| Public | property FixedFunctionLighting: boolean read FFixedFunctionLighting write SetFixedFunctionLighting; |
|
Fixed-function GL_LIGHTING state. This is simply ignored on modern GPUs when "not GLFeatures.EnableFixedFunction". Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 322). | |
| Public | property LineType: TLineType read FLineType write SetLineType; |
|
Line type determines OpenGL glLineStipple, GL_LINE_STIPPLE enable state. Note: This is not supported on OpenGLES. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 326). | |
| Public | property PolygonOffset: TPolygonOffset read FPolygonOffset write SetPolygonOffset; |
|
Current polygon offset state. You can read and write it. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 329). | |
| Public | property BindBuffer[const Target: TBufferTarget]: TGLBuffer
read GetBoundBuffer write SetBoundBuffer; |
|
Bind buffer to target, just like glBindBuffer. Optimized to do nothing if given buffer is already bound. This optimization actually matters for optimization (Android Samsung Galaxy Tab, castle-model-viewer-mobile displaying inspector). Without it, TDrawableImage does a lot of redundant glBindBuffer calls. Source: ../castle-engine/src/base_rendering/castlerendercontext.pas (line 341). | |
Generated by PasDoc 0.17.0.snapshot.