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-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #ifndef _SO_SHADER_PROGRAM_ELEMENT_ 00025 #define _SO_SHADER_PROGRAM_ELEMENT_ 00026 00027 #include <Inventor/elements/SoReplacedElement.h> 00028 00029 class SoGLShaderProgram ; 00030 class SoShaderProgram ; 00031 class SoGLRenderAction; 00032 00044 SoEXTENDER_Documented class SoShaderProgramElement : public SoReplacedElement { 00045 00046 SO_ELEMENT_HEADER(SoShaderProgramElement); 00047 00048 public: 00052 static void set(SoState *state, SoNode *node); 00053 00057 static void get(SoState *state, SoShaderProgram *&); 00058 00062 virtual void push(SoState *) ; 00063 00067 virtual void pop(SoState *state, const SoElement *prevTopElement); 00068 00069 private: 00070 00075 virtual void commonInit(); 00076 00078 virtual void init(SoState *state); 00079 00080 private: 00081 // Initializes the classes. 00082 static void initClass(); 00083 static void exitClass(); 00084 00086 static const SoShaderProgramElement* get(SoState *state); 00087 00089 inline bool isEnabled() const { return m_enabled; } 00090 00092 inline bool isInternal() const { return m_internal; } 00093 00094 // Current shader storage 00095 SoShaderProgram *m_shaderProgram ; 00096 00097 static SoShaderProgramElement * getCurrentElement(SoState *); 00098 00100 static SbBool generatesTransparency(SoState *state); 00101 00103 static bool hasTessellationShader(SoState *state); 00104 00106 static void setBuiltInUniforms(SoGLRenderAction* action); 00107 00110 static SoShaderProgram* getActiveProgram(SoState* state); 00111 00112 private: 00113 // Destructor 00114 virtual ~SoShaderProgramElement(); 00115 00117 bool m_enabled; 00118 00119 // describes if the shader program is set by the user (i.e. false) or by a 00120 // shader-dependent node (i.e. true, such as SoShadowGroup or SoMultipleInstance). 00121 bool m_internal; 00122 }; 00123 #endif /* _SO_GL_SHADER_PROGRAM_ELEMENT_ */ 00124 00125 00126