00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 /* include files */ 00025 #ifndef _SO_SHADER_PARAMETER_H_ 00026 #define _SO_SHADER_PARAMETER_H_ 00027 00028 #include <Inventor/SbBasic.h> 00029 #include <Inventor/nodes/SoNode.h> 00030 #include <Inventor/nodes/SoNode.h> 00031 #include <Inventor/fields/SoSFBufferObject.h> 00032 #include <Inventor/fields/SoSFString.h> 00033 #include <Inventor/fields/SoSFFloat.h> 00034 #include <Inventor/fields/SoSFInt32.h> 00035 #include <Inventor/fields/SoSFVec2f.h> 00036 #include <Inventor/fields/SoSFVec2i32.h> 00037 #include <Inventor/fields/SoSFVec3f.h> 00038 #include <Inventor/fields/SoSFVec3i32.h> 00039 #include <Inventor/fields/SoSFVec4f.h> 00040 #include <Inventor/fields/SoSFVec4i32.h> 00041 #include <Inventor/fields/SoSFBool.h> 00042 #include <Inventor/fields/SoMFFloat.h> 00043 #include <Inventor/fields/SoMFInt32.h> 00044 #include <Inventor/fields/SoMFShort.h> 00045 #include <Inventor/fields/SoMFVec2f.h> 00046 #include <Inventor/fields/SoMFVec2s.h> 00047 #include <Inventor/fields/SoMFVec2i32.h> 00048 #include <Inventor/fields/SoMFVec3f.h> 00049 #include <Inventor/fields/SoMFVec3s.h> 00050 #include <Inventor/fields/SoMFVec3i32.h> 00051 #include <Inventor/fields/SoMFVec4f.h> 00052 #include <Inventor/fields/SoMFVec4i32.h> 00053 #include <Inventor/fields/SoMFVec4s.h> 00054 #include <Inventor/fields/SoMFVec4b.h> 00055 #include <Inventor/fields/SoMFVec4ui32.h> 00056 #include <Inventor/fields/SoMFVec4us.h> 00057 #include <Inventor/fields/SoMFVec4ub.h> 00058 #include <Inventor/fields/SoSFMatrix.h> 00059 #include <Inventor/fields/SoSFMatrix3.h> 00060 #include <Inventor/fields/SoMFMatrix.h> 00061 #include <Inventor/fields/SoSFNode.h> 00062 #include <Inventor/fields/SoMFNode.h> 00063 #include <Inventor/fields/SoSFEnum.h> 00064 #include <Inventor/SbEventHandler.h> 00065 #include <Inventor/renderer/RendererResourceMacro.h> 00066 00067 typedef unsigned int GLenum; 00068 00069 class SoGLShaderObject ; 00070 class SoShaderObject ; 00071 class SoShaderProgram ; 00072 00073 /*----------------------------------------------------------------------------*/ 00074 00136 class SoShaderParameter : public SoNode { 00137 00138 SO_NODE_ABSTRACT_HEADER(SoShaderParameter); 00139 00140 public: 00145 SoSFString name; 00146 00151 SoSFInt32 identifier; 00152 00153 00154 private: 00155 static void initClass() ; 00156 static void exitClass() ; 00157 00158 SbBool isInternal() const; 00159 00160 private: 00164 SoShaderParameter(); 00165 00166 // Destructor 00167 virtual ~SoShaderParameter(); 00168 00169 }; 00170 00312 class SoUniformShaderParameter : public SoShaderParameter { 00313 00314 SO_NODE_ABSTRACT_HEADER(SoUniformShaderParameter); 00315 RENDERER_RESOURCE(SoUniformShaderParameter); 00316 00317 public: 00318 00319 virtual bool isEqual(const SoUniformShaderParameter* param) const = 0; 00320 00321 private: 00322 static void initClass() ; 00323 static void exitClass() ; 00324 00326 virtual void notify(SoNotList *list); 00327 00328 private: 00329 void GLRender(SoGLRenderAction *action); 00330 00331 private: 00335 SoUniformShaderParameter(); 00336 00337 // Destructor 00338 virtual ~SoUniformShaderParameter(); 00339 00340 private: 00341 00342 #if 1 SoDEPRECATED enum 00347 ShaderType { 00352 VERTEX, 00357 FRAGMENT 00358 }; 00359 00368 SoSFEnum SoDEPRECATED shaderType; 00369 #endif 00371 }; 00372 /*----------------------------------------------------------------------------*/ 00373 00413 class SoShaderParameter1f : public SoUniformShaderParameter { 00414 00415 SO_NODE_HEADER(SoShaderParameter1f); 00416 00417 public: 00418 00423 SoSFFloat value; 00424 00428 SoShaderParameter1f(); 00429 00433 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00434 00435 private: 00436 00437 static void initClass() ; 00438 static void exitClass() ; 00439 00440 private: 00441 // Destructor 00442 virtual ~SoShaderParameter1f(); 00443 }; 00444 /*----------------------------------------------------------------------------*/ 00445 00485 class SoShaderParameter1i : public SoUniformShaderParameter { 00486 00487 SO_NODE_HEADER(SoShaderParameter1i); 00488 00489 public: 00493 SoSFInt32 value; 00494 00498 SoShaderParameter1i(); 00499 00500 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00501 00502 private: 00503 static void initClass() ; 00504 static void exitClass() ; 00505 00506 private: 00507 // Destructor 00508 virtual ~SoShaderParameter1i(); 00509 }; 00510 /*----------------------------------------------------------------------------*/ 00511 00551 class SoShaderParameter2f : public SoUniformShaderParameter { 00552 00553 SO_NODE_HEADER(SoShaderParameter2f); 00554 00555 public: 00559 SoSFVec2f value; 00560 00564 SoShaderParameter2f(); 00565 00566 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00567 00568 private: 00569 static void initClass() ; 00570 static void exitClass() ; 00571 00572 private: 00573 // Destructor 00574 virtual ~SoShaderParameter2f(); 00575 }; 00576 /*----------------------------------------------------------------------------*/ 00577 00617 class SoShaderParameter2i : public SoUniformShaderParameter { 00618 00619 SO_NODE_HEADER(SoShaderParameter2i); 00620 00621 public: 00625 SoSFVec2i32 value; 00626 00630 SoShaderParameter2i(); 00631 00632 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00633 00634 private: 00635 static void initClass() ; 00636 static void exitClass() ; 00637 00638 private: 00639 // Destructor 00640 virtual ~SoShaderParameter2i(); 00641 }; 00642 /*----------------------------------------------------------------------------*/ 00643 00683 class SoShaderParameter3f : public SoUniformShaderParameter { 00684 00685 SO_NODE_HEADER(SoShaderParameter3f); 00686 00687 public: 00691 SoSFVec3f value; 00692 00696 SoShaderParameter3f(); 00697 00698 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00699 00700 private: 00701 static void initClass() ; 00702 static void exitClass() ; 00703 00704 private: 00705 // Destructor 00706 virtual ~SoShaderParameter3f(); 00707 }; 00708 /*----------------------------------------------------------------------------*/ 00709 00749 class SoShaderParameter3i : public SoUniformShaderParameter { 00750 00751 SO_NODE_HEADER(SoShaderParameter3i); 00752 00753 public: 00757 SoSFVec3i32 value; 00758 00762 SoShaderParameter3i(); 00763 00764 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00765 00766 private: 00767 static void initClass() ; 00768 static void exitClass() ; 00769 00770 private: 00771 // Destructor 00772 virtual ~SoShaderParameter3i(); 00773 00774 }; 00775 /*----------------------------------------------------------------------------*/ 00776 00816 class SoShaderParameter4f : public SoUniformShaderParameter { 00817 00818 SO_NODE_HEADER(SoShaderParameter4f); 00819 00820 public: 00824 SoSFVec4f value; 00825 00829 SoShaderParameter4f(); 00830 00831 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00832 00833 private: 00834 static void initClass() ; 00835 static void exitClass() ; 00836 00837 private: 00838 // Destructor 00839 virtual ~SoShaderParameter4f(); 00840 }; 00841 /*----------------------------------------------------------------------------*/ 00842 00882 class SoShaderParameter4i : public SoUniformShaderParameter { 00883 00884 SO_NODE_HEADER(SoShaderParameter4i); 00885 00886 public: 00890 SoSFVec4i32 value; 00891 00895 SoShaderParameter4i(); 00896 00897 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00898 00899 private: 00900 static void initClass() ; 00901 static void exitClass() ; 00902 00903 private: 00904 // Destructor 00905 virtual ~SoShaderParameter4i(); 00906 }; 00907 /*----------------------------------------------------------------------------*/ 00908 00950 class SoShaderParameterArray1f : public SoUniformShaderParameter { 00951 00952 SO_NODE_HEADER(SoShaderParameterArray1f); 00953 00954 public: 00958 SoMFFloat value; 00959 00963 SoShaderParameterArray1f(); 00964 00965 virtual bool isEqual(const SoUniformShaderParameter* param) const; 00966 00967 private: 00968 static void initClass() ; 00969 static void exitClass() ; 00970 00971 private: 00972 // Destructor 00973 virtual ~SoShaderParameterArray1f(); 00974 }; 00975 /*----------------------------------------------------------------------------*/ 00976 01018 class SoShaderParameterArray1i : public SoUniformShaderParameter { 01019 01020 SO_NODE_HEADER(SoShaderParameterArray1i); 01021 01022 public: 01026 SoMFInt32 value; 01027 01031 SoShaderParameterArray1i(); 01032 01033 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01034 01035 private: 01036 static void initClass() ; 01037 static void exitClass() ; 01038 01039 private: 01040 // Destructor 01041 virtual ~SoShaderParameterArray1i(); 01042 }; 01043 /*----------------------------------------------------------------------------*/ 01044 01086 class SoShaderParameterArray2f : public SoUniformShaderParameter { 01087 01088 SO_NODE_HEADER(SoShaderParameterArray2f); 01089 01090 public: 01094 SoMFVec2f value; 01095 01099 SoShaderParameterArray2f(); 01100 01101 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01102 01103 private: 01104 static void initClass() ; 01105 static void exitClass() ; 01106 01107 private: 01108 // Destructor 01109 virtual ~SoShaderParameterArray2f(); 01110 }; 01111 /*----------------------------------------------------------------------------*/ 01112 01154 class SoShaderParameterArray2i : public SoUniformShaderParameter { 01155 01156 SO_NODE_HEADER(SoShaderParameterArray2i); 01157 01158 public: 01162 SoMFVec2i32 value; 01163 01167 SoShaderParameterArray2i(); 01168 01169 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01170 01171 private: 01172 static void initClass() ; 01173 static void exitClass() ; 01174 01175 private: 01176 // Destructor 01177 virtual ~SoShaderParameterArray2i(); 01178 }; 01179 /*----------------------------------------------------------------------------*/ 01180 01222 class SoShaderParameterArray3f : public SoUniformShaderParameter { 01223 01224 SO_NODE_HEADER(SoShaderParameterArray3f); 01225 01226 public: 01230 SoMFVec3f value; 01231 01235 SoShaderParameterArray3f(); 01236 01237 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01238 01239 private: 01240 static void initClass() ; 01241 static void exitClass() ; 01242 01243 private: 01244 // Destructor 01245 virtual ~SoShaderParameterArray3f(); 01246 }; 01247 /*----------------------------------------------------------------------------*/ 01248 01291 class SoShaderParameterArray3i : public SoUniformShaderParameter { 01292 01293 SO_NODE_HEADER(SoShaderParameterArray3i); 01294 01295 public: 01299 SoMFVec3i32 value; 01300 01304 SoShaderParameterArray3i(); 01305 01306 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01307 01308 private: 01309 static void initClass() ; 01310 static void exitClass() ; 01311 01312 private: 01313 // Destructor 01314 virtual ~SoShaderParameterArray3i(); 01315 }; 01316 /*----------------------------------------------------------------------------*/ 01317 01360 class SoShaderParameterArray4f : public SoUniformShaderParameter { 01361 01362 SO_NODE_HEADER(SoShaderParameterArray4f); 01363 01364 public: 01368 SoMFVec4f value; 01369 01373 SoShaderParameterArray4f(); 01374 01375 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01376 01377 private: 01378 static void initClass() ; 01379 static void exitClass() ; 01380 01381 private: 01382 // Destructor 01383 virtual ~SoShaderParameterArray4f(); 01384 01385 }; 01386 /*----------------------------------------------------------------------------*/ 01387 01431 class SoShaderParameterArray4i : public SoUniformShaderParameter { 01432 01433 SO_NODE_HEADER(SoShaderParameterArray4i); 01434 01435 public: 01439 SoMFVec4i32 value; 01440 01444 SoShaderParameterArray4i(); 01445 01446 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01447 01448 private: 01449 static void initClass() ; 01450 static void exitClass() ; 01451 01452 private: 01453 // Destructor 01454 virtual ~SoShaderParameterArray4i(); 01455 }; 01456 /*----------------------------------------------------------------------------*/ 01457 01505 class SoShaderParameterMatrix : public SoUniformShaderParameter { 01506 01507 SO_NODE_HEADER(SoShaderParameterMatrix); 01508 01509 public: 01513 SoSFMatrix value; 01514 01518 SoShaderParameterMatrix(); 01519 01520 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01521 01522 private: 01523 static void initClass() ; 01524 static void exitClass() ; 01525 01526 private: 01527 // Destructor 01528 virtual ~SoShaderParameterMatrix(); 01529 01530 }; 01531 /*----------------------------------------------------------------------------*/ 01532 01575 class SoShaderParameterMatrix3 : public SoUniformShaderParameter { 01576 01577 SO_NODE_HEADER(SoShaderParameterMatrix3); 01578 01579 public: 01583 SoSFMatrix3 value; 01584 01588 SoShaderParameterMatrix3(); 01589 01590 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01591 01592 private: 01593 static void initClass() ; 01594 static void exitClass() ; 01595 01596 private: 01597 // Destructor 01598 virtual ~SoShaderParameterMatrix3(); 01599 01600 }; 01601 /*----------------------------------------------------------------------------*/ 01602 01603 01647 class SoShaderParameterMatrixArray : public SoUniformShaderParameter { 01648 01649 SO_NODE_HEADER(SoShaderParameterMatrixArray); 01650 01651 public: 01655 SoMFMatrix value; 01656 01660 SoShaderParameterMatrixArray(); 01661 01662 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01663 01664 private: 01665 static void initClass() ; 01666 static void exitClass() ; 01667 01668 private: 01669 // Destructor 01670 virtual ~SoShaderParameterMatrixArray(); 01671 }; 01672 /*----------------------------------------------------------------------------*/ 01673 01726 class SoShaderStateMatrixParameter : public SoUniformShaderParameter { 01727 01728 SO_NODE_HEADER(SoShaderStateMatrixParameter); 01729 01730 public: 01731 01733 enum MatrixType { 01737 MODELVIEW, 01738 01742 PROJECTION, 01743 01747 TEXTURE, 01748 01752 MODELVIEW_PROJECTION 01753 }; 01754 01756 enum MatrixTransform { 01760 IDENTITY, 01761 01765 TRANSPOSE, 01766 01770 INVERSE, 01771 01775 INVERSE_TRANSPOSE 01776 }; 01777 01781 SoSFEnum matrixType; 01782 01786 SoSFEnum matrixTransform; 01787 01791 SoShaderStateMatrixParameter(); 01792 01793 virtual bool isEqual(const SoUniformShaderParameter* param) const; 01794 01795 private: 01796 static void initClass() ; 01797 static void exitClass() ; 01798 01799 private: 01800 // Destructor 01801 virtual ~SoShaderStateMatrixParameter(); 01802 01803 }; 01804 /*----------------------------------------------------------------------------*/ 01805 01913 class SoVertexShaderParameter : public SoShaderParameter { 01914 01915 SO_NODE_ABSTRACT_HEADER(SoVertexShaderParameter); 01916 01917 private: 01918 virtual void doAction(SoAction *action); 01919 virtual void GLRender(SoGLRenderAction *action); 01920 virtual void callback(SoCallbackAction *action); 01921 virtual void getBoundingBox( SoGetBoundingBoxAction *action ); 01922 virtual void rayPick(SoRayPickAction *action ); 01923 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action ); 01924 01925 private: 01926 static void initClass(); 01927 static void exitClass(); 01928 01929 static SbBool areVertexAttribFuncAvailable(); 01930 static SbBool areVertexAttribDivisorFuncAvailable(); 01931 01932 void getVertexAttribIndex(SoState * state, int& firstInd, int& size); 01933 01934 virtual size_t getVertexAttribOffset(int) { return 0; } 01935 virtual const char * getVertexAttribPtr(int i=0) = 0; 01936 virtual size_t getVertexAttribStride() = 0; 01937 virtual int getVertexAttribNum() = 0; 01938 virtual GLenum getVertexAttribType() = 0; 01939 virtual int getVertexAttribSize() = 0; 01940 virtual SbBool getVertexAttribIsToNormalize() = 0; 01941 virtual unsigned int getVertexAttribDivisor() { return 0; } 01942 private: 01946 SoVertexShaderParameter(); 01947 01948 // Destructor 01949 virtual ~SoVertexShaderParameter(); 01950 01951 }; 01952 /*----------------------------------------------------------------------------*/ 01953 01988 class SoVertexShaderParameter1f : public SoVertexShaderParameter { 01989 01990 SO_NODE_HEADER(SoVertexShaderParameter1f); 01991 01992 public: 01996 SoVertexShaderParameter1f(); 01997 02001 SoMFFloat value; 02002 02003 private: 02004 static void initClass(); 02005 static void exitClass(); 02006 02007 virtual const char * getVertexAttribPtr( int ) { return (char *)value.getValues(0); } 02008 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02009 virtual int getVertexAttribNum() { return value.getNum(); } 02010 virtual GLenum getVertexAttribType(); 02011 virtual int getVertexAttribSize() { return 1; } 02012 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02013 02014 private: 02015 // Destructor 02016 virtual ~SoVertexShaderParameter1f(); 02017 }; 02018 02019 /*----------------------------------------------------------------------------*/ 02020 02055 class SoVertexShaderParameter1s : public SoVertexShaderParameter { 02056 02057 SO_NODE_HEADER(SoVertexShaderParameter1s); 02058 02059 public: 02063 SoVertexShaderParameter1s(); 02064 02068 SoMFShort value; 02069 02070 private: 02071 static void initClass(); 02072 static void exitClass(); 02073 02074 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02075 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02076 virtual int getVertexAttribNum() { return value.getNum(); } 02077 virtual GLenum getVertexAttribType(); 02078 virtual int getVertexAttribSize() { return 1; } 02079 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02080 02081 private: 02082 // Destructor 02083 virtual ~SoVertexShaderParameter1s(); 02084 }; 02085 02086 /*----------------------------------------------------------------------------*/ 02087 02122 class SoVertexShaderParameter2f : public SoVertexShaderParameter { 02123 02124 SO_NODE_HEADER(SoVertexShaderParameter2f); 02125 02126 public: 02130 SoVertexShaderParameter2f(); 02131 02135 SoMFVec2f value; 02136 02137 private: 02138 static void initClass(); 02139 static void exitClass(); 02140 02141 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02142 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02143 virtual int getVertexAttribNum() { return value.getNum(); } 02144 virtual GLenum getVertexAttribType(); 02145 virtual int getVertexAttribSize() { return 2; } 02146 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02147 02148 private: 02149 // Destructor 02150 virtual ~SoVertexShaderParameter2f(); 02151 }; 02152 02153 /*----------------------------------------------------------------------------*/ 02154 02189 class SoVertexShaderParameter2s : public SoVertexShaderParameter { 02190 02191 SO_NODE_HEADER(SoVertexShaderParameter2s); 02192 02193 public: 02197 SoVertexShaderParameter2s(); 02198 02202 SoMFVec2s value; 02203 02204 private: 02205 static void initClass(); 02206 static void exitClass(); 02207 02208 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02209 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02210 virtual int getVertexAttribNum() { return value.getNum(); } 02211 virtual GLenum getVertexAttribType(); 02212 virtual int getVertexAttribSize() { return 2; } 02213 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02214 02215 private: 02216 // Destructor 02217 virtual ~SoVertexShaderParameter2s(); 02218 }; 02219 02220 /*----------------------------------------------------------------------------*/ 02221 02256 class SoVertexShaderParameter3f : public SoVertexShaderParameter { 02257 02258 SO_NODE_HEADER(SoVertexShaderParameter3f); 02259 02260 public: 02264 SoVertexShaderParameter3f(); 02265 02269 SoMFVec3f value; 02270 02271 private: 02272 static void initClass(); 02273 static void exitClass(); 02274 02275 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02276 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02277 virtual int getVertexAttribNum() { return value.getNum(); } 02278 virtual GLenum getVertexAttribType(); 02279 virtual int getVertexAttribSize() { return 3; } 02280 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02281 02282 private: 02283 // Destructor 02284 virtual ~SoVertexShaderParameter3f(); 02285 }; 02286 02287 /*----------------------------------------------------------------------------*/ 02288 02323 class SoVertexShaderParameter3s : public SoVertexShaderParameter { 02324 02325 SO_NODE_HEADER(SoVertexShaderParameter3s); 02326 02327 public: 02331 SoVertexShaderParameter3s(); 02332 02336 SoMFVec3s value; 02337 02338 private: 02339 static void initClass(); 02340 static void exitClass(); 02341 02342 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02343 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02344 virtual int getVertexAttribNum() { return value.getNum(); } 02345 virtual GLenum getVertexAttribType(); 02346 virtual int getVertexAttribSize() { return 3; } 02347 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02348 02349 private: 02350 // Destructor 02351 virtual ~SoVertexShaderParameter3s(); 02352 }; 02353 02354 /*----------------------------------------------------------------------------*/ 02355 02390 class SoVertexShaderParameter4f : public SoVertexShaderParameter { 02391 02392 SO_NODE_HEADER(SoVertexShaderParameter4f); 02393 02394 public: 02398 SoVertexShaderParameter4f(); 02399 02403 SoMFVec4f value; 02404 02405 private: 02406 static void initClass(); 02407 static void exitClass(); 02408 02409 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02410 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02411 virtual int getVertexAttribNum() { return value.getNum(); } 02412 virtual GLenum getVertexAttribType(); 02413 virtual int getVertexAttribSize() { return 4; } 02414 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02415 02416 private: 02417 // Destructor 02418 virtual ~SoVertexShaderParameter4f(); 02419 }; 02420 02421 /*----------------------------------------------------------------------------*/ 02422 02464 class SoVertexShaderParameter4i : public SoVertexShaderParameter { 02465 02466 SO_NODE_HEADER(SoVertexShaderParameter4i); 02467 02468 public: 02472 SoVertexShaderParameter4i(); 02473 02477 SoMFVec4i32 value; 02478 02482 SoSFBool rangeScaling; 02483 02484 private: 02485 static void initClass(); 02486 static void exitClass(); 02487 02488 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02489 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02490 virtual int getVertexAttribNum() { return value.getNum(); } 02491 virtual GLenum getVertexAttribType(); 02492 virtual int getVertexAttribSize() { return 4; } 02493 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02494 02495 private: 02496 // Destructor 02497 virtual ~SoVertexShaderParameter4i(); 02498 }; 02499 02500 /*----------------------------------------------------------------------------*/ 02501 02543 class SoVertexShaderParameter4s : public SoVertexShaderParameter { 02544 02545 SO_NODE_HEADER(SoVertexShaderParameter4s); 02546 02547 public: 02551 SoVertexShaderParameter4s(); 02552 02556 SoMFVec4s value; 02557 02561 SoSFBool rangeScaling; 02562 02563 private: 02564 static void initClass(); 02565 static void exitClass(); 02566 02567 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02568 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02569 virtual int getVertexAttribNum() { return value.getNum(); } 02570 virtual GLenum getVertexAttribType(); 02571 virtual int getVertexAttribSize() { return 4; } 02572 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02573 02574 private: 02575 // Destructor 02576 virtual ~SoVertexShaderParameter4s(); 02577 }; 02578 02579 /*----------------------------------------------------------------------------*/ 02580 02622 class SoVertexShaderParameter4b : public SoVertexShaderParameter { 02623 02624 SO_NODE_HEADER(SoVertexShaderParameter4b); 02625 02626 public: 02630 SoVertexShaderParameter4b(); 02631 02635 SoMFVec4b value; 02636 02640 SoSFBool rangeScaling; 02641 02642 private: 02643 static void initClass(); 02644 static void exitClass(); 02645 02646 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02647 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02648 virtual int getVertexAttribNum() { return value.getNum(); } 02649 virtual GLenum getVertexAttribType(); 02650 virtual int getVertexAttribSize() { return 4; } 02651 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02652 02653 private: 02654 // Destructor 02655 virtual ~SoVertexShaderParameter4b(); 02656 }; 02657 02658 /*----------------------------------------------------------------------------*/ 02659 02701 class SoVertexShaderParameter4ui : public SoVertexShaderParameter { 02702 02703 SO_NODE_HEADER(SoVertexShaderParameter4ui); 02704 02705 public: 02709 SoVertexShaderParameter4ui(); 02710 02714 SoMFVec4ui32 value; 02715 02719 SoSFBool rangeScaling; 02720 02721 private: 02722 static void initClass(); 02723 static void exitClass(); 02724 02725 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02726 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02727 virtual int getVertexAttribNum() { return value.getNum(); } 02728 virtual GLenum getVertexAttribType(); 02729 virtual int getVertexAttribSize() { return 4; } 02730 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02731 02732 private: 02733 // Destructor 02734 virtual ~SoVertexShaderParameter4ui(); 02735 }; 02736 02737 /*----------------------------------------------------------------------------*/ 02738 02781 class SoVertexShaderParameter4us : public SoVertexShaderParameter { 02782 02783 SO_NODE_HEADER(SoVertexShaderParameter4us); 02784 02785 public: 02789 SoVertexShaderParameter4us(); 02790 02794 SoMFVec4us value; 02795 02799 SoSFBool rangeScaling; 02800 02801 private: 02802 static void initClass(); 02803 static void exitClass(); 02804 02805 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02806 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02807 virtual int getVertexAttribNum() { return value.getNum(); } 02808 virtual GLenum getVertexAttribType(); 02809 virtual int getVertexAttribSize() { return 4; } 02810 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02811 02812 private: 02813 // Destructor 02814 virtual ~SoVertexShaderParameter4us(); 02815 }; 02816 02817 /*----------------------------------------------------------------------------*/ 02818 02861 class SoVertexShaderParameter4ub : public SoVertexShaderParameter { 02862 02863 SO_NODE_HEADER(SoVertexShaderParameter4ub); 02864 02865 public: 02869 SoVertexShaderParameter4ub(); 02870 02874 SoMFVec4ub value; 02875 02879 SoSFBool rangeScaling; 02880 02881 private: 02882 static void initClass(); 02883 static void exitClass(); 02884 02885 virtual const char * getVertexAttribPtr(int) { return (char *)value.getValues(0); } 02886 virtual size_t getVertexAttribStride() { return value.getValueSize(); } 02887 virtual int getVertexAttribNum() { return value.getNum(); } 02888 virtual GLenum getVertexAttribType(); 02889 virtual int getVertexAttribSize() { return 4; } 02890 virtual SbBool getVertexAttribIsToNormalize() { return rangeScaling.getValue(); } 02891 02892 private: 02893 // Destructor 02894 virtual ~SoVertexShaderParameter4ub(); 02895 }; 02896 02897 /*----------------------------------------------------------------------------*/ 02898 02936 class SoVertexShaderParameterMatrix : public SoVertexShaderParameter { 02937 02938 SO_NODE_HEADER(SoVertexShaderParameterMatrix); 02939 02940 public: 02944 SoVertexShaderParameterMatrix(); 02945 02949 SoMFMatrix value; 02950 02951 private: 02952 virtual void doAction(SoAction *action); 02953 02954 private: 02955 static void initClass(); 02956 static void exitClass(); 02957 02958 virtual const char * getVertexAttribPtr(int i=0); 02959 virtual size_t getVertexAttribStride() { return sizeof(SbMat); } 02960 virtual int getVertexAttribNum() { return value.getNum(); } 02961 virtual GLenum getVertexAttribType(); 02962 virtual int getVertexAttribSize() { return 4; } 02963 virtual SbBool getVertexAttribIsToNormalize() { return FALSE; } 02964 02965 private: 02966 // Destructor 02967 virtual ~SoVertexShaderParameterMatrix(); 02968 02969 private: 02970 // Storing a list of the transposed matrices of the value field is necessary 02971 // because Open Inventor stores matrices in row major order whereas OpenGL 02972 // load them in column major order. Consequently, this list is necessary, to provide 02973 // values sequentially stored in column major order. 02974 SbMat * m_columnMajorOrderMatrices; 02975 int m_matricesNumber; 02976 void storeColumnMajorOrderMatrices(int startIndex); 02977 }; 02978 02979 /*----------------------------------------------------------------------------*/ 02980 02981 //@TOBEWRAPPED 03019 class SoVertexShaderParameterBufferObject : public SoVertexShaderParameter { 03020 03021 SO_NODE_HEADER(SoVertexShaderParameterBufferObject); 03022 03023 public: 03027 SoVertexShaderParameterBufferObject(); 03028 03032 SoSFBufferObject value; 03033 03038 SoSFInt32 components; 03039 03044 SoSFEnum type; 03045 03050 SoSFInt32 offset; 03051 03057 SoSFInt32 stride; 03058 03063 SoSFBool shouldBeNormalized; 03064 03065 private: 03066 virtual void doAction(SoAction *action); 03067 03068 private: 03069 03070 static void initClass(); 03071 static void exitClass(); 03072 03073 virtual size_t getVertexAttribOffset(int) { return (size_t)offset.getValue(); } 03074 virtual const char* getVertexAttribPtr(int); 03075 03076 virtual size_t getVertexAttribStride(); 03077 virtual int getVertexAttribNum(); 03078 virtual GLenum getVertexAttribType(); 03079 virtual int getVertexAttribSize() { return components.getValue(); } 03080 virtual SbBool getVertexAttribIsToNormalize() { return shouldBeNormalized.getValue(); } 03081 03082 private: 03083 // Destructor 03084 virtual ~SoVertexShaderParameterBufferObject(); 03085 }; 03086 03087 /*----------------------------------------------------------------------------*/ 03088 03089 03090 03091 #endif /*_SO_SHADER_PARAMETER_H_*/ 03092 03093