Class TGLSLProgram
Unit
Declaration
type TGLSLProgram = class(TObject)
Description
Manage (build, use) a program in GLSL (OpenGL Shading Language).
Hierarchy
- TObject
- TGLSLProgram
Overview
Fields
Name: String; |
|
FragmentShaderRequired: Boolean; |
Methods
constructor Create; |
|
destructor Destroy; override; |
|
procedure AttachVertexShader(const S: string); |
|
procedure AttachGeometryShader(const S: string); |
|
procedure AttachFragmentShader(const S: string); |
|
procedure AttachShader(const ShaderType: TShaderType; S: string); overload; |
|
procedure AttachShader(const ShaderType: TShaderType; const Parts: TStrings); overload; |
|
procedure DetachAllShaders; |
|
procedure SetTransformFeedbackVaryings(const Varyings: array of PAnsiChar; const IsSingleBufferMode: Boolean = True); |
|
procedure Link; overload; virtual; |
|
procedure Link(Ignored: boolean); overload; deprecated 'use parameterless Link method'; |
|
procedure Enable; |
|
class procedure Disable; |
|
function SetupUniforms(var BoundTextureUnits: Cardinal): boolean; virtual; |
|
function DebugInfo: string; |
|
function ProgramInfoLog: string; |
|
function RunningInHardware: boolean; |
|
function Uniform(const AName: string): TGLSLUniform; overload; |
|
function Uniform(const AName: string; const AUniformMissing: TUniformMissing): TGLSLUniform; overload; |
|
procedure SetUniform(const AName: string; const Value: boolean ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TGLint ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2Integer; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3Integer; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4Integer; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TGLfloat ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix2 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix3 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix4 ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TBooleanList; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TInt32List ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TSingleList ; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2List; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3List; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4List; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix3List; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix4List; const AUniformMissing: TUniformMissing); overload; |
|
procedure SetUniform(const AName: string; const Value: boolean ); overload; |
|
procedure SetUniform(const AName: string; const Value: TGLint ); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2Integer); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3Integer); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4Integer); overload; |
|
procedure SetUniform(const AName: string; const Value: TGLfloat ); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix2 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix3 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix4 ); overload; |
|
procedure SetUniform(const AName: string; const Value: TBooleanList); overload; |
|
procedure SetUniform(const AName: string; const Value: TInt32List ); overload; |
|
procedure SetUniform(const AName: string; const Value: TSingleList ); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector2List); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector3List); overload; |
|
procedure SetUniform(const AName: string; const Value: TVector4List); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix3List); overload; |
|
procedure SetUniform(const AName: string; const Value: TMatrix4List); overload; |
|
function Attribute(const AName: string): TGLSLAttribute; |
|
function AttributeOptional(const AName: string): TGLSLAttribute; |
|
procedure SetAttribute(const AName: string; const Value: TGLfloat); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TVector2); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TVector3); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TVector4); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TMatrix3); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TMatrix4); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TVector4Integer); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TVector4Byte); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
procedure SetAttribute(const AName: string; const Value: TGLdouble); overload; deprecated 'use TGLSLAttribute.SetValue'; |
Properties
property UniformMissing: TUniformMissing
read FUniformMissing write FUniformMissing
default umWarning; |
|
class property Current: TGLSLProgram read GetCurrent write SetCurrent; deprecated 'use RenderContext.CurrentProgram'; |
Description
Fields
Name: String; |
|
Shader name is used in log messages. Any String is OK. |
FragmentShaderRequired: Boolean; |
|
Is fragment shader required to link successfully. By default this is Setting this to |
Methods
constructor Create; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure AttachVertexShader(const S: string); |
|
Create shader from given string, compile it and attach to current program. For desktop OpenGL, you can attach more than one shader of given type, just make sure that only one main() function is among each type (otherwise link error will be raised later). For OpenGLES, this is not allowed, so don't use this if you want to work with OpenGLES too. If you want to explicitly get rid of old shaders, use DetachAllShaders.
Exceptions raised
|
procedure AttachGeometryShader(const S: string); |
|
This item has no description. |
procedure AttachFragmentShader(const S: string); |
|
This item has no description. |
procedure AttachShader(const ShaderType: TShaderType; S: string); overload; |
|
This item has no description. |
procedure AttachShader(const ShaderType: TShaderType; const Parts: TStrings); overload; |
|
Attach multiple shader parts for given type. For normal OpenGL, we can use GLSL separate compilation units. So this is equivalent to just calling For OpenGL ES, this is unfortunately not possible, you can only attach a single shader of a given type (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glAttachShader.xml ). So we simply concatenate the shaders into one. |
procedure DetachAllShaders; |
|
This item has no description. |
procedure SetTransformFeedbackVaryings(const Varyings: array of PAnsiChar; const IsSingleBufferMode: Boolean = True); |
|
Specify values to record in transform feedback buffers. This must be called before Link method. |
procedure Link; overload; virtual; |
|
Link the program, this should be done after attaching all shaders and before actually using the program. Exceptions raised
|
procedure Link(Ignored: boolean); overload; deprecated 'use parameterless Link method'; |
|
Warning: this symbol is deprecated: use parameterless Link method This item has no description. |
procedure Enable; |
|
Enable (use) this program. Shortcut for |
class procedure Disable; |
|
Disable this program (use the fixed function pipeline). Shortcut for |
function SetupUniforms(var BoundTextureUnits: Cardinal): boolean; virtual; |
|
Override this to set uniform values, in particular to bind the textures used by this shader, right after each Enable call. This is automatically called after every Enable by our renderer (when it renders shapes) or TCastleScreenEffect (when it renders screen effects). If you use this TGLSLProgram directly (if you call Enable yourself), then it's your responsibility to call this method explicitly, if you want shaders using it to work. You can set any uniform values, and generally do anything you want to be done each time this shader is enabled. In particular, you can bind textures and set corresponding uniform variables of them. Increase BoundTextureUnits appropriately. Returns |
function ProgramInfoLog: string; |
|
This is program info log, given to you from OpenGL after the program is linked. |
function RunningInHardware: boolean; |
|
After the program is linked, you can check this. Note that this is necessarily implemented in quite hacky way (by looking at ProgramInfoLog), there is no way currently (AFAIK ?) to get this information cleanly from OpenGL. In case of doubts, we try to "trust" OpenGL to execute shader in hardware. Return |
function Uniform(const AName: string): TGLSLUniform; overload; |
|
Get the uniform instance. It can be used to make repeated TGLSLUniform.SetValue calls. You must link the program first. If the uniform doesn't exist (or is unused), the action we take depends on UniformMissing property (by default – umWarning). The overloaded version with extra |
function Uniform(const AName: string; const AUniformMissing: TUniformMissing): TGLSLUniform; overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: boolean ; const AUniformMissing: TUniformMissing); overload; |
|
Set appropriate uniform variable value. The used type must match the type of this variable in GLSL program. OpenGL forces some constraints on using this:
This will make warning if the variable is not found within the program and UniformMissing = umWarning. The overloaded version with explicit AUniformMissing parameter uses that to decide whether to show warning. |
procedure SetUniform(const AName: string; const Value: TGLint ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2Integer; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3Integer; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4Integer; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TGLfloat ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix2 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix3 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix4 ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TBooleanList; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TInt32List ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TSingleList ; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2List; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3List; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4List; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix3List; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix4List; const AUniformMissing: TUniformMissing); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: boolean ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TGLint ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2Integer); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3Integer); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4Integer); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TGLfloat ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix2 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix3 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix4 ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TBooleanList); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TInt32List ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TSingleList ); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector2List); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector3List); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TVector4List); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix3List); overload; |
|
This item has no description. |
procedure SetUniform(const AName: string; const Value: TMatrix4List); overload; |
|
This item has no description. |
function Attribute(const AName: string): TGLSLAttribute; |
|
Get the attribute instance. It can be used to make repeated TGLSLAttribute.SetValue and TGLSLAttribute.EnableArray. Exceptions raised
|
function AttributeOptional(const AName: string): TGLSLAttribute; |
|
Get the attribute instance. It can be used to make repeated TGLSLAttribute.SetValue and TGLSLAttribute.EnableArray. Returned attribute has TGLSLAttribute.Location equal to -1. All the calls to TGLSLAttribute.SetValue or TGLSLAttribute.EnableArray or TGLSLAttribute.DisableArray methods are silently ignored. |
procedure SetAttribute(const AName: string; const Value: TGLfloat); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue Set attribute variable value. The used type must match the type of this variable in GLSL program. OpenGL forces some constraints on using this, see SetUniform. In short: use this only after linking the program. The program is automatically enabled (set as RenderContext.CurrentProgram) by this. And note that attributes declared but not actually used in shader code may be eliminated, use DebugInfo to see which attributes are actually used (active in OpenGL terminology). These should not be often used. Usually, you should rather load attribute arrays, by VertexAttribPointer. You should also get attribute by the Attribute method, as TGLSLAttribute, and then call TGLSLAttribute.SetValue or TGLSLAttribute.EnableArray.
Exceptions raised
|
procedure SetAttribute(const AName: string; const Value: TVector2); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TVector3); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TVector4); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TMatrix3); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TMatrix4); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TVector4Integer); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TVector4Byte); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
procedure SetAttribute(const AName: string; const Value: TGLdouble); overload; deprecated 'use TGLSLAttribute.SetValue'; |
|
Warning: this symbol is deprecated: use TGLSLAttribute.SetValue This item has no description. |
Properties
property UniformMissing: TUniformMissing
read FUniformMissing write FUniformMissing
default umWarning; |
|
What to do when GLSL uniform variable is accessed (by SetUniform or Uniform) but doesn't exist in the shader. Note that OpenGL aggresively removes unused code and variables from the shader when compiling/linking, so this also happens for "declared but unused" variables. This is only the default value, each Uniform method call may explicitly use other TUniformMissing. See also
|
class property Current: TGLSLProgram read GetCurrent write SetCurrent; deprecated 'use RenderContext.CurrentProgram'; |
|
Warning: this symbol is deprecated: use RenderContext.CurrentProgram
Currently enabled GLSL program. |
Generated by PasDoc 0.16.0-snapshot.