2
// This unit is part of the GLScene Engine https://github.com/glscene
6
14/03/11 - Yar - Creation
18
OpenGLTokens, GLVectorTypes, GLTextureFormat, GLRenderContextInfo;
51
GLSLSampler1DArrayShadow,
52
GLSLSampler2DArrayShadow,
53
GLSLSamplerCubeShadow,
58
GLSLIntSampler1DArray,
59
GLSLIntSampler2DArray,
64
GLSLUIntSampler1DArray,
65
GLSLUIntSampler2DArray,
67
GLSLSamplerRectShadow,
72
GLSLUIntSamplerBuffer,
77
GLSLIntSamplerMSArray,
78
GLSLUIntSamplerMSArray
96
IShaderParameter = interface(IInterface)
97
function GetName: string;
98
function GetGLSLType: TGLSLDataType;
99
function GetGLSLSamplerType: TGLSLSamplerType;
101
function GetAutoSetMethod: string;
102
function GetTextureName: string;
103
function GetSamplerName: string;
104
function GetTextureSwizzle: TSwizzleVector;
105
procedure SetTextureName(const AValue: string);
106
procedure SetSamplerName(const AValue: string);
107
procedure SetAutoSetMethod(const AValue: string);
108
procedure SetTextureSwizzle(const AValue: TSwizzleVector);
110
function GetFloat: Single;
111
function GetVec2: TVector2f;
112
function GetVec3: TVector3f;
113
function GetVec4: TVector4f;
115
function GetInt: TGLint;
116
function GetIVec2: TVector2i;
117
function GetIVec3: TVector3i;
118
function GetIVec4: TVector4i;
120
function GetUInt: TGLuint;
121
function GetUVec2: TVector2ui;
122
function GetUVec3: TVector3ui;
123
function GetUVec4: TVector4ui;
125
procedure SetFloat(const Value: TGLFloat);
126
procedure SetVec2(const Value: TVector2f);
127
procedure SetVec3(const Value: TVector3f);
128
procedure SetVec4(const Value: TVector4f);
130
procedure SetInt(const Value: Integer);
131
procedure SetIVec2(const Value: TVector2i);
132
procedure SetIVec3(const Value: TVector3i);
133
procedure SetIVec4(const Value: TVector4i);
135
procedure SetUInt(const Value: GLuint);
136
procedure SetUVec2(const Value: TVector2ui);
137
procedure SetUVec3(const Value: TVector3ui);
138
procedure SetUVec4(const Value: TVector4ui);
140
function GetMat2: TMatrix2f;
141
function GetMat3: TMatrix3f;
142
function GetMat4: TMatrix4f;
143
procedure SetMat2(const Value: TMatrix2f);
144
procedure SetMat3(const Value: TMatrix3f);
145
procedure SetMat4(const Value: TMatrix4f);
147
procedure SetFloatArray(const Values: PGLFloat; Count: Integer);
148
procedure SetIntArray(const Values: PGLInt; Count: Integer);
149
procedure SetUIntArray(const Values: PGLUInt; Count: Integer);
151
property Name: string read GetName;
152
property GLSLType: TGLSLDataType read GetGLSLType;
153
property GLSLSamplerType: TGLSLSamplerType read GetGLSLSamplerType;
154
{.$IFDEF GLS_DELPHI_OR_CPPB}
156
property float: TGLFloat read GetFloat write SetFloat;
157
property int: TGLint read GetInt write SetInt;
158
property uint: TGLUint read GetUInt write SetUInt;
160
{ Float vector types.}
161
property vec2: TVector2f read GetVec2 write SetVec2;
162
property vec3: TVector3f read GetVec3 write SetVec3;
163
property vec4: TVector4f read GetVec4 write SetVec4;
165
{ Integer vector types.}
166
property ivec2: TVector2i read GetIVec2 write SetIVec2;
167
property ivec3: TVector3i read GetIVec3 write SetIVec3;
168
property ivec4: TVector4i read GetIVec4 write SetIVec4;
170
{ Unsigned integer vector types.}
171
property uvec2: TVector2ui read GetUVec2 write SetUVec2;
172
property uvec3: TVector3ui read GetUVec3 write SetUVec3;
173
property uvec4: TVector4ui read GetUVec4 write SetUVec4;
176
property mat2: TMatrix2f read GetMat2 write SetMat2;
177
property mat3: TMatrix3f read GetMat3 write SetMat3;
178
property mat4: TMatrix4f read GetMat4 write SetMat4;
181
property AutoSetMethod: string read GetAutoSetMethod write SetAutoSetMethod;
182
property TextureName: string read GetTextureName write SetTextureName;
183
property SamplerName: string read GetSamplerName write SetSamplerName;
184
{.$IFDEF GLS_DELPHI_OR_CPPB}
185
property TextureSwizzle: TSwizzleVector read GetTextureSwizzle write SetTextureSwizzle;
190
cGLSLTypeString: array[TGLSLDataType] of AnsiString = (
209
cGLSLSamplerString: array[TGLSLSamplerType] of AnsiString = (
219
'sampler1DArrayShadow',
220
'sampler2DArrayShadow',
249
cGLgsInTypes : array[TGLgsInTypes] of GLenum =
250
(GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_EXT, GL_TRIANGLES,
251
GL_TRIANGLES_ADJACENCY_EXT);
252
cGLgsOutTypes: array[TGLgsOutTypes] of GLenum =
253
(GL_POINTS, GL_LINE_STRIP, GL_TRIANGLE_STRIP);
256
rstrNothing = '*nothing*';
259
TUniformAutoSetMethod = procedure(Sender: IShaderParameter; var ARci: TGLRenderContextInfo) of object;
261
function GLSLTypeEnum(AType: TGLSLDataType): TGLEnum;
262
function GLSLTypeComponentCount(AType: TGLSLDataType): Integer;
263
procedure RegisterUniformAutoSetMethod(AMethodName: string;
264
AType: TGLSLDataType; AMethod: TUniformAutoSetMethod);
265
procedure FillUniformAutoSetMethodList(AList: TStrings;
266
TypeFilter: TGLSLDataType); overload;
267
procedure FillUniformAutoSetMethodList(AList: TStrings;
268
TypeFilter: TGLSLSamplerType); overload;
269
function GetUniformAutoSetMethod(AMethodName: string): TUniformAutoSetMethod;
270
function GetUniformAutoSetMethodName(AMethod: TUniformAutoSetMethod): string;
275
cGLSLTypeComponents: array[TGLSLDataType] of Integer =
296
cGLSLTypeEnum: array[TGLSLDataType] of Integer =
318
TAutoSetMethodRec = record
320
UniformType: TGLSLDataType;
321
SamplerType: TGLSLSamplerType;
322
Method: TUniformAutoSetMethod;
326
vMethods: array of TAutoSetMethodRec;
328
function GLSLTypeEnum(AType: TGLSLDataType): TGLEnum;
330
Result := cGLSLTypeEnum[AType];
333
function GLSLTypeComponentCount(AType: TGLSLDataType): Integer;
335
Result := cGLSLTypeComponents[AType];
338
procedure RegisterUniformAutoSetMethod(AMethodName: string;
339
AType: TGLSLDataType; AMethod: TUniformAutoSetMethod);
343
for I := 0 to High(vMethods) do
344
if vMethods[I].Name = AMethodName then
346
vMethods[I].UniformType := AType;
347
vMethods[I].Method := AMethod;
350
I := Length(vMethods);
351
SetLength(vMethods, I+1);
352
vMethods[I].Name := AMethodName;
353
vMethods[I].UniformType := AType;
354
vMethods[I].SamplerType := GLSLSamplerUndefined;
355
vMethods[I].Method := AMethod;
358
procedure FillUniformAutoSetMethodList(AList: TStrings; TypeFilter: TGLSLDataType);
362
for I := 0 to High(vMethods) do
363
if vMethods[I].UniformType = TypeFilter then
364
AList.Add(vMethods[I].Name);
367
procedure FillUniformAutoSetMethodList(AList: TStrings; TypeFilter: TGLSLSamplerType);
371
for I := 0 to High(vMethods) do
372
if vMethods[I].SamplerType = TypeFilter then
373
AList.Add(vMethods[I].Name);
376
function GetUniformAutoSetMethod(AMethodName: string): TUniformAutoSetMethod;
380
for I := 0 to High(vMethods) do
381
if vMethods[I].Name = AMethodName then
383
Result := vMethods[I].Method;
389
function GetUniformAutoSetMethodName(AMethod: TUniformAutoSetMethod): string;
393
for I := 0 to High(vMethods) do
394
if @vMethods[I].Method = @AMethod then
396
Result := vMethods[I].Name;