OglTexture.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #ifndef OGLTEXTURE_H_
00026 #define OGLTEXTURE_H_
00027 
00028 #include <sofa/core/VisualModel.h>
00029 #include <sofa/core/objectmodel/BaseObject.h>
00030 #include <sofa/defaulttype/Vec3Types.h>
00031 #include <sofa/helper/gl/template.h>
00032 #include <sofa/helper/gl/GLSLShader.h>
00033 #include <sofa/helper/gl/Texture.h>
00034 #include <sofa/component/visualmodel/OglShader.h>
00035 
00036 namespace sofa
00037 {
00038 
00039 namespace component
00040 {
00041 
00042 namespace visualmodel
00043 {
00044 
00053 class OglTexture :  public core::VisualModel, public OglShaderElement
00054 {
00055 
00056 protected:
00057     Data<int> textureUnit;
00058     Data<bool> enabled;
00059 
00060 public:
00061     static unsigned short MAX_NUMBER_OF_TEXTURE_UNIT;
00062 
00063     OglTexture();
00064     virtual ~OglTexture();
00065 
00066     virtual void init();
00067     virtual void initVisual();
00068     virtual void reinit();
00069     void fwdDraw(Pass);
00070     void bwdDraw(Pass);
00071 
00072     std::string getTextureName();
00073     void getTextureUnit();
00074 
00075     virtual void bind() = 0;
00076     virtual void unbind() = 0;
00077 
00079     static void setActiveTexture(unsigned short unit);
00080 
00081     //virtual void setInShader(OglShader& s) = 0;
00082 
00083 protected:
00084     virtual void forwardDraw() = 0;
00085     virtual void backwardDraw() = 0;
00086 };
00087 
00088 class OglTexture2D : public OglTexture
00089 {
00090 private:
00091     Data<std::string> texture2DFilename;
00092     Data<bool> repeat;
00093     helper::gl::Texture* texture2D;
00094 
00095     helper::io::Image* img;
00096 
00097 public:
00098     OglTexture2D();
00099     virtual ~OglTexture2D();
00100 
00101     void parse(core::objectmodel::BaseObjectDescription* arg);
00102     void initVisual();
00103     void reinit() { };
00104 
00105     void bind();
00106     void unbind();
00107 
00108 
00109 protected:
00110     void forwardDraw();
00111     void backwardDraw();
00112 };
00113 
00114 }
00115 
00116 }
00117 
00118 }
00119 
00120 #endif /*OGLTEXTURE_H_*/

Generated on Sun Nov 23 03:49:06 2008 for Sofa by  doxygen 1.5.7.1