gl_texture.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Kutumov Alexey                                  *
00003  *   ru.pixel@gmail.com                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020  
00036  #include "gpucalc/texture.h"
00037 
00038 #include "gpucalc/log_manager.h"
00039 #include "gpucalc/string_util.h"
00040 
00041 #include <GL/glew.h>
00042 
00043 namespace gpucalc
00044 {
00045 
00046  const char _GLTextureClassName [] = "GLTexture";
00047 
00048 
00049  class _GpuCalcPrivate GLTexture: public Texture
00050  {
00051 
00052   OBJ_DISABLE_COPY(GLTexture)
00053 
00054   friend class GLGraphicCore;
00055 
00056   public:
00057    ~GLTexture();
00058 
00059 
00060    bool isRenderTexture() const
00061    {
00062     return (mUsage == TU_Render);
00063    }
00064 
00065 
00066    void uploadToGPU();
00067 
00068 
00069    bool isUploadedToGPU() const
00070    {
00071     return mIsUploadedToGPU;
00072    }
00073 
00074 
00075    GLuint getGLTextureID() const
00076    {
00077     return mGLTextureID;
00078    }
00079 
00080 
00081    GLenum getGLTextureTarget() const
00082    {
00083     return mGLTextureTarget;
00084    }
00085 
00086 
00087    GLenum getGLTextureFormat() const
00088    {
00089     return mGLTextureFormat;
00090    }
00091 
00092 
00093    GLenum getGLTextureType() const
00094    {
00095     return mGLTextureType;
00096    }
00097 
00098 
00099    void initialize();
00100 
00101 
00102    bool isInitialized() const
00103    {
00104     return true;
00105    }
00106 
00107 
00108 
00109   private:
00110 
00111    TextureUsage mUsage;
00112 
00113 
00114    bool mIsUploadedToGPU;
00115 
00116 
00117    // GL specific members
00118    GLenum mGLTextureFormat;
00119 
00120 
00121    GLenum mGLTextureTarget;
00122 
00123 
00124    GLenum mGLTextureType;
00125 
00126 
00127    GLint mGLTextureInternalFormat;
00128 
00129 
00135    GLuint mGLTextureID;
00136 
00137 
00141    void * mGLPointer;
00142 
00143 
00144    GraphicCore * mDefaultGraphicCore;
00145 
00146 
00147 
00151    void setNVData();
00152 
00153 
00163    void setATIData();
00164 
00165 
00166    GLTexture(const std::string & TextureName, TextureUsage Usage, GraphicCore * Core):
00167     Object(_GLTextureClassName, TextureName), Texture(_GLTextureClassName, TextureName, Usage, Core),
00168     mUsage(Usage), mIsUploadedToGPU(false), mGLTextureFormat(0), mGLTextureTarget(0), mGLTextureType(0),
00169     mGLTextureInternalFormat(0), mGLTextureID(0), mGLPointer(0), mDefaultGraphicCore(Core)
00170    {
00171     glGenTextures(1, &mGLTextureID);
00172     addSpecificParameter("GLTextureID", &mGLTextureID, sizeof(mGLTextureID));
00173     LogManager::getSingleton().logMessage(dynamic_cast<Bindable *>(this),
00174      "Generated new OpenGL texture ID: " + auxillary::StringUtil::toString(mGLTextureID), LML_Normal);
00175    }
00176 
00177  };
00178 }

Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6