Class TGLFeatures

Unit

Declaration

type TGLFeatures = class(TObject)

Description

OpenGL(ES) features, analyzed based on extensions and version. A single instance of this class is assigned to GLFeatures after the first rendering context was created. If you have multiple rendering contexts, our engine assumes they share resources and have equal features.

Hierarchy

  • TObject
  • TGLFeatures

Overview

Fields

Public nested const ModernVersionMajor = 3;
Public nested const ModernVersionMinor = 3;

Methods

Public constructor Create;
Public destructor Destroy; override;
Public function MaxTextureUnits: Cardinal;

Properties

Public property Version_1_2: Boolean read FVersion_1_2;
Public property Version_1_3: Boolean read FVersion_1_3;
Public property Version_1_4: Boolean read FVersion_1_4;
Public property Version_1_5: Boolean read FVersion_1_5;
Public property Version_2_0: Boolean read FVersion_2_0;
Public property Version_2_1: Boolean read FVersion_2_1;
Public property Version_3_0: Boolean read FVersion_3_0;
Public property Version_3_1: Boolean read FVersion_3_1;
Public property Version_3_2: Boolean read FVersion_3_2;
Public property Version_3_3: Boolean read FVersion_3_3;
Public property Version_4_0: Boolean read FVersion_4_0;
Public property TextureFilterAnisotropic: Boolean read FTextureFilterAnisotropic;
Public property NV_multisample_filter_hint: Boolean read FNV_multisample_filter_hint;
Public property OcclusionQuery: Boolean read FOcclusionQuery;
Public property CLAMP_TO_EDGE: TGLenum read FCLAMP_TO_EDGE;
Public property MaxTextureSize: Cardinal read FMaxTextureSize;
Public property MaxLights: Cardinal read FMaxLights;
Public property MaxCubeMapTextureSize: Cardinal read FMaxCubeMapTextureSize;
Public property MaxTexture3DSize: Cardinal read FMaxTexture3DSize;
Public property MaxTextureMaxAnisotropy: Single read FMaxTextureMaxAnisotropy;
Public property OcclusionQueryCounterBits: TGLint read FOcclusionQueryCounterBits;
Public property MaxRenderbufferSize: TGLuint read FMaxRenderbufferSize;
Public property MaxClipPlanes: Cardinal read FMaxClipPlanes;
Public property Multisample: Boolean read FMultisample;
Public property MaxTextureUnitsFixedFunction: Cardinal read FMaxTextureUnitsFixedFunction;
Public property MaxTextureUnitsShaders: Cardinal read FMaxTextureUnitsShaders;
Public property UseMultiTexturing: Boolean read FUseMultiTexturing;
Public property Texture3D: Boolean read FTexture3D;
Public property Framebuffer: Boolean read FFramebuffer;
Public property FramebufferBlit: Boolean read FFramebufferBlit;
Public property FBOMultiSampling: Boolean read FFBOMultiSampling;
Public property CurrentMultiSampling: Cardinal read FCurrentMultiSampling;
Public property PackedDepthStencil: Boolean read FPackedDepthStencil;
Public property ShadowVolumesPossible: Boolean read FShadowVolumesPossible;
Public property TextureNonPowerOfTwo: Boolean read FTextureNonPowerOfTwo;
Public property TextureCubeMap: Boolean read FTextureCubeMap;
Public property TextureCompression: TTextureCompressions read FTextureCompression;
Public property VertexBufferObject: Boolean read FVertexBufferObject;
Public property VertexArrayObject: Boolean read FVertexArrayObject;
Public property BlendConstant: Boolean read FBlendConstant;
Public property TextureFloat: Boolean read FTextureFloat;
Public property TextureDepth: Boolean read FTextureDepth;
Public property TextureDepthCompare: Boolean read FTextureDepthCompare;
Public property Shaders: Boolean read FShaders;
Public property EnableFixedFunction: Boolean read FEnableFixedFunction;
Public class property RequestCapabilities: TGLRequestCapabilities read FRequestCapabilities write SetRequestCapabilities;
Public class property Debug: Boolean read FDebug write SetDebug;
Public property Memory: TGLMemoryInfo read FMemory;
Public property MaxViewportDimensions: TVector2Integer read FMaxViewportDimensions;
Public property TextureModernFormatsAndSwizzle: Boolean read FTextureModernFormatsAndSwizzle;
Public property RedBits: TGLint read FRedBits;
Public property GreenBits: TGLint read FGreenBits;
Public property BlueBits: TGLint read FBlueBits;
Public property AlphaBits: TGLint read FAlphaBits;
Public property DepthBits: TGLint read FDepthBits;
Public property StencilBits: TGLint read FStencilBits;
Public property DoubleBuffer: Boolean read FDoubleBuffer;
Public property LineWidth: TVector2 read FLineWidth;
Public property TextureMaxLevel: Boolean read FTextureMaxLevel;

Description

Fields

Public nested const ModernVersionMajor = 3;

OpenGL version considered "modern" for us, that we can use with its "core" profile.

We need >= 3.2 as before it, there were no profiles (only "forward compatibility").

We need >= 3.3 as it has texture swizzle. When we don't have texture swizzle, then we cannot use modern OpenGL texture format constants, and so we need compatibility. See TextureModernFormatsAndSwizzle .

Public nested const ModernVersionMinor = 3;

This item has no description.

Methods

Public constructor Create;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public function MaxTextureUnits: Cardinal;

Maximum number of texture units you can safely always use. If EnableFixedFunction, this is MaxTextureUnitsFixedFunction, otherwise MaxTextureUnitsShaders.

Properties

Public property Version_1_2: Boolean read FVersion_1_2;

OpenGL versions supported. Checked by looking at GL version string and by checking whether actual entry points are available.

This is important because bad OpenGL implementations (like the horrible ATI Linux closed drivers) sometimes lie, claiming support in the GL version string but actually lacking proper function entry points. We check the actual presence of entry points (GLExt.Load_GL_version_x_x do that).

We *also* check version string (TGLVersion.AtLeast), since OpenGL may have some buggy entry point in case of work-in-progress features (not yet advertised in GL version string), e.g. Mesa 6.x had such buggy glStencilOpSeparate. This is correct OpenGL behavior AFAIK, and we handle it.

Public property Version_1_3: Boolean read FVersion_1_3;

This item has no description.

Public property Version_1_4: Boolean read FVersion_1_4;

This item has no description.

Public property Version_1_5: Boolean read FVersion_1_5;

This item has no description.

Public property Version_2_0: Boolean read FVersion_2_0;

This item has no description.

Public property Version_2_1: Boolean read FVersion_2_1;

This item has no description.

Public property Version_3_0: Boolean read FVersion_3_0;

This item has no description.

Public property Version_3_1: Boolean read FVersion_3_1;

This item has no description.

Public property Version_3_2: Boolean read FVersion_3_2;

This item has no description.

Public property Version_3_3: Boolean read FVersion_3_3;

This item has no description.

Public property Version_4_0: Boolean read FVersion_4_0;

This item has no description.

Public property TextureFilterAnisotropic: Boolean read FTextureFilterAnisotropic;

Supports anisotropic texture filtering, as EXT_texture_filter_anisotropic extension (possible for both OpenGL and OpenGLES). This was introduced into OpenGL core late, but is widely available as extension. https://www.khronos.org/opengl/wiki/Sampler_Object#Anisotropic_filtering https://www.khronos.org/opengl/wiki/Ubiquitous_Extension

Public property NV_multisample_filter_hint: Boolean read FNV_multisample_filter_hint;

This item has no description.

Public property OcclusionQuery: Boolean read FOcclusionQuery;

Occlusion query (glGenQueries, glGetQueryObject, glBeginQuery, glEndQuery) in core OpenGL or OpenGLES.

Public property CLAMP_TO_EDGE: TGLenum read FCLAMP_TO_EDGE;

GL_CLAMP_TO_EDGE, if available in current OpenGL version. Otherwise GL_CLAMP. Use this (instead of just GL_CLAMP_TO_EDGE) to work with really ancient OpenGL versions before 1.2.

Public property MaxTextureSize: Cardinal read FMaxTextureSize;

Constant (for given context) OpenGL limits. Initialized to 0 if appropriate OpenGL functionality is not available.

Note that MaxLights is only relevant if we use OpenGL fixed-function pipeline. Otherwise the actual limit is defined purely by Scene.RenderOptions.MaxLightsPerShape, specific to each TCastleScene, and is completely configurable (can be higher or lower than MaxLights).

Public property MaxLights: Cardinal read FMaxLights;

This item has no description.

Public property MaxCubeMapTextureSize: Cardinal read FMaxCubeMapTextureSize;

This item has no description.

Public property MaxTexture3DSize: Cardinal read FMaxTexture3DSize;

This item has no description.

Public property MaxTextureMaxAnisotropy: Single read FMaxTextureMaxAnisotropy;

This item has no description.

Public property OcclusionQueryCounterBits: TGLint read FOcclusionQueryCounterBits;

This item has no description.

Public property MaxRenderbufferSize: TGLuint read FMaxRenderbufferSize;

This item has no description.

Public property MaxClipPlanes: Cardinal read FMaxClipPlanes;

This item has no description.

Public property Multisample: Boolean read FMultisample;

Multisampling is available and can be disabled / enabled by GL_MULTISAMPLE flag (it is enabled by default, if buffers have multiple samples available).

Public property MaxTextureUnitsFixedFunction: Cardinal read FMaxTextureUnitsFixedFunction;

Number of texture units available for fixed-function pipeline.

Since querying glGetInteger(GL_MAX_TEXTURE_UNITS) is deprecated (or not even possible in case of OpenGLES or "core" profile) and we want to keep fixed-function support as simple as possible, we just assume 2 (the only number guaranteed) if only multi-texturing is available (UseMultiTexturing).

Public property MaxTextureUnitsShaders: Cardinal read FMaxTextureUnitsShaders;

Number of texture units available for shader pipeline.

Public property UseMultiTexturing: Boolean read FUseMultiTexturing;

Are all OpenGL multi-texturing extensions for VRML/X3D MultiTexture support available.

This used to check a couple of multitexturing extensions, like ARB_multitexture. Right now, it simply checks for OpenGL 1.3 version. It is supported by virtually all existing GPUs. So it's acceptable to just check it, and write your code for 1.3, and eventual fallback code (when this is false) write only for really ancient GPUs.

Public property Texture3D: Boolean read FTexture3D;

Are 3D textures (GL_TEXTURE_3D, glTexImage3D) supported by core OpenGL or OpenGLES.

Public property Framebuffer: Boolean read FFramebuffer;

Framebuffer supported, by core OpenGL or OpenGLES.

Public property FramebufferBlit: Boolean read FFramebufferBlit;

glFramebufferBlit supported, by core OpenGL or OpenGLES.

Public property FBOMultiSampling: Boolean read FFBOMultiSampling;

Is multisampling possible for FBO buffers and textures. Although these are two orthogonal features of OpenGL, in practice you want to use multisample for both FBO buffers and textures, or for none — otherwise, FBO can not be initialized correctly when you mix various multisample settings.

Public property CurrentMultiSampling: Cardinal read FCurrentMultiSampling;

How multi-sampling was initialized for this OpenGL context. Value = 1 means that no multi-sampling is initialized. Values > 1 mean that you have multi-sampling, with given number of samples per pixel. Contrast this with TCastleWindow.MultiSampling or TOpenGLControl.MultiSampling, that say how many samples you wanted to get.

Public property PackedDepthStencil: Boolean read FPackedDepthStencil;

Does OpenGL context have depth buffer packed with stencil buffer. See OpenGL extensions EXT_packed_depth_stencil and OES_packed_depth_stencil (http://www.opengl.org/registry/specs/EXT/packed_depth_stencil.txt, https://www.khronos.org/registry/OpenGL/extensions/OES/OES_packed_depth_stencil.txt) for explanation what does it mean.

This is important for FBOs, as the depth/stencil have to be set up differently depending on PackedDepthStencil value. This is also important for all code using TGLRenderToTexture with TGLRenderToTexture.Buffer equal tbDepth or tbColorAndDepth: your depth texture must be prepared differently, to include both depth+stencil data, to work.

For now, this is simply equal to GL_EXT_packed_depth_stencil. (TODO: for core OpenGL 3, how to detect should we use packed version? http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt incorporates EXT_packed_depth_stencil, so forward-compatible contexts do not need to declare it. Should we assume that forward-compatible gl 3 contexts always have depth/stencil packed?)

Public property ShadowVolumesPossible: Boolean read FShadowVolumesPossible;

Does OpenGL context support shadow volumes. This checks do we have: - stencil buffer with at least 4 bits - stencil operations that wrap (GL_INCR/DECR_WRAP in OpenGL >= 2.0) - separate stencil operation (glStencilOpSeparate, without this shadow volumes are more complicated, and now we just require it)

Public property TextureNonPowerOfTwo: Boolean read FTextureNonPowerOfTwo;

Are non-power-of-2 textures supported.

Public property TextureCubeMap: Boolean read FTextureCubeMap;

Are cubemaps supported (so you can load to texture targets like GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z) by core OpenGL or OpenGLES.

Public property TextureCompression: TTextureCompressions read FTextureCompression;

Which texture compression formats are supported. If this is not [], then we guarantee glCompressedTexImage2D is also supported.

Public property VertexBufferObject: Boolean read FVertexBufferObject;

VBO support (in OpenGL (ES) core).

Public property VertexArrayObject: Boolean read FVertexArrayObject;

VAO support (in OpenGL (ES) core).

Public property BlendConstant: Boolean read FBlendConstant;

glBlendColor and GL_CONSTANT_ALPHA support.

Public property TextureFloat: Boolean read FTextureFloat;

Support for float texture formats for glTexImage2d.

Public property TextureDepth: Boolean read FTextureDepth;

Support for depth texture formats for glTexImage2d.

Public property TextureDepthCompare: Boolean read FTextureDepthCompare;

Ability to create depth textures (TextureDepth), to define comparison on them: GL_TEXTURE_COMPARE_MODE, GL_TEXTURE_COMPARE_FUNC, GL_COMPARE_REF_TO_TEXTURE, finally to use then in shaders (sampler2DShadow). On OpenGLES the GLSL constructs require that we can use "#version 300 es", to access sampler2DShadow using texture / textureProj calls.

Public property Shaders: Boolean read FShaders;

Are GLSL shaders supported.

Public property EnableFixedFunction: Boolean read FEnableFixedFunction;

Use OpenGL fixed-function rendering for ancient OpenGL versions on desktops. This rules whole rendering approach.

When this is False, you can be sure that these features are supported (OpenGL API exposes them, they are not detected as "buggy"):

When this is True, you should use ancient fixed-function pipeline for all rendering, without shaders or VBO. In fact, to make it easier, we set Shaders and VertexBufferObject to False in this case (even if in theory one of them could be used, at least in some cases... we don't want to maintain too many alternatives for ancient systems, we want only one path for ancient systems: all modern stuff disabled). This makes Shaders and VertexBufferObject practically useless now: they are always negation of EnabledFixedFunction. And this is OK, it means we have 2 clear approaches to rendering, not a lot of possible combinations to test.

Note that UseMultiTexturing may be True or False when EnableFixedFunction is True. So we still allow the option to support fixed-function with or without multi-texturing.

When this is True:

Note that on OpenGLES, it must be always False, since OpenGLES >= 2 has no fixed-function pipeline, and it guarantees having working shaders and VBO.

Public class property RequestCapabilities: TGLRequestCapabilities read FRequestCapabilities write SetRequestCapabilities;

Request specific OpenGL(ES) capabilities at context creation.

  • By default we work in automatic mode: rcAutomatic. We will use only modern (core, >= 3.3) OpenGL features, if your OpenGL version is sufficiently high. But we will fallback sensibly on OpenGL 2.0 or even OpenGL 1.1 if necessary.

  • You can force using only modern OpenGL 3.3 (on desktops) by setting this to rcForceModern.

    You can alternatively select "Run -> Run Parameters -> Force Modern Rendering Context" menu item before running any application from CGE editor to test it. Or you can pass command-line option –capabilities=force-modern.

  • You can force using ancient OpenGL 1.1 (on desktops), only for testing, by setting this to rcForceFixedFunction.

    You can alternatively select "Run -> Run Parameters -> Force Ancient Rendering Context" menu item before running any application to test it. Or you can pass command-line option –capabilities=force-fixed-function.

This is a class property and it can only change before OpenGL(ES) context is initialized, which means before TCastleWindow.Open occurs, which means before GLFeatures instance is initialized.

The routines that initialize OpenGL(ES) context, like using wgl (on Windows) or glX (on Unix) should look at this setting and honour it.

Normal code using OpenGL(ES) should not look at this property: instead, detect the current OpenGL(ES) capabilities looking at properties of current TGLFeatures instance, like TGLFeatures.Framebuffer, TGLFeatures.Version_4_0 etc. This way, we should use modern features both when rcForceFixedFunction and rcAutomatic is set.

Public class property Debug: Boolean read FDebug write SetDebug;

Request debug OpenGL(ES) context. OpenGL will report a lot of information and errors to log, and OpenGL API usage errors will result in immediate exception (with useful stack-trace pointing to their usage in CGE). This should never be used at production, but it is very useful when developing and using OpenGL(ES) API directly.

See https://www.khronos.org/opengl/wiki/Debug_Output .

Public property Memory: TGLMemoryInfo read FMemory;

Total and current memory available. Call Memory.Refresh whenever needed.

Public property MaxViewportDimensions: TVector2Integer read FMaxViewportDimensions;

This item has no description.

Public property TextureModernFormatsAndSwizzle: Boolean read FTextureModernFormatsAndSwizzle;

We should use modern OpenGL enums for format, internal format and we have texture swizzle available.

This means we should use e.g. GL_RG8 and not GL_LUMINANCE_ALPHA. See https://www.khronos.org/opengl/wiki/Image_Format .

To make it always work (e.g. to use grayscale or grayscale+alpha images), we really need https://www.khronos.org/opengl/wiki/Texture#Swizzle_mask https://registry.khronos.org/OpenGL/extensions/ARB/ARB_texture_swizzle.txt https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_swizzle.txt (core extension since 3.3).

Public property RedBits: TGLint read FRedBits;

Size, in bits, of the red channel of the color buffer.

Public property GreenBits: TGLint read FGreenBits;

Size, in bits, of the green channel of the color buffer.

Public property BlueBits: TGLint read FBlueBits;

Size, in bits, of the blue channel of the color buffer.

Public property AlphaBits: TGLint read FAlphaBits;

Size, in bits, of the alpha channel of the color buffer.

Public property DepthBits: TGLint read FDepthBits;

Size, in bits, of the depth buffer.

Public property StencilBits: TGLint read FStencilBits;

Size, in bits, of the stencil buffer.

Public property DoubleBuffer: Boolean read FDoubleBuffer;

Do we have double-buffer.

Public property LineWidth: TVector2 read FLineWidth;

Line width granularity and maximum width.

Public property TextureMaxLevel: Boolean read FTextureMaxLevel;

Supports glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, ...);


Generated by PasDoc 0.16.0-snapshot.