-
Notifications
You must be signed in to change notification settings - Fork 3
/
LUX.GPU.OpenGL.Render_.pas
182 lines (128 loc) · 5.12 KB
/
LUX.GPU.OpenGL.Render_.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
unit LUX.GPU.OpenGL.Render_;
interface //#################################################################### ■
uses System.UITypes,
Winapi.Windows, Winapi.OpenGL, Winapi.OpenGLext,
LUX, LUX.D4x4,
LUX.GPU.OpenGL.Atom.Buffer.UniBuf,
LUX.GPU.OpenGL.Atom.Framer,
LUX.GPU.OpenGL.Camera;
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
///%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGL_Render
TGL_Render = class
private
protected
_Frame1 :TGLFramer1;
_FrameN :TGLFramerN;
_Camera :TGLCamera;
_SizeX :Integer;
_SizeY :Integer;
_Viewer :TGLUniBuf<TSingleM4>;
_Color :TAlphaColorF;
///// アクセス
function GetSizeX :Integer;
procedure SetSizeX( const SizeX_:Integer );
function GetSizeY :Integer;
procedure SetSizeY( const SizeY_:Integer );
function GetColor :TAlphaColorF;
procedure SetColor( const Color_:TAlphaColorF );
///// メソッド
procedure FitWindow;
public
constructor Create;
destructor Destroy; override;
///// プロパティ
property Camera :TGLCamera read _Camera write _Camera;
property SizeX :Integer read GetSizeX write SetSizeX ;
property SizeY :Integer read GetSizeY write SetSizeY ;
property Color :TAlphaColorF read GetColor write SetColor ;
///// メソッド
procedure Render;
end;
//const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
implementation //############################################################### ■
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TGL_Render
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
/////////////////////////////////////////////////////////////////////// アクセス
function TGL_Render.GetSizeX :Integer;
begin
Result := _SizeX;
end;
procedure TGL_Render.SetSizeX( const SizeX_:Integer );
begin
_SizeX := SizeX_;
_Frame1.SizeX := _SizeX;
_FrameN.SizeX := _SizeX;
FitWindow;
end;
function TGL_Render.GetSizeY :Integer;
begin
Result := _SizeY;
end;
procedure TGL_Render.SetSizeY( const SizeY_:Integer );
begin
_SizeY := SizeY_;
_Frame1.SizeY := _SizeY;
_FrameN.SizeY := _SizeY;
FitWindow;
end;
//------------------------------------------------------------------------------
function TGL_Render.GetColor :TAlphaColorF;
begin
Result := _Color;
end;
procedure TGL_Render.SetColor( const Color_:TAlphaColorF );
begin
_Color := Color_;
end;
/////////////////////////////////////////////////////////////////////// メソッド
procedure TGL_Render.FitWindow;
begin
if _SizeY < _SizeX then _Viewer[ 0 ] := TSingleM4.Scale( _SizeY / _SizeX, 1, 1 )
else
if _SizeX < _SizeY then _Viewer[ 0 ] := TSingleM4.Scale( 1, _SizeX / _SizeY, 1 )
else _Viewer[ 0 ] := TSingleM4.Identity;
end;
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
constructor TGL_Render.Create;
begin
inherited;
_Frame1 := TGLFramer1.Create;
_FrameN := TGLFramerN.Create;
_Viewer := TGLUniBuf<TSingleM4>.Create( GL_DYNAMIC_DRAW );
SizeX := 1920;
SizeY := 1080;
_Color := TAlphaColorF.Create( 0, 0, 0, 1 );
end;
destructor TGL_Render.Destroy;
begin
_Viewer.Free;
_Frame1.Free;
_FrameN.Free;
inherited;
end;
/////////////////////////////////////////////////////////////////////// メソッド
procedure TGL_Render.Render;
begin
_FrameN.Bind;
with _Color do glClearColor( R, G, B, A );
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
_Viewer.Use( 0{BinP} );
glViewport( 0, 0, _SizeX, _SizeY );
if Assigned( _Camera ) then _Camera.Render;
_Viewer.Unuse( 0{BinP} );
glFlush;
_FrameN.Unbind;
_FrameN.DrawToFramer( _Frame1 );
end;
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
//############################################################################## □
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
end. //######################################################################### ■