fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Variables / OSGShaderVariableOSG.cpp
blobbb068efb300d0c1b9d8bc685ab7c6f39bdd34550
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGShaderVariableOSG.h"
49 #include "OSGGLFuncProtos.h"
50 #include "OSGShaderProgram.h"
52 #include "OSGDrawEnv.h"
53 #include "OSGWindow.h"
54 #include "OSGNode.h"
56 #include "OSGConceptPropertyChecks.h"
58 OSG_USING_NAMESPACE
60 // Documentation for this class is emited in the
61 // OSGShaderVariableOSGBase.cpp file.
62 // To modify it, please change the .fcd file (OSGShaderVariableOSG.fcd) and
63 // regenerate the base file.
65 /***************************************************************************\
66 * Class variables *
67 \***************************************************************************/
69 /***************************************************************************\
70 * Class methods *
71 \***************************************************************************/
73 void ShaderVariableOSG::initMethod(InitPhase ePhase)
75 Inherited::initMethod(ePhase);
79 /***************************************************************************\
80 * Instance methods *
81 \***************************************************************************/
83 /*-------------------------------------------------------------------------*\
84 - private -
85 \*-------------------------------------------------------------------------*/
87 /*----------------------- constructors & destructors ----------------------*/
89 ShaderVariableOSG::ShaderVariableOSG(void) :
90 Inherited()
92 setTypeId(ShaderVariable::SHVTypeOSG);
95 ShaderVariableOSG::ShaderVariableOSG(const ShaderVariableOSG &source) :
96 Inherited(source)
100 ShaderVariableOSG::~ShaderVariableOSG(void)
104 /*----------------------------- class specific ----------------------------*/
106 void ShaderVariableOSG::changed(ConstFieldMaskArg whichField,
107 UInt32 origin,
108 BitVector details)
110 Inherited::changed(whichField, origin, details);
112 if(0x0000 != (whichField & NameFieldMask))
114 if(_sfName.getValue() == "OSGWorldMatrix")
116 setOsgVarType(OSGWorldMatrix);
117 setDependency(SHDObject );
119 else if(_sfName.getValue() == "OSGInvWorldMatrix")
121 setOsgVarType(OSGInvWorldMatrix);
122 setDependency(SHDObject );
124 else if(_sfName.getValue() == "OSGTransInvWorldMatrix")
126 setOsgVarType(OSGTransInvWorldMatrix);
127 setDependency(SHDObject );
129 else if(_sfName.getValue() == "OSGCameraOrientation")
131 setOsgVarType(OSGCameraOrientation);
132 setDependency(SHDScene );
134 else if(_sfName.getValue() == "OSGCameraPosition")
136 setOsgVarType(OSGCameraPosition);
137 setDependency(SHDScene );
139 else if(_sfName.getValue() == "OSGViewMatrix")
141 setOsgVarType(OSGViewMatrix);
142 setDependency(SHDScene );
144 else if(_sfName.getValue() == "OSGInvViewMatrix")
146 setOsgVarType(OSGInvViewMatrix);
147 setDependency(SHDScene );
149 else if(_sfName.getValue() == "OSGProjectionMatrix")
151 setOsgVarType(OSGProjectionMatrix);
152 setDependency(SHDScene );
154 else if(_sfName.getValue() == "OSGModelViewMatrix")
156 setOsgVarType(OSGModelViewMatrix);
157 setDependency(SHDObject );
159 else if(_sfName.getValue() == "OSGViewportSize")
161 setOsgVarType(OSGViewportSize);
162 setDependency(SHDScene );
164 #ifdef OSG_OGL_COREONLY
165 else if(_sfName.getValue() == "OSGNormalMatrix")
167 setOsgVarType(OSGNormalMatrix);
168 setDependency(SHDObject );
170 else if(_sfName.getValue() == "OSGModelViewProjectionMatrix")
172 setOsgVarType(OSGModelViewProjectionMatrix);
173 setDependency(SHDObject );
175 #endif
176 else if(_sfName.getValue() == "OSGStereoLeftEye")
178 setOsgVarType(OSGStereoLeftEye);
179 setDependency(SHDScene );
181 else if(_sfName.getValue() == "OSGDrawerId")
183 setOsgVarType(OSGDrawerId);
184 setDependency(SHDScene );
186 else if(_sfName.getValue() == "OSGDrawableId")
188 setOsgVarType(OSGDrawableId);
189 setDependency(SHDScene );
191 else if(_sfName.getValue() == "OSGNodeId")
193 setOsgVarType(OSGNodeId);
194 setDependency(SHDObject);
196 else if(_sfName.getValue() == "OSGNodeBoxMin")
198 setOsgVarType(OSGNodeBoxMin);
199 setDependency(SHDObject );
201 else if(_sfName.getValue() == "OSGNodeBoxMax")
203 setOsgVarType(OSGNodeBoxMax);
204 setDependency(SHDObject );
206 else if(_sfName.getValue() == "OSGNodeBoxCenter")
208 setOsgVarType(OSGNodeBoxCenter);
209 setDependency(SHDObject );
211 else if(_sfName.getValue() == "OSGNodeWorldBoxMin")
213 setOsgVarType(OSGNodeWorldBoxMin);
214 setDependency(SHDObject );
216 else if(_sfName.getValue() == "OSGNodeWorldBoxMax")
218 setOsgVarType(OSGNodeWorldBoxMax);
219 setDependency(SHDObject );
221 else if(_sfName.getValue() == "OSGNodeWorldBoxCenter")
223 setOsgVarType(OSGNodeWorldBoxCenter);
224 setDependency(SHDObject );
226 else if(_sfName.getValue() == "OSGActiveLightsMask")
228 setOsgVarType(OSGActiveLightsMask);
229 setDependency(SHDObject );
231 else if(_sfName.getValue() == "OSGLight0Active")
233 setOsgVarType(OSGLight0Active);
234 setDependency(SHDObject );
236 else if(_sfName.getValue() == "OSGLight1Active")
238 setOsgVarType(OSGLight1Active);
239 setDependency(SHDObject );
241 else if(_sfName.getValue() == "OSGLight2Active")
243 setOsgVarType(OSGLight2Active);
244 setDependency(SHDObject );
246 else if(_sfName.getValue() == "OSGLight3Active")
248 setOsgVarType(OSGLight3Active);
249 setDependency(SHDObject );
251 else if(_sfName.getValue() == "OSGLight4Active")
253 setOsgVarType(OSGLight4Active);
254 setDependency(SHDObject );
256 else if(_sfName.getValue() == "OSGLight5Active")
258 setOsgVarType(OSGLight5Active);
259 setDependency(SHDObject );
261 else if(_sfName.getValue() == "OSGLight6Active")
263 setOsgVarType(OSGLight6Active);
264 setDependency(SHDObject );
266 else if(_sfName.getValue() == "OSGLight7Active")
268 setOsgVarType(OSGLight7Active);
269 setDependency(SHDObject );
271 else
273 setOsgVarType(OSGUnknown);
274 setDependency(SHDObject );
279 void ShaderVariableOSG::dump( UInt32 ,
280 const BitVector ) const
282 SLOG << "Dump ShaderVariableOSG NI" << std::endl;
285 bool ShaderVariableOSG::isProcedural(void) const
287 return true;
290 void ShaderVariableOSG::setName(const std::string &value)
292 Inherited::setName(value);
294 if(_sfName.getValue() == "OSGWorldMatrix")
296 setOsgVarType(OSGWorldMatrix);
297 setDependency(SHDObject );
299 else if(_sfName.getValue() == "OSGInvWorldMatrix")
301 setOsgVarType(OSGInvWorldMatrix);
302 setDependency(SHDObject );
304 else if(_sfName.getValue() == "OSGTransInvWorldMatrix")
306 setOsgVarType(OSGTransInvWorldMatrix);
307 setDependency(SHDObject );
309 else if(_sfName.getValue() == "OSGCameraOrientation")
311 setOsgVarType(OSGCameraOrientation);
312 setDependency(SHDScene );
314 else if(_sfName.getValue() == "OSGCameraPosition")
316 setOsgVarType(OSGCameraPosition);
317 setDependency(SHDScene );
319 else if(_sfName.getValue() == "OSGViewMatrix")
321 setOsgVarType(OSGViewMatrix);
322 setDependency(SHDScene );
324 else if(_sfName.getValue() == "OSGInvViewMatrix")
326 setOsgVarType(OSGInvViewMatrix);
327 setDependency(SHDScene );
329 else if(_sfName.getValue() == "OSGProjectionMatrix")
331 setOsgVarType(OSGProjectionMatrix);
332 setDependency(SHDScene );
334 else if(_sfName.getValue() == "OSGModelViewMatrix")
336 setOsgVarType(OSGModelViewMatrix);
337 setDependency(SHDObject );
339 else if(_sfName.getValue() == "OSGViewportSize")
341 setOsgVarType(OSGViewportSize);
342 setDependency(SHDScene );
344 #ifdef OSG_OGL_COREONLY
345 else if(_sfName.getValue() == "OSGNormalMatrix")
347 setOsgVarType(OSGNormalMatrix);
348 setDependency(SHDObject );
350 else if(_sfName.getValue() == "OSGModelViewProjectionMatrix")
352 setOsgVarType(OSGModelViewProjectionMatrix);
353 setDependency(SHDObject );
355 #endif
356 else if(_sfName.getValue() == "OSGStereoLeftEye")
358 setOsgVarType(OSGStereoLeftEye);
359 setDependency(SHDScene );
361 else if(_sfName.getValue() == "OSGDrawerId")
363 setOsgVarType(OSGDrawerId);
364 setDependency(SHDScene );
366 else if(_sfName.getValue() == "OSGDrawableId")
368 setOsgVarType(OSGDrawableId);
369 setDependency(SHDScene );
371 else if(_sfName.getValue() == "OSGNodeId")
373 setOsgVarType(OSGNodeId);
374 setDependency(SHDObject);
376 else if(_sfName.getValue() == "OSGNodeBoxMin")
378 setOsgVarType(OSGNodeBoxMin);
379 setDependency(SHDObject );
381 else if(_sfName.getValue() == "OSGNodeBoxMax")
383 setOsgVarType(OSGNodeBoxMax);
384 setDependency(SHDObject );
386 else if(_sfName.getValue() == "OSGNodeBoxCenter")
388 setOsgVarType(OSGNodeBoxCenter);
389 setDependency(SHDObject );
391 else if(_sfName.getValue() == "OSGNodeWorldBoxMin")
393 setOsgVarType(OSGNodeWorldBoxMin);
394 setDependency(SHDObject );
396 else if(_sfName.getValue() == "OSGNodeWorldBoxMax")
398 setOsgVarType(OSGNodeWorldBoxMax);
399 setDependency(SHDObject );
401 else if(_sfName.getValue() == "OSGNodeWorldBoxCenter")
403 setOsgVarType(OSGNodeWorldBoxCenter);
404 setDependency(SHDObject );
406 else if(_sfName.getValue() == "OSGActiveLightsMask")
408 setOsgVarType(OSGActiveLightsMask);
409 setDependency(SHDObject );
411 else if(_sfName.getValue() == "OSGLight0Active")
413 setOsgVarType(OSGLight0Active);
414 setDependency(SHDObject );
416 else if(_sfName.getValue() == "OSGLight1Active")
418 setOsgVarType(OSGLight1Active);
419 setDependency(SHDObject );
421 else if(_sfName.getValue() == "OSGLight2Active")
423 setOsgVarType(OSGLight2Active);
424 setDependency(SHDObject );
426 else if(_sfName.getValue() == "OSGLight3Active")
428 setOsgVarType(OSGLight3Active);
429 setDependency(SHDObject );
431 else if(_sfName.getValue() == "OSGLight4Active")
433 setOsgVarType(OSGLight4Active);
434 setDependency(SHDObject );
436 else if(_sfName.getValue() == "OSGLight5Active")
438 setOsgVarType(OSGLight5Active);
439 setDependency(SHDObject );
441 else if(_sfName.getValue() == "OSGLight6Active")
443 setOsgVarType(OSGLight6Active);
444 setDependency(SHDObject );
446 else if(_sfName.getValue() == "OSGLight7Active")
448 setOsgVarType(OSGLight7Active);
449 setDependency(SHDObject );
451 else
453 setOsgVarType(OSGUnknown);
454 setDependency(SHDObject );
458 void ShaderVariableOSG::evaluate(DrawEnv *pEnv,
459 Int32 &iLocation)
461 Window *pWin = pEnv->getWindow();
463 osgSinkUnusedWarning(pWin);
465 switch(_sfOsgVarType.getValue())
467 case OSGWorldMatrix:
469 Matrix m = pEnv->getObjectToWorld();
471 if(iLocation > -1)
473 OSGGETGLFUNCBYID_GL3_ES(
474 glUniformMatrix4fv,
475 osgGlUniformMatrix4fv,
476 ShaderProgram::getFuncIdUniformMatrix4fv(),
477 pWin);
479 osgGlUniformMatrix4fv(iLocation,
481 GL_FALSE,
482 m.getValues());
485 break;
487 case OSGInvWorldMatrix:
489 Matrix m = pEnv->getObjectToWorld();
491 m.invert();
493 if(iLocation > -1)
495 OSGGETGLFUNCBYID_GL3_ES(
496 glUniformMatrix4fv,
497 osgGlUniformMatrix4fv,
498 ShaderProgram::getFuncIdUniformMatrix4fv(),
499 pWin);
501 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
504 break;
506 case OSGTransInvWorldMatrix:
508 Matrix m = pEnv->getObjectToWorld();
510 m.invert();
511 m.transpose();
514 if(iLocation > -1)
516 OSGGETGLFUNCBYID_GL3_ES(
517 glUniformMatrix4fv,
518 osgGlUniformMatrix4fv,
519 ShaderProgram::getFuncIdUniformMatrix4fv(),
520 pWin);
522 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
525 break;
527 case OSGCameraOrientation:
529 Matrix m = pEnv->getCameraToWorld();
531 m[3].setValues(0, 0, 0, 1);
533 if(iLocation > -1)
535 OSGGETGLFUNCBYID_GL3_ES(
536 glUniformMatrix4fv,
537 osgGlUniformMatrix4fv,
538 ShaderProgram::getFuncIdUniformMatrix4fv(),
539 pWin);
541 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
544 break;
546 case OSGCameraPosition:
548 if(iLocation > -1)
550 Matrix m = pEnv->getCameraToWorld();
552 Vec3f cameraPos(m[3][0], m[3][1], m[3][2]);
554 OSGGETGLFUNCBYID_GL3_ES(
555 glUniform3fv,
556 osgGlUniform3fv,
557 ShaderProgram::getFuncIdUniform3fv(),
558 pWin);
560 osgGlUniform3fv(iLocation, 1, cameraPos.getValues());
563 break;
565 case OSGViewMatrix:
567 Matrix m = pEnv->getCameraViewing();
569 if(iLocation > -1)
571 OSGGETGLFUNCBYID_GL3_ES(
572 glUniformMatrix4fv,
573 osgGlUniformMatrix4fv,
574 ShaderProgram::getFuncIdUniformMatrix4fv(),
575 pWin);
577 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
580 break;
582 case OSGInvViewMatrix:
584 Matrix m = pEnv->getCameraToWorld();
586 if(iLocation > -1)
588 OSGGETGLFUNCBYID_GL3_ES(
589 glUniformMatrix4fv,
590 osgGlUniformMatrix4fv,
591 ShaderProgram::getFuncIdUniformMatrix4fv(),
592 pWin);
594 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
597 break;
599 case OSGProjectionMatrix:
601 Matrix m = pEnv->_openGLState.getProjection();
603 if(iLocation > -1)
605 OSGGETGLFUNCBYID_GL3_ES(
606 glUniformMatrix4fv,
607 osgGlUniformMatrix4fv,
608 ShaderProgram::getFuncIdUniformMatrix4fv(),
609 pWin);
611 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
614 break;
616 case OSGModelViewMatrix:
618 Matrix m = pEnv->_openGLState.getModelView();
620 if(iLocation > -1)
622 OSGGETGLFUNCBYID_GL3_ES(
623 glUniformMatrix4fv,
624 osgGlUniformMatrix4fv,
625 ShaderProgram::getFuncIdUniformMatrix4fv(),
626 pWin);
628 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
631 break;
633 case OSGViewportSize:
635 Vec2f viewportSize(pEnv->getPixelWidth (),
636 pEnv->getPixelHeight());
638 OSGGETGLFUNCBYID_GL3_ES(
639 glUniform2fv,
640 osgGlUniform2fv,
641 ShaderProgram::getFuncIdUniform2fv(),
642 pWin);
644 osgGlUniform2fv(iLocation, 1, viewportSize.getValues());
646 break;
648 #ifdef OSG_OGL_COREONLY
649 case OSGNormalMatrix:
651 Matrix m = pEnv->_openGLState.getNormalMatrix();
653 if(iLocation > -1)
655 OSGGETGLFUNCBYID_GL3_ES(
656 glUniformMatrix4fv,
657 osgGlUniformMatrix4fv,
658 ShaderProgram::getFuncIdUniformMatrix4fv(),
659 pWin);
661 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
664 break;
666 case OSGModelViewProjectionMatrix:
668 Matrix m = pEnv->_openGLState.getModelViewProjection();
670 if(iLocation > -1)
672 OSGGETGLFUNCBYID_GL3_ES(
673 glUniformMatrix4fv,
674 osgGlUniformMatrix4fv,
675 ShaderProgram::getFuncIdUniformMatrix4fv(),
676 pWin);
678 osgGlUniformMatrix4fv(iLocation, 1, GL_FALSE, m.getValues());
681 break;
682 #endif
684 case OSGStereoLeftEye:
687 break;
689 case OSGDrawerId:
691 if(iLocation > -1)
693 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
694 osgGlUniform1i,
695 ShaderProgram::getFuncIdUniform1i(),
696 pWin);
698 osgGlUniform1i(iLocation,
699 GLint(pEnv->getDrawerId()));
702 break;
704 case OSGDrawableId:
706 if(iLocation > -1)
708 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
709 osgGlUniform1i,
710 ShaderProgram::getFuncIdUniform1i(),
711 pWin);
713 osgGlUniform1i(iLocation,
714 GLint(pEnv->getDrawableId()));
717 break;
719 case OSGNodeId:
721 if(iLocation > -1)
723 if(pEnv->getSGNode() != NULL)
725 OSGGETGLFUNCBYID_GL3_ES(
726 glUniform1i,
727 osgGlUniform1i,
728 ShaderProgram::getFuncIdUniform1i(),
729 pWin);
731 osgGlUniform1i(iLocation,
732 GLint(pEnv->getSGNode()->getId()));
736 break;
738 case OSGNodeBoxMin:
740 if(iLocation > -1)
742 if(pEnv->getSGNode() != NULL)
744 OSGGETGLFUNCBYID_GL3_ES(
745 glUniform3f,
746 osgGlUniform3f,
747 ShaderProgram::getFuncIdUniform3f(),
748 pWin);
750 const BoxVolume &bvBox = pEnv->getSGNode()->getVolume();
752 osgGlUniform3f(iLocation,
753 bvBox.getMin()[0],
754 bvBox.getMin()[1],
755 bvBox.getMin()[2]);
759 break;
761 case OSGNodeBoxMax :
763 if(iLocation > -1)
765 if(pEnv->getSGNode() != NULL)
767 OSGGETGLFUNCBYID_GL3_ES(
768 glUniform3f,
769 osgGlUniform3f,
770 ShaderProgram::getFuncIdUniform3f(),
771 pWin);
773 const BoxVolume &bvBox = pEnv->getSGNode()->getVolume();
775 osgGlUniform3f(iLocation,
776 bvBox.getMax()[0],
777 bvBox.getMax()[1],
778 bvBox.getMax()[2]);
782 break;
784 case OSGNodeBoxCenter:
786 if(iLocation > -1)
788 if(pEnv->getSGNode() != NULL)
790 OSGGETGLFUNCBYID_GL3_ES(
791 glUniform3f,
792 osgGlUniform3f,
793 ShaderProgram::getFuncIdUniform3f(),
794 pWin);
796 Pnt3f vBoxCenter;
798 pEnv->getSGNode()->getVolume().getCenter(vBoxCenter);
800 osgGlUniform3f(iLocation,
801 vBoxCenter[0],
802 vBoxCenter[1],
803 vBoxCenter[2]);
807 break;
810 case OSGNodeWorldBoxMin:
812 if(iLocation > -1)
814 if(pEnv->getSGNode() != NULL)
816 OSGGETGLFUNCBYID_GL3_ES(
817 glUniform3f,
818 osgGlUniform3f,
819 ShaderProgram::getFuncIdUniform3f(),
820 pWin);
822 BoxVolume bvWorldBox;
824 pEnv->getSGNode()->getWorldVolume(bvWorldBox);
826 osgGlUniform3f(iLocation,
827 bvWorldBox.getMin()[0],
828 bvWorldBox.getMin()[1],
829 bvWorldBox.getMin()[2]);
833 break;
835 case OSGNodeWorldBoxMax :
837 if(iLocation > -1)
839 if(pEnv->getSGNode() != NULL)
841 OSGGETGLFUNCBYID_GL3_ES(
842 glUniform3f,
843 osgGlUniform3f,
844 ShaderProgram::getFuncIdUniform3f(),
845 pWin);
847 BoxVolume bvWorldBox;
849 pEnv->getSGNode()->getWorldVolume(bvWorldBox);
851 osgGlUniform3f(iLocation,
852 bvWorldBox.getMax()[0],
853 bvWorldBox.getMax()[1],
854 bvWorldBox.getMax()[2]);
858 break;
860 case OSGNodeWorldBoxCenter:
862 if(iLocation > -1)
864 if(pEnv->getSGNode() != NULL)
866 OSGGETGLFUNCBYID_GL3_ES(
867 glUniform3f,
868 osgGlUniform3f,
869 ShaderProgram::getFuncIdUniform3f(),
870 pWin);
872 BoxVolume bvWorldBox;
873 Pnt3f vWorldBoxCenter;
875 pEnv->getSGNode()->getWorldVolume(bvWorldBox);
877 bvWorldBox.getCenter(vWorldBoxCenter);
879 osgGlUniform3f(iLocation,
880 vWorldBoxCenter[0],
881 vWorldBoxCenter[1],
882 vWorldBoxCenter[2]);
886 break;
888 case OSGActiveLightsMask:
890 if(iLocation > -1)
892 OSGGETGLFUNCBYID_GL3_ES(
893 glUniform1i,
894 osgGlUniform1i,
895 ShaderProgram::getFuncIdUniform1i(),
896 pWin);
898 osgGlUniform1i(iLocation,
899 GLint(pEnv->getLightState()));
902 break;
904 case OSGLight0Active:
906 if(iLocation > -1)
908 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
909 osgGlUniform1i,
910 ShaderProgram::getFuncIdUniform1i(),
911 pWin);
913 osgGlUniform1i(iLocation,
914 GLint(pEnv->getLightState() & 0x0001));
917 break;
919 case OSGLight1Active:
921 if(iLocation > -1)
923 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
924 osgGlUniform1i,
925 ShaderProgram::getFuncIdUniform1i(),
926 pWin);
928 osgGlUniform1i(iLocation,
929 GLint(pEnv->getLightState() & 0x0002));
932 break;
934 case OSGLight2Active:
936 if(iLocation > -1)
938 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
939 osgGlUniform1i,
940 ShaderProgram::getFuncIdUniform1i(),
941 pWin);
943 osgGlUniform1i(iLocation,
944 GLint(pEnv->getLightState() & 0x0004));
947 break;
949 case OSGLight3Active:
951 if(iLocation > -1)
953 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
954 osgGlUniform1i,
955 ShaderProgram::getFuncIdUniform1i(),
956 pWin);
958 osgGlUniform1i(iLocation,
959 GLint(pEnv->getLightState() & 0x0008));
962 break;
964 case OSGLight4Active:
966 if(iLocation > -1)
968 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
969 osgGlUniform1i,
970 ShaderProgram::getFuncIdUniform1i(),
971 pWin);
973 osgGlUniform1i(iLocation,
974 GLint(pEnv->getLightState() & 0x0010));
977 break;
979 case OSGLight5Active:
981 if(iLocation > -1)
983 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
984 osgGlUniform1i,
985 ShaderProgram::getFuncIdUniform1i(),
986 pWin);
988 osgGlUniform1i(iLocation,
989 GLint(pEnv->getLightState() & 0x0020));
992 break;
994 case OSGLight6Active:
996 if(iLocation > -1)
998 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
999 osgGlUniform1i,
1000 ShaderProgram::getFuncIdUniform1i(),
1001 pWin);
1003 osgGlUniform1i(iLocation,
1004 GLint(pEnv->getLightState() & 0x0040));
1007 break;
1009 case OSGLight7Active:
1011 if(iLocation > -1)
1013 OSGGETGLFUNCBYID_GL3_ES(glUniform1i,
1014 osgGlUniform1i,
1015 ShaderProgram::getFuncIdUniform1i(),
1016 pWin);
1018 osgGlUniform1i(iLocation,
1019 GLint(pEnv->getLightState() & 0x0080));
1022 break;
1024 default:
1027 break;