aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 17:24:39 +1000
committerDavid Walter Seikel2013-01-13 17:24:39 +1000
commit393b5cd1dc438872af89d334ef6e5fcc59f27d47 (patch)
tree6a14521219942a08a1b95cb2f5a923a9edd60f63 /libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp
parentAdd a note about rasters suggested start up code. (diff)
downloadSledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.zip
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.gz
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.bz2
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.xz
Added Irrlicht 1.8, but without all the Windows binaries.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp702
1 files changed, 702 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp
new file mode 100644
index 0000000..6964c18
--- /dev/null
+++ b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.cpp
@@ -0,0 +1,702 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5// This file was originally written by William Finlayson. I (Nikolaus
6// Gebhardt) did some minor modifications and changes to it and integrated it
7// into Irrlicht. Thanks a lot to William for his work on this and that he gave
8// me his permission to add it into Irrlicht using the zlib license.
9
10// After Irrlicht 0.12, Michael Zoech did some improvements to this renderer, I
11// merged this into Irrlicht 0.14, thanks to him for his work.
12
13#include "IrrCompileConfig.h"
14#ifdef _IRR_COMPILE_WITH_OPENGL_
15
16#include "COpenGLSLMaterialRenderer.h"
17#include "IGPUProgrammingServices.h"
18#include "IShaderConstantSetCallBack.h"
19#include "IMaterialRendererServices.h"
20#include "IVideoDriver.h"
21#include "os.h"
22#include "COpenGLDriver.h"
23
24namespace irr
25{
26namespace video
27{
28
29
30//! Constructor
31COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver,
32 s32& outMaterialTypeNr, const c8* vertexShaderProgram,
33 const c8* vertexShaderEntryPointName,
34 E_VERTEX_SHADER_TYPE vsCompileTarget,
35 const c8* pixelShaderProgram,
36 const c8* pixelShaderEntryPointName,
37 E_PIXEL_SHADER_TYPE psCompileTarget,
38 const c8* geometryShaderProgram,
39 const c8* geometryShaderEntryPointName,
40 E_GEOMETRY_SHADER_TYPE gsCompileTarget,
41 scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
42 u32 verticesOut,
43 IShaderConstantSetCallBack* callback,
44 video::IMaterialRenderer* baseMaterial,
45 s32 userData)
46 : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial),
47 Program(0), Program2(0), UserData(userData)
48{
49 #ifdef _DEBUG
50 setDebugName("COpenGLSLMaterialRenderer");
51 #endif
52
53 //entry points must always be main, and the compile target isn't selectable
54 //it is fine to ignore what has been asked for, as the compiler should spot anything wrong
55 //just check that GLSL is available
56
57 if (BaseMaterial)
58 BaseMaterial->grab();
59
60 if (CallBack)
61 CallBack->grab();
62
63 if (!Driver->queryFeature(EVDF_ARB_GLSL))
64 return;
65
66 init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, geometryShaderProgram);
67}
68
69
70//! constructor only for use by derived classes who want to
71//! create a fall back material for example.
72COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver,
73 IShaderConstantSetCallBack* callback,
74 IMaterialRenderer* baseMaterial, s32 userData)
75: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial),
76 Program(0), Program2(0), UserData(userData)
77{
78 if (BaseMaterial)
79 BaseMaterial->grab();
80
81 if (CallBack)
82 CallBack->grab();
83}
84
85
86//! Destructor
87COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer()
88{
89 if (CallBack)
90 CallBack->drop();
91
92 if (Program)
93 {
94 GLhandleARB shaders[8];
95 GLint count;
96 Driver->extGlGetAttachedObjects(Program, 8, &count, shaders);
97 // avoid bugs in some drivers, which return larger numbers
98 count=core::min_(count,8);
99 for (GLint i=0; i<count; ++i)
100 Driver->extGlDeleteObject(shaders[i]);
101 Driver->extGlDeleteObject(Program);
102 Program = 0;
103 }
104
105 if (Program2)
106 {
107 GLuint shaders[8];
108 GLint count;
109 Driver->extGlGetAttachedShaders(Program2, 8, &count, shaders);
110 // avoid bugs in some drivers, which return larger numbers
111 count=core::min_(count,8);
112 for (GLint i=0; i<count; ++i)
113 Driver->extGlDeleteShader(shaders[i]);
114 Driver->extGlDeleteProgram(Program2);
115 Program2 = 0;
116 }
117
118 UniformInfo.clear();
119
120 if (BaseMaterial)
121 BaseMaterial->drop();
122}
123
124
125void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr,
126 const c8* vertexShaderProgram,
127 const c8* pixelShaderProgram,
128 const c8* geometryShaderProgram,
129 scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
130 u32 verticesOut)
131{
132 outMaterialTypeNr = -1;
133
134 if (!createProgram())
135 return;
136
137#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader)
138 if (vertexShaderProgram)
139 if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram))
140 return;
141
142 if (pixelShaderProgram)
143 if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram))
144 return;
145#endif
146
147#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_program4) || defined(GL_NV_geometry_shader4)
148 if (geometryShaderProgram && Driver->queryFeature(EVDF_GEOMETRY_SHADER))
149 {
150 if (!createShader(GL_GEOMETRY_SHADER_EXT, geometryShaderProgram))
151 return;
152#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4)
153 if (Program2)
154 {
155 Driver->extGlProgramParameteri((GLhandleARB)Program2, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType));
156 Driver->extGlProgramParameteri((GLhandleARB)Program2, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType));
157 if (verticesOut==0)
158 Driver->extGlProgramParameteri((GLhandleARB)Program2, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut);
159 else
160 Driver->extGlProgramParameteri((GLhandleARB)Program2, GL_GEOMETRY_VERTICES_OUT_EXT, core::min_(verticesOut, Driver->MaxGeometryVerticesOut));
161 }
162 else
163 {
164 Driver->extGlProgramParameteri(Program, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType));
165 Driver->extGlProgramParameteri(Program, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType));
166 if (verticesOut==0)
167 Driver->extGlProgramParameteri(Program, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut);
168 else
169 Driver->extGlProgramParameteri(Program, GL_GEOMETRY_VERTICES_OUT_EXT, core::min_(verticesOut, Driver->MaxGeometryVerticesOut));
170 }
171#elif defined(GL_NV_geometry_program4)
172 if (verticesOut==0)
173 Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, Driver->MaxGeometryVerticesOut);
174 else
175 Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, core::min_(verticesOut, Driver->MaxGeometryVerticesOut));
176#endif
177 }
178#endif
179
180 if (!linkProgram())
181 return;
182
183 // register myself as new material
184 outMaterialTypeNr = Driver->addMaterialRenderer(this);
185}
186
187
188bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
189 E_VERTEX_TYPE vtxtype)
190{
191 // call callback to set shader constants
192 if (CallBack && (Program||Program2))
193 CallBack->OnSetConstants(this, UserData);
194
195 return true;
196}
197
198
199void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
200 const video::SMaterial& lastMaterial,
201 bool resetAllRenderstates,
202 video::IMaterialRendererServices* services)
203{
204 if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
205 {
206 if (Program2)
207 Driver->extGlUseProgram(Program2);
208 else if (Program)
209 Driver->extGlUseProgramObject(Program);
210
211 if (BaseMaterial)
212 BaseMaterial->OnSetMaterial(material, material, true, this);
213 }
214
215 //let callback know used material
216 if (CallBack)
217 CallBack->OnSetMaterial(material);
218
219 for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
220 Driver->setActiveTexture(i, material.getTexture(i));
221 Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
222}
223
224
225void COpenGLSLMaterialRenderer::OnUnsetMaterial()
226{
227 if (Program)
228 Driver->extGlUseProgramObject(0);
229 if (Program2)
230 Driver->extGlUseProgram(0);
231
232 if (BaseMaterial)
233 BaseMaterial->OnUnsetMaterial();
234}
235
236
237//! Returns if the material is transparent.
238bool COpenGLSLMaterialRenderer::isTransparent() const
239{
240 return BaseMaterial ? BaseMaterial->isTransparent() : false;
241}
242
243
244bool COpenGLSLMaterialRenderer::createProgram()
245{
246 if (Driver->Version>=200)
247 Program2 = Driver->extGlCreateProgram();
248 else
249 Program = Driver->extGlCreateProgramObject();
250 return true;
251}
252
253
254bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shader)
255{
256 if (Program2)
257 {
258 GLuint shaderHandle = Driver->extGlCreateShader(shaderType);
259 Driver->extGlShaderSource(shaderHandle, 1, &shader, NULL);
260 Driver->extGlCompileShader(shaderHandle);
261
262 GLint status = 0;
263
264#ifdef GL_VERSION_2_0
265 Driver->extGlGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status);
266#endif
267
268 if (status != GL_TRUE)
269 {
270 os::Printer::log("GLSL shader failed to compile", ELL_ERROR);
271 // check error message and log it
272 GLint maxLength=0;
273 GLint length;
274#ifdef GL_VERSION_2_0
275 Driver->extGlGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH,
276 &maxLength);
277#endif
278 if (maxLength)
279 {
280 GLchar *infoLog = new GLchar[maxLength];
281 Driver->extGlGetShaderInfoLog(shaderHandle, maxLength, &length, infoLog);
282 os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
283 delete [] infoLog;
284 }
285
286 return false;
287 }
288
289 Driver->extGlAttachShader(Program2, shaderHandle);
290 }
291 else
292 {
293 GLhandleARB shaderHandle = Driver->extGlCreateShaderObject(shaderType);
294
295 Driver->extGlShaderSourceARB(shaderHandle, 1, &shader, NULL);
296 Driver->extGlCompileShaderARB(shaderHandle);
297
298 GLint status = 0;
299
300#ifdef GL_ARB_shader_objects
301 Driver->extGlGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status);
302#endif
303
304 if (!status)
305 {
306 os::Printer::log("GLSL shader failed to compile", ELL_ERROR);
307 // check error message and log it
308 GLint maxLength=0;
309 GLsizei length;
310#ifdef GL_ARB_shader_objects
311 Driver->extGlGetObjectParameteriv(shaderHandle,
312 GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
313#endif
314 if (maxLength)
315 {
316 GLcharARB *infoLog = new GLcharARB[maxLength];
317 Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, infoLog);
318 os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
319 delete [] infoLog;
320 }
321
322 return false;
323 }
324
325 Driver->extGlAttachObject(Program, shaderHandle);
326 }
327 return true;
328}
329
330
331bool COpenGLSLMaterialRenderer::linkProgram()
332{
333 if (Program2)
334 {
335 Driver->extGlLinkProgram(Program2);
336
337 GLint status = 0;
338
339#ifdef GL_VERSION_2_0
340 Driver->extGlGetProgramiv(Program2, GL_LINK_STATUS, &status);
341#endif
342
343 if (!status)
344 {
345 os::Printer::log("GLSL shader program failed to link", ELL_ERROR);
346 // check error message and log it
347 GLint maxLength=0;
348 GLsizei length;
349#ifdef GL_VERSION_2_0
350 Driver->extGlGetProgramiv(Program2, GL_INFO_LOG_LENGTH, &maxLength);
351#endif
352 if (maxLength)
353 {
354 GLchar *infoLog = new GLchar[maxLength];
355 Driver->extGlGetProgramInfoLog(Program2, maxLength, &length, infoLog);
356 os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
357 delete [] infoLog;
358 }
359
360 return false;
361 }
362
363 // get uniforms information
364
365 GLint num = 0;
366#ifdef GL_VERSION_2_0
367 Driver->extGlGetProgramiv(Program2, GL_ACTIVE_UNIFORMS, &num);
368#endif
369
370 if (num == 0)
371 {
372 // no uniforms
373 return true;
374 }
375
376 GLint maxlen = 0;
377#ifdef GL_VERSION_2_0
378 Driver->extGlGetProgramiv(Program2, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen);
379#endif
380
381 if (maxlen == 0)
382 {
383 os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR);
384 return false;
385 }
386
387 // seems that some implementations use an extra null terminator
388 ++maxlen;
389 c8 *buf = new c8[maxlen];
390
391 UniformInfo.clear();
392 UniformInfo.reallocate(num);
393
394 for (GLint i=0; i < num; ++i)
395 {
396 SUniformInfo ui;
397 memset(buf, 0, maxlen);
398
399 GLint size;
400 Driver->extGlGetActiveUniform(Program2, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLchar*>(buf));
401 ui.name = buf;
402
403 UniformInfo.push_back(ui);
404 }
405
406 delete [] buf;
407 }
408 else
409 {
410 Driver->extGlLinkProgramARB(Program);
411
412 GLint status = 0;
413
414#ifdef GL_ARB_shader_objects
415 Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_LINK_STATUS_ARB, &status);
416#endif
417
418 if (!status)
419 {
420 os::Printer::log("GLSL shader program failed to link", ELL_ERROR);
421 // check error message and log it
422 GLint maxLength=0;
423 GLsizei length;
424#ifdef GL_ARB_shader_objects
425 Driver->extGlGetObjectParameteriv(Program,
426 GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
427#endif
428 if (maxLength)
429 {
430 GLcharARB *infoLog = new GLcharARB[maxLength];
431 Driver->extGlGetInfoLog(Program, maxLength, &length, infoLog);
432 os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
433 delete [] infoLog;
434 }
435
436 return false;
437 }
438
439 // get uniforms information
440
441 GLint num = 0;
442 #ifdef GL_ARB_shader_objects
443 Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &num);
444 #endif
445
446 if (num == 0)
447 {
448 // no uniforms
449 return true;
450 }
451
452 GLint maxlen = 0;
453 #ifdef GL_ARB_shader_objects
454 Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen);
455 #endif
456
457 if (maxlen == 0)
458 {
459 os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR);
460 return false;
461 }
462
463 // seems that some implementations use an extra null terminator
464 ++maxlen;
465 c8 *buf = new c8[maxlen];
466
467 UniformInfo.clear();
468 UniformInfo.reallocate(num);
469
470 for (int i=0; i < num; ++i)
471 {
472 SUniformInfo ui;
473 memset(buf, 0, maxlen);
474
475 GLint size;
476 Driver->extGlGetActiveUniformARB(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLcharARB*>(buf));
477 ui.name = buf;
478
479 UniformInfo.push_back(ui);
480 }
481
482 delete [] buf;
483 }
484
485 return true;
486}
487
488
489void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material,
490 const SMaterial& lastMaterial,
491 bool resetAllRenderstates)
492{
493 // forward
494 Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
495}
496
497
498bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const f32* floats, int count)
499{
500 return setPixelShaderConstant(name, floats, count);
501}
502
503bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const bool* bools, int count)
504{
505 return setPixelShaderConstant(name, bools, count);
506}
507
508bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const s32* ints, int count)
509{
510 return setPixelShaderConstant(name, ints, count);
511}
512
513void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
514{
515 os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
516}
517
518bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count)
519{
520 u32 i;
521 const u32 num = UniformInfo.size();
522
523 for (i=0; i < num; ++i)
524 {
525 if (UniformInfo[i].name == name)
526 break;
527 }
528
529 if (i == num)
530 return false;
531
532#if defined(GL_VERSION_2_0)||defined(GL_ARB_shader_objects)
533 GLint Location=0;
534 if (Program2)
535 Location=Driver->extGlGetUniformLocation(Program2,name);
536 else
537 Location=Driver->extGlGetUniformLocationARB(Program,name);
538
539 bool status = true;
540
541 switch (UniformInfo[i].type)
542 {
543 case GL_FLOAT:
544 Driver->extGlUniform1fv(Location, count, floats);
545 break;
546 case GL_FLOAT_VEC2:
547 Driver->extGlUniform2fv(Location, count/2, floats);
548 break;
549 case GL_FLOAT_VEC3:
550 Driver->extGlUniform3fv(Location, count/3, floats);
551 break;
552 case GL_FLOAT_VEC4:
553 Driver->extGlUniform4fv(Location, count/4, floats);
554 break;
555 case GL_FLOAT_MAT2:
556 Driver->extGlUniformMatrix2fv(Location, count/4, false, floats);
557 break;
558 case GL_FLOAT_MAT3:
559 Driver->extGlUniformMatrix3fv(Location, count/9, false, floats);
560 break;
561 case GL_FLOAT_MAT4:
562 Driver->extGlUniformMatrix4fv(Location, count/16, false, floats);
563 break;
564 case GL_SAMPLER_1D:
565 case GL_SAMPLER_2D:
566 case GL_SAMPLER_3D:
567 case GL_SAMPLER_CUBE:
568 case GL_SAMPLER_1D_SHADOW:
569 case GL_SAMPLER_2D_SHADOW:
570 {
571 const GLint id = static_cast<GLint>(*floats);
572 Driver->extGlUniform1iv(Location, 1, &id);
573 }
574 break;
575 default:
576 status = false;
577 break;
578 }
579 return status;
580#else
581 return false;
582#endif
583}
584
585bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const bool* bools, int count)
586{
587 u32 i;
588 const u32 num = UniformInfo.size();
589
590 for (i=0; i < num; ++i)
591 {
592 if (UniformInfo[i].name == name)
593 break;
594 }
595
596 if (i == num)
597 return false;
598
599#if defined(GL_VERSION_2_0)||defined(GL_ARB_shader_objects)
600 GLint Location=0;
601 if (Program2)
602 Location=Driver->extGlGetUniformLocation(Program2,name);
603 else
604 Location=Driver->extGlGetUniformLocationARB(Program,name);
605
606 bool status = true;
607
608 switch (UniformInfo[i].type)
609 {
610 case GL_BOOL:
611 Driver->extGlUniform1iv(Location, count, (GLint*)bools);
612 break;
613 case GL_BOOL_VEC2:
614 Driver->extGlUniform2iv(Location, count/2, (GLint*)bools);
615 break;
616 case GL_BOOL_VEC3:
617 Driver->extGlUniform3iv(Location, count/3, (GLint*)bools);
618 break;
619 case GL_BOOL_VEC4:
620 Driver->extGlUniform4iv(Location, count/4, (GLint*)bools);
621 break;
622 default:
623 status = false;
624 break;
625 }
626 return status;
627#else
628 return false;
629#endif
630}
631
632bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const s32* ints, int count)
633{
634 u32 i;
635 const u32 num = UniformInfo.size();
636
637 for (i=0; i < num; ++i)
638 {
639 if (UniformInfo[i].name == name)
640 break;
641 }
642
643 if (i == num)
644 return false;
645
646#if defined(GL_VERSION_2_0)||defined(GL_ARB_shader_objects)
647 GLint Location=0;
648 if (Program2)
649 Location=Driver->extGlGetUniformLocation(Program2,name);
650 else
651 Location=Driver->extGlGetUniformLocationARB(Program,name);
652
653 bool status = true;
654
655 switch (UniformInfo[i].type)
656 {
657 case GL_INT:
658 Driver->extGlUniform1iv(Location, count, ints);
659 break;
660 case GL_INT_VEC2:
661 Driver->extGlUniform2iv(Location, count/2, ints);
662 break;
663 case GL_INT_VEC3:
664 Driver->extGlUniform3iv(Location, count/3, ints);
665 break;
666 case GL_INT_VEC4:
667 Driver->extGlUniform4iv(Location, count/4, ints);
668 break;
669 case GL_SAMPLER_1D:
670 case GL_SAMPLER_2D:
671 case GL_SAMPLER_3D:
672 case GL_SAMPLER_CUBE:
673 case GL_SAMPLER_1D_SHADOW:
674 case GL_SAMPLER_2D_SHADOW:
675 Driver->extGlUniform1iv(Location, 1, ints);
676 break;
677 default:
678 status = false;
679 break;
680 }
681 return status;
682#else
683 return false;
684#endif
685}
686
687void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
688{
689 os::Printer::log("Cannot set constant, use high level shader call.", ELL_WARNING);
690}
691
692IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver()
693{
694 return Driver;
695}
696
697} // end namespace video
698} // end namespace irr
699
700
701#endif
702