OglShader.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SOFA_COMPONENT_OGLSHADER
00037 #define SOFA_COMPONENT_OGLSHADER
00038
00039 #include <sofa/core/VisualModel.h>
00040 #include <sofa/core/objectmodel/BaseObject.h>
00041 #include <sofa/core/Shader.h>
00042 #include <sofa/defaulttype/Vec3Types.h>
00043 #include <sofa/helper/gl/template.h>
00044 #include <sofa/helper/gl/GLSLShader.h>
00045
00046 namespace sofa
00047 {
00048
00049 namespace component
00050 {
00051
00052 namespace visualmodel
00053 {
00054
00065 class OglShader : public core::Shader, public core::VisualModel {
00066 protected:
00068 Data<bool> turnOn;
00069
00071 Data<std::string> vertFilename;
00073 Data<std::string> fragFilename;
00075 Data<std::string> geoFilename;
00076
00078 Data<int> geometryInputType;
00080 Data<int> geometryOutputType;
00082 Data<int> geometryVerticesOut;
00083
00085 sofa::helper::gl::GLSLShader m_shader;
00086
00087 bool hasGeometryShader;
00088
00089 public:
00090 OglShader();
00091 virtual ~OglShader();
00092
00093 void initVisual();
00094 void init();
00095 void reinit();
00096 void drawVisual();
00097 void updateVisual();
00098
00099 void start();
00100 void stop();
00101
00102 void addDefineMacro(const std::string &name, const std::string &value);
00103
00104 void setTexture(const char* name, unsigned short unit);
00105
00106 void setInt(const char* name, int i);
00107 void setInt2(const char* name, int i1, int i2);
00108 void setInt3(const char* name, int i1, int i2, int i3);
00109 void setInt4(const char* name, int i1, int i2, int i3, int i4);
00110
00111 void setFloat(const char* name, float f1);
00112 void setFloat2(const char* name, float f1, float f2);
00113 void setFloat3(const char* name, float f1, float f2, float f3);
00114 void setFloat4(const char* name, float f1, float f2, float f3, float f4);
00115
00116 void setIntVector(const char* name, int count, const GLint* i);
00117 void setIntVector2(const char* name, int count, const GLint* i);
00118 void setIntVector3(const char* name, int count, const GLint* i);
00119 void setIntVector4(const char* name, int count, const GLint* i);
00120
00121 void setFloatVector(const char* name, int count, const float* f);
00122 void setFloatVector2(const char* name, int count, const float* f);
00123 void setFloatVector3(const char* name, int count, const float* f);
00124 void setFloatVector4(const char* name, int count, const float* f);
00125
00126 GLint getGeometryInputType() ;
00127 void setGeometryInputType(GLint v) ;
00128
00129 GLint getGeometryOutputType() ;
00130 void setGeometryOutputType(GLint v) ;
00131
00132 GLint getGeometryVerticesOut() ;
00133 void setGeometryVerticesOut(GLint v);
00134 };
00135
00144 class OglShaderElement : public core::ShaderElement {
00145 protected:
00147 Data<std::string> id;
00149 OglShader* shader;
00150 public:
00151 OglShaderElement();
00152 virtual ~OglShaderElement() { };
00153 virtual void init();
00154
00155
00156 };
00157
00158 }
00159
00160 }
00161
00162 }
00163
00164 #endif //SOFA_COMPONENT_OGLSHADER