MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 00006 00007 00008 #ifndef _SO_GL_SHADER_OBJECT_ 00009 #define _SO_GL_SHADER_OBJECT_ 00010 00011 #include "SoShaderSystem.h" 00012 #include "Inventor/misc/SoGLShader.h" 00013 #include "Inventor/misc/SoShaderTypes.h" 00014 #include <Inventor/SbLinear.h> 00015 #ifdef MEVISLAB 00016 #include <mlGLResources.h> 00017 #else 00018 #include <Inventor/system/SbOpenGL.h> 00019 #endif 00020 00021 class SoGLShaderProgram; 00022 00024 class INVENTOR_SHADER_API SoGLShaderObject : public SoGLShader 00025 { 00026 typedef SoGLShader inherited; 00027 00028 public: 00029 00031 SoGLShaderObject(SoShader::ShaderType shaderType); 00032 00034 virtual ~SoGLShaderObject(); 00035 00037 virtual void reset(); 00038 00039 void activate(SbBool act); 00040 SbBool isActive() const { 00041 return _isActive; 00042 } 00043 00044 SoShader::ShaderType shaderType() const { 00045 return _shaderType; 00046 } 00047 00048 void setSource(const SbString &source); 00049 const SbString &getSource() const { 00050 return _source; 00051 } 00052 00053 void attach(SoGLShaderProgram *shaderProgram); 00054 void detach(); 00055 00056 SbBool isCreated() const { 00057 #ifdef MEVISLAB 00058 return _shaderRes.isValid(); 00059 #else 00060 return _shaderHandle != 0; 00061 #endif 00062 } 00063 00064 SoINTERNAL public: 00065 00066 void compile(int context); 00067 00068 void scheduleCompile() { 00069 _shouldCompile = TRUE; 00070 } 00071 SbBool shouldCompile() const { 00072 return _shouldCompile; 00073 } 00074 00075 void scheduleRebuild() { 00076 _shaderProgram = NULL; 00077 _programHandle = 0; 00078 #ifndef MEVISLAB 00079 _shaderHandle = 0; 00080 #endif 00081 _shouldCompile = TRUE; 00082 } 00083 00084 SoGLShaderProgram *getShaderProgram() const { 00085 return _shaderProgram; 00086 } 00087 00088 void setName(const SbString& name) { _name = name; } 00089 00090 const SbString& getName() const { return _name; } 00091 00092 protected: 00093 00094 SoShader::ShaderType _shaderType; 00095 SbBool _isActive; 00096 00097 SbString _source; 00098 SbBool _shouldCompile; 00099 00100 SbString _name; 00101 00102 SoGLShaderProgram *_shaderProgram; 00103 00104 #ifdef MEVISLAB 00105 ml::GLSLShader _shaderRes; 00106 #define SHADERHANDLE (_shaderRes.getHandle()) 00107 #else 00108 GLuint _shaderHandle; 00109 #define SHADERHANDLE (_shaderHandle) 00110 #endif 00111 }; 00112 00113 #endif // _SO_GL_SHADER_OBJECT_