MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoShader/Inventor/nodes/SoShaderProgram.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 
00006 
00007 
00008 #ifndef  _SO_SHADER_PROGRAM_
00009 #define  _SO_SHADER_PROGRAM_
00010 
00011 #include "SoShaderSystem.h"
00012 #include "Inventor/misc/SoShaderTypes.h"
00013 #include "Inventor/fields/SoMFShaderObject.h"
00014 #include "Inventor/fields/SoMFUniformShaderParameter.h"
00015 #include <Inventor/fields/SoSFEnum.h>
00016 #include <Inventor/fields/SoSFInt32.h>
00017 #include <Inventor/nodes/SoSubNode.h>
00018 #include <Inventor/SbPList.h>
00019 
00020 class SoState;
00021 class SoSensor;
00022 class SoNodeSensor;
00023 class SoGLRenderAction;
00024 class SoGLShaderProgram;
00025 
00027 class INVENTOR_SHADER_API SoShaderProgram : public SoNode
00028 {
00029    typedef SoNode inherited;
00030   
00031    SO_NODE_HEADER(SoShaderProgram);
00032   
00033    public:
00034 
00035       enum GeometryInputType { 
00036          POINTS_INPUT, 
00037          LINES_INPUT, 
00038          LINES_ADJACENCY_INPUT,
00039          TRIANGLES_INPUT,
00040          TRIANGLES_ADJACENCY_INPUT
00041       };
00042       enum GeometryOutputType { 
00043          POINTS_OUTPUT, 
00044          LINE_STRIP_OUTPUT, 
00045          TRIANGLE_STRIP_OUTPUT 
00046       };
00047   
00049       SoMFShaderObject shaderObject;
00050   
00052       SoMFUniformShaderParameter parameter;
00053   
00055       SoSFEnum geometryInputType;
00056   
00058       SoSFEnum geometryOutputType;
00059   
00061       SoSFInt32 maxEmittedGeometryVertices;
00062 
00064       SoShaderProgram();
00065   
00066    SoEXTENDER public:
00067 
00069       virtual void GLRender(SoGLRenderAction *action);
00070  
00071    SoINTERNAL public:
00072 
00074       static void initClass();
00075 
00076    protected:
00077   
00078       SoGLShaderProgram *_glShaderProgram;
00079 
00081       SbPList            _usedShaderParameters;
00082 
00084       virtual ~SoShaderProgram();
00085    
00087       void setup();
00088  
00090       SbBool  isValidShaderObjects() const;
00091 
00092       void    adaptParametersList(const SbPList &nextParameters);
00093       void    adaptShadersList(SbPList &prevShaders, const SbPList &nextShaders);
00094       void    scheduleShaderObjectRebuild();
00095       void    injectSnippets();
00096 
00101       void    updateOIVStateDependentParameters(SoState *state);
00102   
00103    private:
00104   
00105       SbPList           _prevGraphShaders;
00106       SbPList           _prevFieldShaders;
00107       
00108       // Active shaders containing the main function
00109       SoShaderObject   *_shaderWithMainFuncForType[SoShader::NUM_SHADER_TYPES];
00110       // List of active shaders with snippets
00111       SbPList           _snippetShadersForType[SoShader::NUM_SHADER_TYPES];
00112 
00113       SoNodeSensor     *_nodeSensor;
00114 
00115       int               _cacheContext;
00116 
00117       static void nodeChangedCB(void *data, SoSensor *sensor);
00118       void nodeChanged(SoField *field);
00119    
00120 };
00121 
00122 #endif  // _SO_SHADER_PROGRAM_