GLEffect
Description
- Derived from
-
RenderEffectGeneric<TParameters> abstract
- Extended by
-
OpenGLEffect abstract
OpenGLESEffect abstract
Abstract base class for IRenderEffect implementations for OpenGL 4.1 Core Profile (or newer) and OpenGLES 3.0 (or newer).
An implementing class must perform the following steps in its constructor:
-
Create render effect passes with RenderEffect.PassCreate.
-
Create shader objects with RenderEffect.ShaderCreate and assign them to render effect passes with RenderEffect.ShaderAssign.
-
Declare vertex attributes with VertexAttributeDeclare. Based on the specified value semantics, vertex attributes will then be mapped to the vertex elements (see VertexElements) of the current geometry buffer (see IGeometryBuffer).
-
Create sampler states with SamplerStateCreate1 and assign them to texture resources with SamplerStateAssign3.
Because there are no render state blocks / objects that could be created in the constructor, the render state for each pass must be setup by subclasses, using the following methods:
-
The RenderStateSet must be implemented and will be called each time the active render pass changes.
-
Use the RenderStateDefault method to establish default render state, for example when the render effect has begun.
-
Use the RenderStateApply method to set common render state values.
-
Use the GLBase subclass for setting all other render state.
If an implementation wants to use low-level parameter slots, the following steps must be performed in the constructor:
-
Declare low-level parameter slots with IRenderEffectParameters.ParameterDeclare, for example by calling RenderEffectParameters.Declare.
Public / Constants
CS
Shader type index: Compute Shader (GL_COMPUTE_SHADER
)
Compute shaders are not available in OpenGLES 3.0.
- See also
GS
Shader type index: Geometry Shader (GL_GEOMETRY_SHADER
)
Geometry shaders are provided by an extension in OpenGLES 3.0/3.1.
- See also
MS
Shader type index: Mesh Shader (GL_MESH_SHADER_NV
)
Mesh shaders are provided by a vendor-specific extension.
- See also
TCS
Shader type index: Tessellation Control Shader (GL_TESS_CONTROL_SHADER
)
Tessellation shaders are provided by an extension in OpenGLES 3.0/3.1.
TES
Shader type index: Tessellation Evaluation Shader (GL_TESS_EVALUATION_SHADER
)
Tessellation shaders are provided by an extension in OpenGLES 3.0/3.1.
Public / Methods
RenderStateApply
Applies the given render state preset.
This method assumes that default render state values are in place, as defined by the implementation of RenderStateDefault or the GL (in that order).
RenderStateDefault
Sets default render state values.
Please refer to the documentation of the concrete subclass for details on which render state is set by this method.
RenderStateSet
Sets the render state for the current render effect pass.
Render state must be set by subclasses by using a GLBase wrapper for accessing the GL API, for example GL or GLES. The default implementation calls RenderStateDefault initially (when context in is negative) and then keeps track of the current render state preset (when context in is zero, using RenderEffectParameters.EffectRenderState), calling RenderStateApply accordingly to apply resp. revert render states. Finally (when context in is greater than zero), the current render state preset is reverted. An overriding method may call RenderStateDirty to indicate that it has modified the render state in a way that conflicts with the given render state presets, so that they will be applied again, if necessary.
SamplerStateAssign
3 overloads
Assigns the common sampler state preset to a texture resource.
All vertex attributes must have been declared via VertexAttributeDeclare before a sampler state may be assigned. This method first calls RenderEffectParameters.EffectSamplerState to get the common sampler state preset and then calls SamplerStateAssign2.
- RenderException
-
If a graphics subsystem error has occurred.
Assigns a sampler state to a texture resource.
All vertex attributes must have been declared via VertexAttributeDeclare before a sampler state may be assigned. This method first calls SamplerStateCreate3 and then passes the created sampler state object to SamplerStateAssign3.
- RenderException
-
If a graphics subsystem error has occurred.
Assigns a sampler state to a texture resource.
All vertex attributes must have been declared via VertexAttributeDeclare before a sampler state may be assigned.
- RenderException
-
If a graphics subsystem error has occurred.
SamplerStateCreate
3 overloads
Creates a sampler state (step 1 of 2).
Use the returned sampler object name to configure the sampler state using the GL API. Then, call SamplerStateCreate2.
- RenderException
-
If sampler state creation has failed.
- See also
Creates a sampler state (step 2 of 2).
Creates a sampler state based on a SamplerStatePreset.
This method first calls SamplerStateCreate1, then SamplerStateApply, passing preset in. Finally, it calls SamplerStateCreate2 and returns the result.
- RenderException
-
If sampler state creation has failed.
VertexAttributeDeclare
Declares a vertex attribute.
All shader objects must have been created via RenderEffect.ShaderCreate and must have been assigned to passes via RenderEffect.ShaderAssign before a vertex attribute may be declared.
- RenderException
-
If a graphics subsystem error has occurred.
- See also
Protected / Methods
BufferObjectCreate
Creates a buffer object for a uniform block.
- RenderException
-
If buffer creation has failed.
BufferObjectUpdate
Updates the content of the given buffer object.
For each sequence of buffer updates, the last call will receive a bufferObject in of 0
.
PlatformIdentifier
Constructs a string value that identifies the platform that is compiling programs.
Cached programs are stored along with a platform hash, in order to detect when the platform has changed.
ProgramObjectBinary
2 overloads
Tries to retrieve the binary of the given program.
Builds a program from the given binary.
- RenderException
-
If program creation has failed.
ProgramObjectBuild
Creates a program object for each available render effect pass, attaches all shader objects and links the program.
- RenderException
-
If program creation has failed.
- See also
ProgramObjectReflect
Reflects the active vertex attributes, active uniforms and uniform blocks of the given program object.
An implementing method must perform the following steps, in the order given:
-
For each active vertex attribute, call the ProgramObjectReflectAttribute method once.
-
For each uniform block, call the ProgramObjectReflectUniformBlock method once.
-
For each active uniform, call the ProgramObjectReflectUniform method once.
- RenderException
-
If program reflection has failed.
ProgramObjectReflectAttribute
Declares a program vertex attribute.
- RenderException
-
If the given vertex attribute specification is invalid or unsupported.
- See also
ProgramObjectReflectShaderStorageBlock
Declares a program shader storage block.
- RenderException
-
If the given shader storage block specification is invalid.
ProgramObjectReflectUniform
Declares a program uniform variable.
- RenderException
-
If the given uniform specification is invalid or unsupported.
- See also
ProgramObjectReflectUniformBlock
Declares a program uniform block.
- RenderException
-
If the given uniform block specification is invalid.
- See also
ProgramObjectUse
Applies the given program in for subsequent use.
The following steps must be performed, in the order given:
-
Activate the given program in by calling
glUseProgram
. -
Apply the uniform block buffers for the given program in, using uniformBlockBinding and uniformBlockGpu.
-
Apply the sampler objects for the given program in, using samplerBinding.
-
Apply the texture units to the uniform variables of the given program in, using uniformTextures.
Protected / Attributes
RenderEffectIdentifier
Returns the identifier of this render effect that shall be used for naming files in the program binary cache.
samplerBinding
Mapping from program object and texture unit to sampler object:
first.X := program object name first.Y := texture unit index second := sampler object name
shaderObjects
Mapping from render effect shader to shader object:
first := render effect shader index second := shader object name
shaderStorageBlockBinding
Mapping from program and shader storage block index to binding point:
first.X := program object name first.Y := program-agnostic shader storage block index second := shader storage block binding point index
uniformBlockBinding
Mapping from program object and uniform block to uniform block binding:
first.X := program object name first.Y := program-agnostic uniform block index second := uniform block binding point index or -1 if not used