1
unit LUX.GPU.OpenGL.Atom.Porter;
3
interface //#################################################################### ■
5
uses System.Generics.Collections,
6
Winapi.OpenGL, Winapi.OpenGLext,
10
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
12
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
14
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortF
22
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortV
32
constructor Create( const Name_:String;
35
const Offs_:GLuint = 0 );
38
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortU
45
constructor Create( const Name_:String );
48
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortT
55
constructor Create( const Name_:String );
58
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortS
65
constructor Create( const Name_:String );
68
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
70
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorter<_TPort_>
72
TGLPorter<_TPort_:record> = class( TDictionary<GLuint,_TPort_> )
77
procedure AddPort( const BinP_:GLuint; const Port_:_TPort_ ); virtual; abstract;
78
procedure DelPort( const BinP_:GLuint; const Port_:_TPort_ ); virtual; abstract;
80
constructor Create( const Progra_:IGLProgra );
82
property Progra :IGLProgra read _Progra;
84
procedure Add( const BindI_:GLuint; const Port_:_TPort_ );
85
procedure Remove( const BindI_:GLuint );
86
procedure Del( const BindI_:GLuint );
89
procedure Use; virtual;
90
procedure Unuse; virtual;
93
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterF
95
TGLPorterF = class( TGLPorter<TGLPortF> )
99
procedure AddPort( const BinP_:GLuint; const Port_:TGLPortF ); override;
100
procedure DelPort( const BinP_:GLuint; const Port_:TGLPortF ); override;
103
procedure Add( const BinP_:GLuint; const Name_:String );
106
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterV
108
TGLPorterV = class( TGLPorter<TGLPortV> )
113
procedure AddPort( const BinP_:GLuint; const Port_:TGLPortV ); override;
114
procedure DelPort( const BinP_:GLuint; const Port_:TGLPortV ); override;
116
constructor Create( const Progra_:IGLProgra );
117
destructor Destroy; override;
119
procedure Add( const BinP_:GLuint; const Name_:String;
122
const Offs_:GLuint = 0 );
123
procedure Use; override;
124
procedure Unuse; override;
127
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterU
129
TGLPorterU = class( TGLPorter<TGLPortU> )
133
procedure AddPort( const BinP_:GLuint; const Port_:TGLPortU ); override;
134
procedure DelPort( const BinP_:GLuint; const Port_:TGLPortU ); override;
137
procedure Add( const BinP_:GLuint; const Name_:String );
140
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterT
142
TGLPorterT = class( TGLPorter<TGLPortT> )
146
procedure AddPort( const BinP_:GLuint; const Port_:TGLPortT ); override;
147
procedure DelPort( const BinP_:GLuint; const Port_:TGLPortT ); override;
150
procedure Add( const BinP_:GLuint; const Name_:String );
153
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterS
155
TGLPorterS = class( TGLPorter<TGLPortS> )
159
procedure AddPort( const BinP_:GLuint; const Port_:TGLPortS ); override;
160
procedure DelPort( const BinP_:GLuint; const Port_:TGLPortS ); override;
163
procedure Add( const BinP_:GLuint; const Name_:String );
166
//const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
168
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
170
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
172
implementation //############################################################### ■
174
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
176
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortF
178
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
180
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
182
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortV
184
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
186
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
188
constructor TGLPortV.Create( const Name_:String;
191
const Offs_:GLuint );
199
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortU
201
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
203
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
205
constructor TGLPortU.Create( const Name_:String );
210
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortT
212
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
214
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
216
constructor TGLPortT.Create( const Name_:String );
221
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPortS
223
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
225
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
227
constructor TGLPortS.Create( const Name_:String );
232
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
234
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorter<_TPort_>
236
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
238
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
240
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
242
constructor TGLPorter<_TPort_>.Create( const Progra_:IGLProgra );
249
/////////////////////////////////////////////////////////////////////// メソッド
251
procedure TGLPorter<_TPort_>.Add( const BindI_:GLuint; const Port_:_TPort_ );
253
inherited AddOrSetValue( BindI_, Port_ );
255
AddPort( BindI_, Port_ );
258
procedure TGLPorter<_TPort_>.Remove( const BindI_:GLuint );
260
DelPort( BindI_, Items[ BindI_ ] );
262
inherited Remove( BindI_ );
265
procedure TGLPorter<_TPort_>.Del( const BindI_:GLuint );
270
//------------------------------------------------------------------------------
272
procedure TGLPorter<_TPort_>.AddPorts;
274
P :TPair<GLuint,_TPort_>;
278
with P do AddPort( Key, Value );
282
procedure TGLPorter<_TPort_>.DelPorts;
284
P :TPair<GLuint,_TPort_>;
288
with P do DelPort( Key, Value );
292
//------------------------------------------------------------------------------
294
procedure TGLPorter<_TPort_>.Use;
299
procedure TGLPorter<_TPort_>.Unuse;
304
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterF
306
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
308
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
310
/////////////////////////////////////////////////////////////////////// メソッド
312
procedure TGLPorterF.AddPort( const BinP_:GLuint; const Port_:TGLPortF );
314
glBindFragDataLocation( _Progra.ID, BinP_, PGLchar( AnsiString( Port_.Name ) ) );
317
procedure TGLPorterF.DelPort( const BinP_:GLuint; const Port_:TGLPortF );
322
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
324
/////////////////////////////////////////////////////////////////////// メソッド
326
procedure TGLPorterF.Add( const BinP_:GLuint; const Name_:String );
335
inherited Add( BinP_, P );
338
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterV
340
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
342
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
344
/////////////////////////////////////////////////////////////////////// メソッド
346
procedure TGLPorterV.AddPort( const BinP_:GLuint; const Port_:TGLPortV );
350
L := _Progra.GetProgramResourceLocation( GL_PROGRAM_INPUT, Port_.Name );
356
glEnableVertexAttribArray( L );
361
GL_INT :glVertexAttribIFormat( L, EleN, EleT, Offs );
362
GL_FLOAT :glVertexAttribFormat( L, EleN, EleT, GL_FALSE, Offs );
366
glVertexAttribBinding( L, BinP_ );
372
procedure TGLPorterV.DelPort( const BinP_:GLuint; const Port_:TGLPortV );
376
L := _Progra.GetProgramResourceLocation( GL_PROGRAM_INPUT, Port_.Name );
382
glDisableVertexAttribArray( L );
388
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
390
constructor TGLPorterV.Create( const Progra_:IGLProgra );
394
_Varray := TGLVarray.Create;
397
destructor TGLPorterV.Destroy;
404
/////////////////////////////////////////////////////////////////////// メソッド
406
procedure TGLPorterV.Use;
411
procedure TGLPorterV.Unuse;
416
//------------------------------------------------------------------------------
418
procedure TGLPorterV.Add( const BinP_:GLuint; const Name_:String;
421
const Offs_:GLuint = 0 );
433
inherited Add( BinP_, P );
436
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterU
438
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
440
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
442
/////////////////////////////////////////////////////////////////////// メソッド
444
procedure TGLPorterU.AddPort( const BinP_:GLuint; const Port_:TGLPortU );
450
I := GetProgramResourceIndex( GL_UNIFORM_BLOCK, Port_.Name );
452
glUniformBlockBinding( ID, I, BinP_ );
456
procedure TGLPorterU.DelPort( const BinP_:GLuint; const Port_:TGLPortU );
461
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
463
/////////////////////////////////////////////////////////////////////// メソッド
465
procedure TGLPorterU.Add( const BinP_:GLuint; const Name_:String );
474
inherited Add( BinP_, P );
477
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterT
479
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
481
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
483
/////////////////////////////////////////////////////////////////////// メソッド
485
procedure TGLPorterT.AddPort( const BinP_:GLuint; const Port_:TGLPortT );
491
L := GetProgramResourceLocation( GL_UNIFORM, Port_.Name );
493
glProgramUniform1i( ID, L, BinP_ );
497
procedure TGLPorterT.DelPort( const BinP_:GLuint; const Port_:TGLPortT );
502
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
504
/////////////////////////////////////////////////////////////////////// メソッド
506
procedure TGLPorterT.Add( const BinP_:GLuint; const Name_:String );
515
inherited Add( BinP_, P );
518
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGLPorterS
520
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
522
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
524
/////////////////////////////////////////////////////////////////////// メソッド
526
procedure TGLPorterS.AddPort( const BinP_:GLuint; const Port_:TGLPortS );
532
I := GetProgramResourceIndex( GL_SHADER_STORAGE_BLOCK, Port_.Name );
534
glShaderStorageBlockBinding( ID, I, BinP_ );
538
procedure TGLPorterS.DelPort( const BinP_:GLuint; const Port_:TGLPortS );
543
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
545
/////////////////////////////////////////////////////////////////////// メソッド
547
procedure TGLPorterS.Add( const BinP_:GLuint; const Name_:String );
556
inherited Add( BinP_, P );
559
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
561
//############################################################################## □
563
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
565
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
567
end. //######################################################################### ■