MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoShader/Inventor/nodes/SoSampler.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 
00006 
00007 
00008 #ifndef  _SO_SAMPLER_
00009 #define  _SO_SAMPLER_
00010 
00011 #include "SoShaderSystem.h"
00012 #include "Inventor/nodes/SoUniformShaderParameter.h"
00013 #include "Inventor/elements/SoSamplerInfoElement.h"
00014 #include <Inventor/fields/SoSFUInt32.h>
00015 #include <Inventor/fields/SoSFEnum.h>
00016 #include <Inventor/fields/SoSFBool.h>
00017 #include <Inventor/fields/SoSFVec4f.h>
00018 #include <GL/glew.h>
00019 
00020 class SoSensor;
00021 class SoFieldSensor;
00022 
00024 SoEXTENDER class INVENTOR_SHADER_API SoSampler : public SoUniformShaderParameter
00025 {
00026    typedef SoUniformShaderParameter inherited;
00027 
00028    SO_NODE_ABSTRACT_HEADER(SoSampler);
00029 
00030    public:
00031 
00033       enum TexGenMode {
00034          NORMAL_MAP      = GL_NORMAL_MAP_EXT,
00035          REFLECTION_MAP  = GL_REFLECTION_MAP_EXT
00036       };
00037 
00039       enum Wrap {
00040          REPEAT          = GL_REPEAT,          // Not supported by GL_TEXTURE_RECTANGLE_ARB
00041          CLAMP           = GL_CLAMP,
00042          CLAMP_TO_EDGE   = GL_CLAMP_TO_EDGE,   // OpenGL 1.2
00043          CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER, // OpenGL 1.3
00044          MIRRORED_REPEAT = GL_MIRRORED_REPEAT  // OpenGL 1.4, not supported by GL_TEXTURE_RECTANGLE_ARB
00045       };
00046 
00048       enum Filter {
00049          NEAREST                = GL_NEAREST,
00050          LINEAR                 = GL_LINEAR,
00051          NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,   // GL_TEXTURE_MIN_FILTER only
00052          NEAREST_MIPMAP_LINEAR  = GL_NEAREST_MIPMAP_LINEAR,    // GL_TEXTURE_MIN_FILTER only
00053          LINEAR_MIPMAP_NEAREST  = GL_LINEAR_MIPMAP_NEAREST,    // GL_TEXTURE_MIN_FILTER only
00054          LINEAR_MIPMAP_LINEAR   = GL_LINEAR_MIPMAP_LINEAR      // GL_TEXTURE_MIN_FILTER only
00055       };
00056 
00058       SoSFEnum   wrapS;
00059 
00061       SoSFBool   enableBorder;
00062 
00064       SoSFVec4f  borderColor;
00065       
00067       SoSFEnum   minFilter;
00068 
00070       SoSFEnum   magFilter;
00071       
00073       SoSFBool   use16BitFloat;
00074 
00075    SoEXTENDER public:
00076 
00078       virtual void  updateParameter(SoUniformParameterBase *uniformBase, SoState *state);
00079 
00080    SoINTERNAL public:
00081 
00083       static void   initClass();
00084 
00085    protected:
00086      
00087       virtual ~SoSampler();
00088 
00090       SbBool         _hasTextureFloat;
00091 
00093       SbString       _sizeUniformName;
00094 
00096       unsigned int   _textureComponents;
00098       GLenum         _textureDataType;
00099 
00101       SoSampler();
00102 
00104       GLint          getInternalFormat(GLenum glDataType);
00105       
00107       const char *   getTextureFormatName(GLenum internalFormat);
00108 
00109       SbSamplerInfo::TextureType getTextureTypeFromGLFormat(GLenum internalFormat);
00110 
00112       void postTextureFormatInfo(GLenum target, GLint format);
00113 
00115       void postTextureSizeInfo(GLenum target);
00116 
00118       virtual void   nameChanged(SoSensor *sensor);
00119       static  void   nameChangedCB(void *data, SoSensor *sensor);
00120 
00122       virtual void   texConfigChanged(SoSensor *) {};
00123       static  void   texConfigChangedCB(void *data, SoSensor *sensor);
00124   
00125    private:
00126 
00127       SoFieldSensor *_nameSensor;
00128       SoFieldSensor *_minSensor;
00129       SoFieldSensor *_magSensor;
00130       SoFieldSensor *_use16BitFloatSensor;
00131 };
00132 
00133 #endif  // _SO_SAMPLER_