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/NuxCore.h"
24
#include "GLResource.h"
26
#include "GLDeviceObjects.h"
30
// //-----------------------------------------------------------------------------
31
// bool IOpenGLShaderProgram::SetUniform1f(char* varname, GLfloat v0)
33
// //if (!useGLSL) return false; // GLSL not available
34
// //if (!_noshader) return true;
36
// GLint loc = GetUniformLocationARB(varname);
37
// if (loc==-1) return false; // can't find variable
39
// glUniform1fARB(loc, v0);
43
// bool IOpenGLShaderProgram::SetUniform1f(GLint loc, GLfloat v0)
45
// //if (!useGLSL) return false; // GLSL not available
46
// //if (!_noshader) return true;
48
// if (loc==-1) return false; // can't find variable
49
// glUniform1fARB(loc, v0);
53
// //-----------------------------------------------------------------------------
55
// bool IOpenGLShaderProgram::SetUniform2f(char* varname, GLfloat v0, GLfloat v1)
57
// //if (!useGLSL) return false; // GLSL not available
58
// //if (!_noshader) return true;
60
// GLint loc = GetUniformLocationARB(varname);
61
// if (loc==-1) return false; // can't find variable
63
// glUniform2fARB(loc, v0, v1);
67
// bool IOpenGLShaderProgram::SetUniform2f(GLint loc, GLfloat v0, GLfloat v1)
69
// //if (!useGLSL) return false; // GLSL not available
70
// //if (!_noshader) return true;
72
// if (loc==-1) return false; // can't find variable
73
// glUniform2fARB(loc, v0, v1);
76
// //-----------------------------------------------------------------------------
78
// bool IOpenGLShaderProgram::SetUniform3f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2)
80
// //if (!useGLSL) return false; // GLSL not available
81
// //if (!_noshader) return true;
83
// GLint loc = GetUniformLocationARB(varname);
84
// if (loc==-1) return false; // can't find variable
86
// glUniform3fARB(loc, v0, v1, v2);
90
// bool IOpenGLShaderProgram::SetUniform3f(GLint loc, GLfloat v0, GLfloat v1, GLfloat v2)
92
// //if (!useGLSL) return false; // GLSL not available
93
// //if (!_noshader) return true;
95
// if (loc==-1) return false; // can't find variable
97
// glUniform3fARB(loc, v0, v1, v2);
101
// //-----------------------------------------------------------------------------
103
// bool IOpenGLShaderProgram::SetUniform4f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
105
// //if (!useGLSL) return false; // GLSL not available
106
// //if (!_noshader) return true;
108
// GLint loc = GetUniformLocationARB(varname);
109
// if (loc==-1) return false; // can't find variable
111
// glUniform4fARB(loc, v0, v1, v2, v3);
115
// bool IOpenGLShaderProgram::SetUniform4f(GLint loc, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
117
// //if (!useGLSL) return false; // GLSL not available
118
// //if (!_noshader) return true;
120
// if (loc==-1) return false; // can't find variable
122
// glUniform4fARB(loc, v0, v1, v2, v3);
126
// //-----------------------------------------------------------------------------
128
// bool IOpenGLShaderProgram::SetUniform1i(char* varname, GLint v0)
130
// //if (!useGLSL) return false; // GLSL not available
131
// //if (!_noshader) return true;
133
// GLint loc = GetUniformLocationARB(varname);
134
// if (loc==-1) return false; // can't find variable
136
// glUniform1iARB(loc, v0);
140
// bool IOpenGLShaderProgram::SetUniform1i(GLint loc, GLint v0)
142
// //if (!useGLSL) return false; // GLSL not available
143
// //if (!_noshader) return true;
145
// if (loc==-1) return false; // can't find variable
147
// glUniform1iARB(loc, v0);
152
// bool IOpenGLShaderProgram::SetUniform2i(char* varname, GLint v0, GLint v1)
154
// // if (!useGLSL) return false; // GLSL not available
155
// // if (!_noshader) return true;
157
// GLint loc = GetUniformLocationARB(varname);
158
// if (loc==-1) return false; // can't find variable
160
// glUniform2iARB(loc, v0, v1);
165
// bool IOpenGLShaderProgram::SetUniform2i(GLint loc, GLint v0, GLint v1)
167
// // if (!useGLSL) return false; // GLSL not available
168
// // if (!_noshader) return true;
170
// if (loc==-1) return false; // can't find variable
172
// glUniform2iARB(loc, v0, v1);
177
// //-----------------------------------------------------------------------------
179
// bool IOpenGLShaderProgram::SetUniform3i(char* varname, GLint v0, GLint v1, GLint v2)
181
// // if (!useGLSL) return false; // GLSL not available
182
// // if (!_noshader) return true;
184
// GLint loc = GetUniformLocationARB(varname);
185
// if (loc==-1) return false; // can't find variable
187
// glUniform3iARB(loc, v0, v1, v2);
191
// bool IOpenGLShaderProgram::SetUniform3i(GLint loc, GLint v0, GLint v1, GLint v2)
193
// // if (!useGLSL) return false; // GLSL not available
194
// // if (!_noshader) return true;
196
// if (loc==-1) return false; // can't find variable
198
// glUniform3iARB(loc, v0, v1, v2);
203
// bool IOpenGLShaderProgram::SetUniform4i(char* varname, GLint v0, GLint v1, GLint v2, GLint v3)
205
// // if (!useGLSL) return false; // GLSL not available
206
// // if (!_noshader) return true;
208
// GLint loc = GetUniformLocationARB(varname);
209
// if (loc==-1) return false; // can't find variable
211
// glUniform4iARB(loc, v0, v1, v2, v3);
215
// bool IOpenGLShaderProgram::SetUniform4i(GLint loc, GLint v0, GLint v1, GLint v2, GLint v3)
217
// // if (!useGLSL) return false; // GLSL not available
218
// // if (!_noshader) return true;
220
// if (loc==-1) return false; // can't find variable
222
// glUniform4iARB(loc, v0, v1, v2, v3);
226
// //-----------------------------------------------------------------------------
228
// bool IOpenGLShaderProgram::SetUniform1fv(char* varname, GLsizei count, GLfloat *value)
230
// // if (!useGLSL) return false; // GLSL not available
231
// // if (!_noshader) return true;
233
// GLint loc = GetUniformLocationARB(varname);
234
// if (loc==-1) return false; // can't find variable
236
// glUniform1fvARB(loc, count, value);
240
// bool IOpenGLShaderProgram::SetUniform1fv(GLint loc, GLsizei count, GLfloat *value)
242
// // if (!useGLSL) return false; // GLSL not available
243
// // if (!_noshader) return true;
245
// if (loc==-1) return false; // can't find variable
247
// glUniform1fvARB(loc, count, value);
252
// bool IOpenGLShaderProgram::SetUniform2fv(char* varname, GLsizei count, GLfloat *value)
254
// // if (!useGLSL) return false; // GLSL not available
255
// // if (!_noshader) return true;
257
// GLint loc = GetUniformLocationARB(varname);
258
// if (loc==-1) return false; // can't find variable
260
// glUniform2fvARB(loc, count, value);
264
// bool IOpenGLShaderProgram::SetUniform2fv(GLint loc, GLsizei count, GLfloat *value)
266
// // if (!useGLSL) return false; // GLSL not available
267
// // if (!_noshader) return true;
269
// if (loc==-1) return false; // can't find variable
271
// glUniform2fvARB(loc, count, value);
275
// //-----------------------------------------------------------------------------
277
// bool IOpenGLShaderProgram::SetUniform3fv(char* varname, GLsizei count, GLfloat *value)
279
// // if (!useGLSL) return false; // GLSL not available
280
// // if (!_noshader) return true;
282
// GLint loc = GetUniformLocationARB(varname);
283
// if (loc==-1) return false; // can't find variable
285
// glUniform3fvARB(loc, count, value);
289
// bool IOpenGLShaderProgram::SetUniform3fv(GLint loc, GLsizei count, GLfloat *value)
291
// // if (!useGLSL) return false; // GLSL not available
292
// // if (!_noshader) return true;
294
// if (loc==-1) return false; // can't find variable
296
// glUniform3fvARB(loc, count, value);
300
// //-----------------------------------------------------------------------------
302
// bool IOpenGLShaderProgram::SetUniform4fv(char* varname, GLsizei count, GLfloat *value)
304
// // if (!useGLSL) return false; // GLSL not available
305
// // if (!_noshader) return true;
307
// GLint loc = GetUniformLocationARB(varname);
308
// if (loc==-1) return false; // can't find variable
310
// glUniform4fvARB(loc, count, value);
314
// bool IOpenGLShaderProgram::SetUniform4fv(GLint loc, GLsizei count, GLfloat *value)
316
// // if (!useGLSL) return false; // GLSL not available
317
// // if (!_noshader) return true;
319
// if (loc==-1) return false; // can't find variable
321
// glUniform4fvARB(loc, count, value);
325
// //-----------------------------------------------------------------------------
327
// bool IOpenGLShaderProgram::SetUniform1iv(char* varname, GLsizei count, GLint *value)
329
// // if (!useGLSL) return false; // GLSL not available
330
// // if (!_noshader) return true;
332
// GLint loc = GetUniformLocationARB(varname);
333
// if (loc==-1) return false; // can't find variable
335
// glUniform1ivARB(loc, count, value);
339
// bool IOpenGLShaderProgram::SetUniform1iv(GLint loc, GLsizei count, GLint *value)
341
// // if (!useGLSL) return false; // GLSL not available
342
// // if (!_noshader) return true;
344
// if (loc==-1) return false; // can't find variable
346
// glUniform1ivARB(loc, count, value);
350
// //-----------------------------------------------------------------------------
352
// bool IOpenGLShaderProgram::SetUniform2iv(char* varname, GLsizei count, GLint *value)
354
// // if (!useGLSL) return false; // GLSL not available
355
// // if (!_noshader) return true;
357
// GLint loc = GetUniformLocationARB(varname);
358
// if (loc==-1) return false; // can't find variable
360
// glUniform2ivARB(loc, count, value);
364
// bool IOpenGLShaderProgram::SetUniform2iv(GLint loc, GLsizei count, GLint *value)
366
// // if (!useGLSL) return false; // GLSL not available
367
// // if (!_noshader) return true;
369
// if (loc==-1) return false; // can't find variable
371
// glUniform2ivARB(loc, count, value);
375
// //-----------------------------------------------------------------------------
377
// bool IOpenGLShaderProgram::SetUniform3iv(char* varname, GLsizei count, GLint *value)
379
// // if (!useGLSL) return false; // GLSL not available
380
// // if (!_noshader) return true;
382
// GLint loc = GetUniformLocationARB(varname);
383
// if (loc==-1) return false; // can't find variable
385
// glUniform3ivARB(loc, count, value);
389
// bool IOpenGLShaderProgram::SetUniform3iv(GLint loc, GLsizei count, GLint *value)
391
// // if (!useGLSL) return false; // GLSL not available
392
// // if (!_noshader) return true;
394
// if (loc==-1) return false; // can't find variable
396
// glUniform3ivARB(loc, count, value);
400
// //-----------------------------------------------------------------------------
402
// bool IOpenGLShaderProgram::SetUniform4iv(char* varname, GLsizei count, GLint *value)
404
// // if (!useGLSL) return false; // GLSL not available
405
// // if (!_noshader) return true;
407
// GLint loc = GetUniformLocationARB(varname);
408
// if (loc==-1) return false; // can't find variable
410
// glUniform4ivARB(loc, count, value);
414
// bool IOpenGLShaderProgram::SetUniform4iv(GLint loc, GLsizei count, GLint *value)
416
// // if (!useGLSL) return false; // GLSL not available
417
// // if (!_noshader) return true;
419
// if (loc==-1) return false; // can't find variable
421
// glUniform4ivARB(loc, count, value);
425
// //-----------------------------------------------------------------------------
427
// bool IOpenGLShaderProgram::SetUniformMatrix2fv(char* varname, GLsizei count, GLboolean transpose, GLfloat *value)
429
// // if (!useGLSL) return false; // GLSL not available
430
// // if (!_noshader) return true;
432
// GLint loc = GetUniformLocationARB(varname);
433
// if (loc==-1) return false; // can't find variable
435
// glUniformMatrix2fvARB(loc, count, transpose, value);
439
// bool IOpenGLShaderProgram::SetUniformLocMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
441
// // if (!useGLSL) return false; // GLSL not available
442
// // if (!_noshader) return true;
444
// if (loc==-1) return false; // can't find variable
446
// glUniformMatrix2fvARB(loc, count, transpose, value);
450
// //-----------------------------------------------------------------------------
452
// bool IOpenGLShaderProgram::SetUniformMatrix3fv(char* varname, GLsizei count, GLboolean transpose, GLfloat *value)
454
// // if (!useGLSL) return false; // GLSL not available
455
// // if (!_noshader) return true;
457
// GLint loc = GetUniformLocationARB(varname);
458
// if (loc==-1) return false; // can't find variable
460
// glUniformMatrix3fvARB(loc, count, transpose, value);
464
// bool IOpenGLShaderProgram::SetUniformLocMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
466
// // if (!useGLSL) return false; // GLSL not available
467
// // if (!_noshader) return true;
469
// if (loc==-1) return false; // can't find variable
471
// glUniformMatrix3fvARB(loc, count, transpose, value);
475
// //-----------------------------------------------------------------------------
477
// bool IOpenGLShaderProgram::SetUniformMatrix4fv(char* varname, GLsizei count, GLboolean transpose, GLfloat *value)
479
// // if (!useGLSL) return false; // GLSL not available
480
// // if (!_noshader) return true;
482
// GLint loc = GetUniformLocationARB(varname);
483
// if (loc==-1) return false; // can't find variable
485
// glUniformMatrix4fvARB(loc, count, transpose, value);
489
// bool IOpenGLShaderProgram::SetUniformLocMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
491
// // if (!useGLSL) return false; // GLSL not available
492
// // if (!_noshader) return true;
494
// if (loc==-1) return false; // can't find variable
496
// glUniformMatrix4fvARB(loc, count, transpose, value);
501
// //-----------------------------------------------------------------------------
503
// void IOpenGLShaderProgram::GetUniformfv(char* name, GLfloat* values)
505
// // if (!useGLSL) return;
508
// loc = glGetUniformLocationARB(_OpenGLID, name);
511
// std::cout << "Error: can't find uniform variable \"" << name << "\"\n";
513
// glGetUniformfvARB(_OpenGLID, loc, values);
516
// //-----------------------------------------------------------------------------
518
// void IOpenGLShaderProgram::GetUniformiv(char* name, GLint* values)
520
// //if (!useGLSL) return;
522
// loc = glGetUniformLocationARB(_OpenGLID, name);
525
// std::cout << "Error: can't find uniform variable \"" << name << "\"\n";
527
// glGetUniformivARB(_OpenGLID, loc, values);
529
// //-----------------------------------------------------------------------------
531
// int IOpenGLShaderProgram::GetUniformLocationARB(const GLcharARB* name)
534
// loc = glGetUniformLocationARB(_OpenGLID, name);
538
// //-----------------------------------------------------------------------------
539
// void IOpenGLShaderProgram::GetActiveUniformARB(
541
// GLsizei maxLength,
548
// glGetActiveUniformARB(_OpenGLID,
555
// CHECKGL_MSG(glGetActiveUniformARB);
558
// //-----------------------------------------------------------------------------
560
// void IOpenGLShaderProgram::GetObjectParameterfvARB(GLenum pname,
563
// glGetObjectParameterfvARB(_OpenGLID,
566
// CHECKGL_MSG(glGetObjectParameterfvARB);
569
// //-----------------------------------------------------------------------------
571
// BOOL IOpenGLShaderProgram::SetSampler(char* name, int texture_unit)
573
// GLint loc = GetUniformLocationARB(name);
574
// if (loc==-1) return false; // can't find variable
576
// glUniform1iARB(loc, texture_unit);