gl_texture.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
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
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 }