2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
23
#include "NuxCore/NKernel.h"
25
#include "NuxImage/Tga.h"
26
#include "NuxImage/ImageSurface.h"
27
#include "NuxMesh/NTextureArchiveManager.h"
29
#include "GLDeviceFactory.h"
30
#include "GLDeviceObjects.h"
31
#include "GLResourceManager.h"
33
#include "GLTextureResourceManager.h"
34
#include "GLVertexResourceManager.h"
35
#include "RenderingPipe.h"
36
#include "OpenGLEngine.h"
41
// For some strange reason, make sure that the attribute holding the vertex position has a name that comes first in alphabetic order before all
42
// other attributes. Otherwise you get a bug on NVidia! Why is that???
43
// [Update]: it seems that the vertex attributes have to be declared in alphabetic order in the shader. It does not matter if the vertex
44
// attribute is declared first in the alphabetic order.
46
// For some other strange reason, on Intel GMA, the order in which attributes are used in the vertex shaders, is the order used to associated them with a
47
// and attribute location. One has to make sure that the vertex attribute get index 0. So use the vertex attribute first. All of this does not make any sense.
48
// Need more info from driver developers.
51
bool USE_ARB_SHADERS = true;
53
void GraphicsContext::InitSlColorShader()
55
TRefGL<IOpenGLVertexShader> VS = m_GLWindow.m_DeviceFactory->CreateVertexShader();
56
TRefGL<IOpenGLPixelShader> PS = m_GLWindow.m_DeviceFactory->CreatePixelShader();
60
VSString = TEXT("#version 110 \n\
61
uniform mat4 ViewProjectionMatrix; \n\
62
attribute vec4 AVertex; \n\
63
attribute vec4 VertexColor; \n\
66
gl_Position = ViewProjectionMatrix * AVertex; \n\
67
gl_FrontColor = VertexColor; \n\
70
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
72
PSString = TEXT("#version 110 \n\
75
gl_FragColor = gl_Color; \n\
77
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString));
79
m_SlColor = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
80
m_SlColor->ClearShaderObjects();
81
m_SlColor->AddShaderObject(VS);
82
m_SlColor->AddShaderObject(PS);
86
void GraphicsContext::InitSlTextureShader()
88
TRefGL<IOpenGLVertexShader> VS = m_GLWindow.m_DeviceFactory->CreateVertexShader();
89
TRefGL<IOpenGLPixelShader> PS = m_GLWindow.m_DeviceFactory->CreatePixelShader();
93
VSString = TEXT("#version 110 \n\
94
attribute vec4 AVertex; \n\
95
attribute vec4 MyTextureCoord0; \n\
96
attribute vec4 VertexColor; \n\
97
uniform mat4 ViewProjectionMatrix; \n\
98
varying vec4 varyTexCoord0; \n\
99
varying vec4 varyVertexColor; \n\
102
gl_Position = ViewProjectionMatrix * (AVertex); \n\
103
varyTexCoord0 = MyTextureCoord0; \n\
104
varyVertexColor = VertexColor; \n\
107
PSString = TEXT("#version 110 \n\
108
#extension GL_ARB_texture_rectangle : enable \n\
109
varying vec4 varyTexCoord0; \n\
110
varying vec4 varyVertexColor; \n\
111
#ifdef SAMPLERTEX2D \n\
112
uniform sampler2D TextureObject0; \n\
113
vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
115
return texture2D(TexObject, TexCoord.st); \n\
117
#elif defined SAMPLERTEX2DRECT \n\
118
uniform sampler2DRect TextureObject0; \n\
119
vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
121
return texture2DRect(TexObject, TexCoord.st); \n\
126
vec4 v = SampleTexture(TextureObject0, varyTexCoord0); \n\
127
gl_FragColor = v*varyVertexColor; \n\
130
// Textured 2D Primitive Shader
131
m_SlTextureModColor = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
132
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
133
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2D"));
135
m_SlTextureModColor->ClearShaderObjects();
136
m_SlTextureModColor->AddShaderObject(VS);
137
m_SlTextureModColor->AddShaderObject(PS);
138
CHECKGL( glBindAttribLocation(m_SlTextureModColor->GetOpenGLID(), 0, "AVertex") );
139
m_SlTextureModColor->Link();
142
void GraphicsContext::InitSlColorModTexMaskAlpha()
144
TRefGL<IOpenGLVertexShader> VS = m_GLWindow.m_DeviceFactory->CreateVertexShader();
145
TRefGL<IOpenGLPixelShader> PS = m_GLWindow.m_DeviceFactory->CreatePixelShader();
149
VSString = TEXT("#version 110 \n\
150
attribute vec4 AVertex; \n\
151
attribute vec4 MyTextureCoord0; \n\
152
attribute vec4 VertexColor; \n\
153
uniform mat4 ViewProjectionMatrix; \n\
154
varying vec4 varyTexCoord0; \n\
155
varying vec4 varyVertexColor; \n\
158
gl_Position = ViewProjectionMatrix * (AVertex); \n\
159
varyTexCoord0 = MyTextureCoord0; \n\
160
varyVertexColor = VertexColor; \n\
163
PSString = TEXT("#version 110 \n\
164
#extension GL_ARB_texture_rectangle : enable \n\
165
varying vec4 varyTexCoord0; \n\
166
varying vec4 varyVertexColor; \n\
167
#ifdef SAMPLERTEX2D \n\
168
uniform sampler2D TextureObject0; \n\
169
vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
171
return texture2D(TexObject, TexCoord.st); \n\
173
#elif defined SAMPLERTEX2DRECT \n\
174
uniform sampler2DRect TextureObject0; \n\
175
vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
177
return texture2DRect(TexObject, TexCoord.st); \n\
182
float alpha = SampleTexture(TextureObject0, varyTexCoord0).w; \n\
183
gl_FragColor = vec4(varyVertexColor.xyz, alpha*varyVertexColor.a); \n\
186
m_SlColorModTexMaskAlpha = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
187
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
188
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2D"));
189
m_SlColorModTexMaskAlpha->ClearShaderObjects();
190
m_SlColorModTexMaskAlpha->AddShaderObject(VS);
191
m_SlColorModTexMaskAlpha->AddShaderObject(PS);
192
CHECKGL( glBindAttribLocation(m_SlColorModTexMaskAlpha->GetOpenGLID(), 0, "AVertex") );
193
CHECKGL( glBindAttribLocation(m_SlColorModTexMaskAlpha->GetOpenGLID(), 1, "MyTextureCoord0") );
194
CHECKGL( glBindAttribLocation(m_SlColorModTexMaskAlpha->GetOpenGLID(), 2, "VectexColor") );
195
m_SlColorModTexMaskAlpha->Link();
197
m_SlColorModTexRectMaskAlpha = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
198
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
199
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2DRECT"));
200
m_SlColorModTexRectMaskAlpha->ClearShaderObjects();
201
m_SlColorModTexRectMaskAlpha->AddShaderObject(VS);
202
m_SlColorModTexRectMaskAlpha->AddShaderObject(PS);
203
CHECKGL( glBindAttribLocation(m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 0, "AVertex") );
204
CHECKGL( glBindAttribLocation(m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 1, "MyTextureCoord0") );
205
CHECKGL( glBindAttribLocation(m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 2, "VectexColor") );
206
m_SlColorModTexRectMaskAlpha->Link();
209
void GraphicsContext::InitSl2TextureAdd()
211
TRefGL<IOpenGLVertexShader> VS = m_GLWindow.m_DeviceFactory->CreateVertexShader();
212
TRefGL<IOpenGLPixelShader> PS = m_GLWindow.m_DeviceFactory->CreatePixelShader();
216
// For some strange reason, make sure that the attribute holding the vertex position has a name that comes first in alphabetic order before all
217
// other attributes. Otherwise you get a bug on NVidia! Why is that???
219
////////////////////////////////////////////////////////////////////////////////////////////////////
220
VSString = TEXT( "#version 110 \n\
221
uniform mat4 ViewProjectionMatrix; \n\
222
attribute vec4 AVertex; \n\
223
attribute vec4 MyTextureCoord0; \n\
224
attribute vec4 MyTextureCoord1; \n\
225
varying vec4 varyTexCoord0; \n\
226
varying vec4 varyTexCoord1; \n\
229
varyTexCoord0 = MyTextureCoord0; \n\
230
varyTexCoord1 = MyTextureCoord1; \n\
231
gl_Position = ViewProjectionMatrix * (AVertex); \n\
234
PSString = TEXT( "#version 110 \n\
235
#extension GL_ARB_texture_rectangle : enable \n\
236
varying vec4 varyTexCoord0; \n\
237
varying vec4 varyTexCoord1; \n\
238
uniform vec4 color0; \n\
239
uniform vec4 color1; \n\
240
#ifdef SAMPLERTEX2D \n\
241
uniform sampler2D TextureObject0; \n\
242
uniform sampler2D TextureObject1; \n\
243
vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
245
return texture2D(TexObject, TexCoord.st); \n\
247
#elif defined SAMPLERTEX2DRECT \n\
248
uniform sampler2DRect TextureObject0; \n\
249
uniform sampler2DRect TextureObject1; \n\
250
vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
252
return texture2DRect(TexObject, TexCoord.st); \n\
254
#elif define MOD_TEX_COLOR_RGB \n\
256
#elif define MOD_TEX_COLOR_ALPHA \n\
261
vec4 b0 = color0*SampleTexture(TextureObject0, varyTexCoord0); \n\
262
vec4 b1 = color1*SampleTexture(TextureObject1, varyTexCoord1); \n\
263
gl_FragColor = b0.a*b0 + b1; \n\
266
//vec4(v.w, v.w, v.w, v.w)
268
// Textured 2D Primitive Shader
269
m_Sl2TextureAdd = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
270
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
271
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2D"));
273
m_Sl2TextureAdd->ClearShaderObjects();
274
m_Sl2TextureAdd->AddShaderObject(VS);
275
m_Sl2TextureAdd->AddShaderObject(PS);
276
CHECKGL( glBindAttribLocation(m_Sl2TextureAdd->GetOpenGLID(), 0, "AVertex") );
277
m_Sl2TextureAdd->Link();
280
void GraphicsContext::InitSl4TextureAdd()
282
TRefGL<IOpenGLVertexShader> VS = m_GLWindow.m_DeviceFactory->CreateVertexShader();
283
TRefGL<IOpenGLPixelShader> PS = m_GLWindow.m_DeviceFactory->CreatePixelShader();
287
// For some strange reason, make sure that the attribute holding the vertex position has a name that comes first in alphabetic order before all
288
// other attributes. Otherwise you get a bug on NVidia! Why is that???
290
////////////////////////////////////////////////////////////////////////////////////////////////////
291
VSString = TEXT( "#version 110 \n\
292
uniform mat4 ViewProjectionMatrix; \n\
293
attribute vec4 AVertex; \n\
294
attribute vec4 MyTextureCoord0; \n\
295
attribute vec4 MyTextureCoord1; \n\
296
attribute vec4 MyTextureCoord2; \n\
297
attribute vec4 MyTextureCoord3; \n\
298
varying vec4 varyTexCoord0; \n\
299
varying vec4 varyTexCoord1; \n\
300
varying vec4 varyTexCoord2; \n\
301
varying vec4 varyTexCoord3; \n\
304
varyTexCoord0 = MyTextureCoord0; \n\
305
varyTexCoord1 = MyTextureCoord1; \n\
306
varyTexCoord2 = MyTextureCoord2; \n\
307
varyTexCoord3 = MyTextureCoord3; \n\
308
gl_Position = ViewProjectionMatrix * (AVertex); \n\
311
PSString = TEXT( "#version 110 \n\
312
#extension GL_ARB_texture_rectangle : enable \n\
313
varying vec4 varyTexCoord0; \n\
314
varying vec4 varyTexCoord1; \n\
315
varying vec4 varyTexCoord2; \n\
316
varying vec4 varyTexCoord3; \n\
317
uniform vec4 color0; \n\
318
uniform vec4 color1; \n\
319
uniform vec4 color2; \n\
320
uniform vec4 color3; \n\
321
#ifdef SAMPLERTEX2D \n\
322
uniform sampler2D TextureObject0; \n\
323
uniform sampler2D TextureObject1; \n\
324
uniform sampler2D TextureObject2; \n\
325
uniform sampler2D TextureObject3; \n\
326
vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
328
return texture2D(TexObject, TexCoord.st); \n\
330
#elif defined SAMPLERTEX2DRECT \n\
331
uniform sampler2DRect TextureObject0; \n\
332
uniform sampler2DRect TextureObject1; \n\
333
uniform sampler2DRect TextureObject2; \n\
334
uniform sampler2DRect TextureObject3; \n\
335
vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
337
return texture2DRect(TexObject, TexCoord.st); \n\
342
vec4 b0 = color0*SampleTexture(TextureObject0, varyTexCoord0); \n\
343
vec4 b1 = color1*SampleTexture(TextureObject1, varyTexCoord1); \n\
344
vec4 b2 = color2*SampleTexture(TextureObject2, varyTexCoord2); \n\
345
vec4 b3 = color3*SampleTexture(TextureObject3, varyTexCoord3); \n\
346
gl_FragColor = b0+b1+b2+b3; \n\
349
//vec4(v.w, v.w, v.w, v.w)
351
// Textured 2D Primitive Shader
352
m_Sl4TextureAdd = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
353
VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
354
PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2D"));
356
m_Sl4TextureAdd->ClearShaderObjects();
357
m_Sl4TextureAdd->AddShaderObject(VS);
358
m_Sl4TextureAdd->AddShaderObject(PS);
359
CHECKGL( glBindAttribLocation(m_Sl4TextureAdd->GetOpenGLID(), 0, "AVertex") );
360
m_Sl4TextureAdd->Link();
362
// // Textured Rect Primitive Shader
363
// m_4TexBlendRectProg = m_GLWindow.m_DeviceFactory->CreateShaderProgram();
364
// VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
365
// PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2DRECT"));
366
// m_4TexBlendRectProg->ClearShaderObjects();
367
// m_4TexBlendRectProg->AddShaderObject(VS);
368
// m_4TexBlendRectProg->AddShaderObject(PS);
369
// CHECKGL( glBindAttribLocation(m_4TexBlendRectProg->GetOpenGLID(), 0, "AVertex") );
370
// m_4TexBlendRectProg->Link();
373
void GraphicsContext::QRP_GLSL_Color(int x, int y, int width, int height, const Color& color)
376
QRP_Color(x, y, width, height, color, color, color, color);
380
QRP_GLSL_Color(x, y, width, height, color, color, color, color);
383
void GraphicsContext::QRP_GLSL_Color(int x, int y, int width, int height, const Color& c0, const Color& c1, const Color& c2, const Color& c3)
386
QRP_Color(x, y, width, height, c0, c1, c2, c3);
394
x, y, 0.0f, 1.0f, c0.R(), c0.G(), c0.B(), c0.A(),
395
x, y + height, 0.0f, 1.0f, c1.R(), c1.G(), c1.B(), c1.A(),
396
x + width, y + height, 0.0f, 1.0f, c2.R(), c2.G(), c2.B(), c2.A(),
397
x + width, y, 0.0f, 1.0f, c3.R(), c3.G(), c3.B(), c3.A(),
400
TRefGL<IOpenGLShaderProgram> ShaderProg = m_SlColor;
402
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
403
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
406
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
407
int VertexColorLocation = ShaderProg->GetAttributeLocation("VertexColor");
409
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
410
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
412
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
413
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 32, VtxBuffer) );
415
if(VertexColorLocation != -1)
417
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
418
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 32, VtxBuffer + 4) );
421
CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
423
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
424
if(VertexColorLocation != -1)
425
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
429
void GraphicsContext::QRP_GLSL_1Tex(int x, int y, int width, int height, TRefGL<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform0, const Color& color0)
432
QRP_1Tex(x, y, width, height, DeviceTexture, texxform0, color0);
437
QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);
440
x, y, 0.0f, 1.0f, texxform0.u0, texxform0.v0, 0, 0, color0.R(), color0.G(), color0.B(), color0.A(),
441
x, y + height, 0.0f, 1.0f, texxform0.u0, texxform0.v1, 0, 0, color0.R(), color0.G(), color0.B(), color0.A(),
442
x + width, y + height, 0.0f, 1.0f, texxform0.u1, texxform0.v1, 0, 0, color0.R(), color0.G(), color0.B(), color0.A(),
443
x + width, y, 0.0f, 1.0f, texxform0.u1, texxform0.v0, 0, 0, color0.R(), color0.G(), color0.B(), color0.A(),
446
TRefGL<IOpenGLShaderProgram> ShaderProg;
447
if(DeviceTexture->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType))
449
ShaderProg = m_SlTextureModColor;
452
// if(DeviceTexture->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) ||
453
// DeviceTexture->Type().IsDerivedFromType(IOpenGLAnimatedTexture::StaticObjectType))
455
// ShaderProg = m_TexturedRectProg;
458
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
459
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
462
int TextureObjectLocation = ShaderProg->GetUniformLocationARB("TextureObject0");
463
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
464
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
465
int VertexColorLocation = ShaderProg->GetAttributeLocation("VertexColor");
467
SetTexture(GL_TEXTURE0, DeviceTexture);
468
CHECKGL( glUniform1iARB(TextureObjectLocation, 0) );
470
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
471
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
473
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
474
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
476
if(TextureCoord0Location != -1)
478
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
479
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
482
if(VertexColorLocation != -1)
484
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
485
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
488
CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
490
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
491
if(TextureCoord0Location != -1)
492
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
493
if(VertexColorLocation != -1)
494
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
498
// Render the texture alpha into RGB and modulated by a color.
499
void GraphicsContext::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height,
500
TRefGL< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform, const Color& color)
503
QRP_ColorModTexAlpha(x, y, width, height, DeviceTexture, texxform, color);
508
QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform);
512
x, y, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, color.R(), color.G(), color.B(), color.A(),
513
x, y + height, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, color.R(), color.G(), color.B(), color.A(),
514
x + width, y + height, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, color.R(), color.G(), color.B(), color.A(),
515
x + width, y, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, color.R(), color.G(), color.B(), color.A(),
518
TRefGL<IOpenGLShaderProgram> ShaderProg;
519
// if(DeviceTexture->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType))
521
ShaderProg = m_SlColorModTexMaskAlpha;
524
if(DeviceTexture->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) ||
525
DeviceTexture->Type().IsDerivedFromType(IOpenGLAnimatedTexture::StaticObjectType))
527
ShaderProg = m_SlColorModTexRectMaskAlpha;
530
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
531
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
534
int TextureObjectLocation = ShaderProg->GetUniformLocationARB("TextureObject0");
535
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
536
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
537
int VertexColorLocation = ShaderProg->GetAttributeLocation("VertexColor");
539
SetTexture(GL_TEXTURE0, DeviceTexture);
541
if(TextureObjectLocation != -1)
543
CHECKGL( glUniform1iARB(TextureObjectLocation, 0) );
546
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
547
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
549
if(VertexLocation != -1)
551
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
552
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
555
if(TextureCoord0Location != -1)
557
CHECKGL( glEnableVertexAttribArray(TextureCoord0Location) );
558
CHECKGL( glVertexAttribPointer((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
561
if(VertexColorLocation != -1)
563
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
564
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
567
CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
569
if(VertexLocation != -1)
570
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
571
if(TextureCoord0Location != -1)
573
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
575
if(VertexColorLocation != -1)
577
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
582
// Blend 2 textures together
583
void GraphicsContext::QRP_GLSL_2Tex(int x, int y, int width, int height,
584
TRefGL<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm& texxform0, const Color& color0,
585
TRefGL<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm& texxform1, const Color& color1)
588
QRP_2Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
592
bool bRectangleTexture = false;
593
TRefGL<IOpenGLShaderProgram> ShaderProg;
594
// if(SrcTexture0->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType) &&
595
// SrcTexture1->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType))
597
ShaderProg = m_Sl2TextureAdd;
600
// if((SrcTexture0->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) &&
601
// SrcTexture1->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType)) /*||
602
// (SrcTexture0->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType) &&
603
// SrcTexture1->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType)*/)
605
// bRectangleTexture = true;
606
// ShaderProg = m_2TexBlendRectProg;
609
QRP_Compute_Texture_Coord(width, height, DeviceTexture0, texxform0);
610
QRP_Compute_Texture_Coord(width, height, DeviceTexture1, texxform1);
614
x, y, 0.0f, 1.0f, texxform0.u0, texxform0.v0, 0.0f, 1.0f, texxform1.u0, texxform1.v0, 0.0f, 1.0f,
615
x, y + height, 0.0f, 1.0f, texxform0.u0, texxform0.v1, 0.0f, 1.0f, texxform1.u0, texxform1.v1, 0.0f, 1.0f,
616
x + width, y + height, 0.0f, 1.0f, texxform0.u1, texxform0.v1, 0.0f, 1.0f, texxform1.u1, texxform1.v1, 0.0f, 1.0f,
617
x + width, y, 0.0f, 1.0f, texxform0.u1, texxform0.v0, 0.0f, 1.0f, texxform1.u1, texxform1.v0, 0.0f, 1.0f,
620
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
621
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
624
int TextureObjectLocation0 = ShaderProg->GetUniformLocationARB("TextureObject0");
625
int TextureObjectLocation1 = ShaderProg->GetUniformLocationARB("TextureObject1");
626
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
627
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
628
int TextureCoord1Location = ShaderProg->GetAttributeLocation("MyTextureCoord1");
630
int TextureCoef0Location = ShaderProg->GetUniformLocationARB("color0");
631
int TextureCoef1Location = ShaderProg->GetUniformLocationARB("color1");
634
SetTexture(GL_TEXTURE0, DeviceTexture0);
635
SetTexture(GL_TEXTURE1, DeviceTexture1);
637
CHECKGL( glUniform1iARB(TextureObjectLocation0, 0) );
638
CHECKGL( glUniform1iARB(TextureObjectLocation1, 1) );
640
CHECKGL( glUniform4fARB(TextureCoef0Location, color0.R(), color0.G(), color0.B(), color0.A()) );
641
CHECKGL( glUniform4fARB(TextureCoef1Location, color1.R(), color1.G(), color1.B(), color1.A()) );
643
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
644
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
646
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
647
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
649
if(TextureCoord0Location != -1)
651
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
652
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
654
if(TextureCoord1Location != -1)
656
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord1Location) );
657
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord1Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
660
CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
662
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
663
if(TextureCoord0Location != -1)
664
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
665
if(TextureCoord1Location != -1)
666
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord1Location) );
671
void GraphicsContext::QRP_GLSL_4Tex(int x, int y, int width, int height,
672
TRefGL<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm& texxform0, const Color& color0,
673
TRefGL<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm& texxform1, const Color& color1,
674
TRefGL<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm& texxform2, const Color& color2,
675
TRefGL<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm& texxform3, const Color& color3)
678
QRP_4Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1,
679
DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3);
683
QRP_Compute_Texture_Coord(width, height, DeviceTexture0, texxform0);
684
QRP_Compute_Texture_Coord(width, height, DeviceTexture1, texxform1);
685
QRP_Compute_Texture_Coord(width, height, DeviceTexture2, texxform2);
686
QRP_Compute_Texture_Coord(width, height, DeviceTexture3, texxform3);
688
bool bRectangleTexture = false;
689
TRefGL<IOpenGLShaderProgram> ShaderProg;
690
// if(SrcTexture0->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType) &&
691
// SrcTexture1->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType) &&
692
// SrcTexture2->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType) &&
693
// SrcTexture3->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType))
695
ShaderProg = m_Sl4TextureAdd;
698
// if((SrcTexture0->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) &&
699
// SrcTexture1->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) &&
700
// SrcTexture2->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType) &&
701
// SrcTexture3->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType)) /*||
702
// (SrcTexture0->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType) &&
703
// SrcTexture1->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType) &&
704
// SrcTexture2->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType) &&
705
// SrcTexture3->Type().IsDerivedFromType(NAnimatedTexture::StaticObjectType))*/)
707
// bRectangleTexture = true;
708
// ShaderProg = m_4TexBlendRectProg;
713
x, y, 0.0f, 1.0f, texxform0.u0, texxform0.v0, 0, 1.0f, texxform1.u0, texxform1.v0, 0, 1.0f, texxform2.u0, texxform2.v0, 0, 1.0f, texxform3.u0, texxform3.v0, 0, 1.0f,
714
x, y + height, 0.0f, 1.0f, texxform0.u0, texxform0.v1, 0, 1.0f, texxform1.u0, texxform1.v1, 0, 1.0f, texxform2.u0, texxform2.v1, 0, 1.0f, texxform3.u0, texxform3.v1, 0, 1.0f,
715
x + width, y + height, 0.0f, 1.0f, texxform0.u1, texxform0.v1, 0, 1.0f, texxform1.u1, texxform1.v1, 0, 1.0f, texxform2.u1, texxform2.v1, 0, 1.0f, texxform3.u1, texxform3.v1, 0, 1.0f,
716
x + width, y, 0.0f, 1.0f, texxform0.u1, texxform0.v0, 0, 1.0f, texxform1.u1, texxform1.v0, 0, 1.0f, texxform2.u1, texxform2.v0, 0, 1.0f, texxform3.u1, texxform3.v0, 0, 1.0f,
719
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
720
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
723
int TextureObjectLocation0 = ShaderProg->GetUniformLocationARB("TextureObject0");
724
int TextureObjectLocation1 = ShaderProg->GetUniformLocationARB("TextureObject1");
725
int TextureObjectLocation2 = ShaderProg->GetUniformLocationARB("TextureObject2");
726
int TextureObjectLocation3 = ShaderProg->GetUniformLocationARB("TextureObject3");
727
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
728
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
729
int TextureCoord1Location = ShaderProg->GetAttributeLocation("MyTextureCoord1");
730
int TextureCoord2Location = ShaderProg->GetAttributeLocation("MyTextureCoord2");
731
int TextureCoord3Location = ShaderProg->GetAttributeLocation("MyTextureCoord3");
733
int TextureCoef0Location = ShaderProg->GetUniformLocationARB("color0");
734
int TextureCoef1Location = ShaderProg->GetUniformLocationARB("color1");
735
int TextureCoef2Location = ShaderProg->GetUniformLocationARB("color2");
736
int TextureCoef3Location = ShaderProg->GetUniformLocationARB("color3");
738
SetTexture(GL_TEXTURE0, DeviceTexture0);
739
SetTexture(GL_TEXTURE1, DeviceTexture1);
740
SetTexture(GL_TEXTURE2, DeviceTexture2);
741
SetTexture(GL_TEXTURE3, DeviceTexture3);
743
CHECKGL( glUniform1iARB(TextureObjectLocation0, 0) );
744
CHECKGL( glUniform1iARB(TextureObjectLocation1, 1) );
745
CHECKGL( glUniform1iARB(TextureObjectLocation2, 2) );
746
CHECKGL( glUniform1iARB(TextureObjectLocation3, 3) );
748
CHECKGL( glUniform4fARB(TextureCoef0Location, color0.R(), color0.G(), color0.B(), color0.A()) );
749
CHECKGL( glUniform4fARB(TextureCoef1Location, color1.R(), color1.G(), color1.B(), color1.A()) );
750
CHECKGL( glUniform4fARB(TextureCoef0Location, color2.R(), color2.G(), color2.B(), color2.A()) );
751
CHECKGL( glUniform4fARB(TextureCoef1Location, color3.R(), color3.G(), color3.B(), color3.A()) );
753
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
754
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
756
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
757
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 80, VtxBuffer) );
759
if(TextureCoord0Location != -1)
761
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
762
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 80, VtxBuffer + 4) );
764
if(TextureCoord1Location != -1)
766
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord1Location) );
767
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord1Location, 4, GL_FLOAT, GL_FALSE, 80, VtxBuffer + 8) );
769
if(TextureCoord2Location != -1)
771
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord2Location) );
772
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord2Location, 4, GL_FLOAT, GL_FALSE, 80, VtxBuffer + 12) );
774
if(TextureCoord3Location != -1)
776
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord3Location) );
777
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord3Location, 4, GL_FLOAT, GL_FALSE, 80, VtxBuffer + 16) );
780
CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
782
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
783
if(TextureCoord0Location != -1)
784
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
785
if(TextureCoord1Location != -1)
786
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord1Location) );
787
if(TextureCoord2Location != -1)
788
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord2Location) );
789
if(TextureCoord3Location != -1)
790
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord3Location) );
794
///////////////////////////////////////////
795
void GraphicsContext::QRP_GLSL_Triangle(int x0, int y0,
801
QRP_Triangle(x0, y0, x1, y1, x2, y2, c0, c0, c0);
805
QRP_GLSL_Triangle(x0, y0, x1, y1, x2, y2, c0, c0, c0);
808
void GraphicsContext::QRP_GLSL_Triangle(int x0, int y0,
811
Color c0, Color c1, Color c2)
814
QRP_Triangle(x0, y0, x1, y1, x2, y2, c0, c1, c2);
820
x0, y0, 0.0f, 1.0f, c0.R(), c0.G(), c0.B(), c0.A(),
821
x1, y1, 0.0f, 1.0f, c1.R(), c1.G(), c1.B(), c1.A(),
822
x2, y2, 0.0f, 1.0f, c2.R(), c2.G(), c2.B(), c2.A(),
825
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
826
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
830
int VertexLocation = m_SlColor->GetAttributeLocation("AVertex");
831
int VertexColorLocation = m_SlColor->GetAttributeLocation("VertexColor");
833
int VPMatrixLocation = m_SlColor->GetUniformLocationARB("ViewProjectionMatrix");
834
m_SlColor->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
836
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
837
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 32, VtxBuffer) );
839
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
840
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 32, VtxBuffer + 4) );
842
CHECKGL( glDrawArrays(GL_TRIANGLES, 0, 3) );
844
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
845
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
851
//////////////////////
853
//////////////////////
854
void GraphicsContext::QRP_GLSL_Line(int x0, int y0,
855
int x1, int y1, Color c0)
858
QRP_Line(x0, y0, x1, y1, c0, c0);
862
QRP_Line(x0, y0, x1, y1, c0, c0);
865
void GraphicsContext::QRP_GLSL_Line(int x0, int y0,
866
int x1, int y1, Color c0, Color c1)
869
QRP_Line(x0, y0, x1, y1, c0, c1);
875
x0, y0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c0.R(), c0.G(), c0.B(), c0.A(),
876
x1, y1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c1.R(), c1.G(), c1.B(), c1.A(),
879
TRefGL<IOpenGLShaderProgram> ShaderProg = m_SlColor;
882
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
883
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
886
int TextureObjectLocation = ShaderProg->GetUniformLocationARB("TextureObject0");
887
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
888
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
889
int VertexColorLocation = ShaderProg->GetAttributeLocation("VertexColor");
892
CHECKGL( glUniform1iARB(TextureObjectLocation, 0) );
894
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
895
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
897
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
898
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
900
if(TextureCoord0Location != -1)
902
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
903
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
906
if(VertexColorLocation != -1)
908
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
909
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
912
CHECKGL( glDrawArrays(GL_LINES, 0, 2) );
914
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
915
if(TextureCoord0Location != -1)
916
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
917
if(VertexColorLocation != -1)
918
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
924
void GraphicsContext::QRP_GLSL_QuadWireframe(int x0, int y0, int width, int height,
931
QRP_QuadWireframe(x0, y0, width, height, c0, c1, c2, c3);
937
x0, y0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c0.R(), c0.G(), c0.B(), c0.A(),
938
x0, y0 + height - 1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c1.R(), c1.G(), c1.B(), c1.A(),
939
x0 + width - 1, y0 + height - 1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c2.R(), c2.G(), c2.B(), c2.A(),
940
x0 + width - 1, y0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c3.R(), c3.G(), c3.B(), c3.A(),
941
x0, y0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, c0.R(), c0.G(), c0.B(), c0.A(),
944
TRefGL<IOpenGLShaderProgram> ShaderProg = m_SlColor;
947
CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
948
CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
951
int TextureObjectLocation = ShaderProg->GetUniformLocationARB("TextureObject0");
952
int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
953
int TextureCoord0Location = ShaderProg->GetAttributeLocation("MyTextureCoord0");
954
int VertexColorLocation = ShaderProg->GetAttributeLocation("VertexColor");
957
CHECKGL( glUniform1iARB(TextureObjectLocation, 0) );
959
int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
960
ShaderProg->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(GetModelViewProjectionMatrix().m));
962
CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
963
CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
965
if(TextureCoord0Location != -1)
967
CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
968
CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
971
if(VertexColorLocation != -1)
973
CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
974
CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
977
CHECKGL( glDrawArrays(GL_LINE_STRIP, 0, 5) );
979
CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
980
if(TextureCoord0Location != -1)
981
CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
982
if(VertexColorLocation != -1)
983
CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );