00001 /*********************************************************************** 00002 filename: opengltexture.h 00003 created: 9/4/2004 00004 author: Mark Strom 00005 mwstrom@gmail.com 00006 00007 purpose: Interface to Texture implemented via Opengl 00008 *************************************************************************/ 00009 /*************************************************************************** 00010 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00011 * 00012 * Permission is hereby granted, free of charge, to any person obtaining 00013 * a copy of this software and associated documentation files (the 00014 * "Software"), to deal in the Software without restriction, including 00015 * without limitation the rights to use, copy, modify, merge, publish, 00016 * distribute, sublicense, and/or sell copies of the Software, and to 00017 * permit persons to whom the Software is furnished to do so, subject to 00018 * the following conditions: 00019 * 00020 * The above copyright notice and this permission notice shall be 00021 * included in all copies or substantial portions of the Software. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00024 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00025 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00026 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00027 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00028 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00029 * OTHER DEALINGS IN THE SOFTWARE. 00030 ***************************************************************************/ 00031 #ifndef _opengltexture_h_ 00032 #define _opengltexture_h_ 00033 00034 #include "CEGUIBase.h" 00035 #include "CEGUIRenderer.h" 00036 #include "CEGUITexture.h" 00037 #include "openglrenderer.h" 00038 00039 #include <list> 00040 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00045 00050 class OPENGL_GUIRENDERER_API OpenGLTexture : public Texture 00051 { 00052 private: 00053 /************************************************************************* 00054 Friends (to allow construction and destruction) 00055 *************************************************************************/ 00056 friend Texture* OpenGLRenderer::createTexture(void); 00057 friend Texture* OpenGLRenderer::createTexture(const String& filename, const String& resourceGroup); 00058 friend Texture* OpenGLRenderer::createTexture(float size); 00059 friend void OpenGLRenderer::destroyTexture(Texture* texture); 00060 00061 00062 /************************************************************************* 00063 Construction & Destruction (by Renderer object only) 00064 *************************************************************************/ 00065 OpenGLTexture(Renderer* owner); 00066 virtual ~OpenGLTexture(void); 00067 00068 public: 00076 virtual ushort getWidth(void) const {return d_width;} 00077 00085 virtual ushort getHeight(void) const {return d_height;} 00086 00087 virtual ushort getOriginalWidth(void) const { return d_orgWidth; } 00088 virtual ushort getOriginalHeight(void) const { return d_orgHeight; } 00089 00090 virtual float getXScale(void) const { return d_xScale; } 00091 virtual float getYScale(void) const { return d_yScale; } 00092 00106 virtual void loadFromFile(const String& filename, const String& resourceGroup); 00107 00108 00128 virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat); 00129 00130 00138 GLuint getOGLTexid(void) const {return d_ogltexture;} 00139 00140 00151 void setOGLTextureSize(uint size); 00152 00153 00154 /************************************************************************ 00155 Grab/restore 00156 *************************************************************************/ 00162 void grabTexture(void); 00163 00164 00169 void restoreTexture(void); 00170 00171 00172 private: 00174 void updateCachedScaleValues(); 00175 00177 uint getSizeNextPOT(uint size) const; 00178 00179 /************************************************************************* 00180 Implementation Data 00181 *************************************************************************/ 00182 GLuint d_ogltexture; 00183 ushort d_width; 00184 ushort d_height; 00185 uint8* d_grabBuffer; 00186 00187 ushort d_orgWidth; 00189 ushort d_orgHeight; 00191 float d_xScale; 00193 float d_yScale; 00194 }; 00195 00196 } // End of CEGUI namespace section 00197 00198 00199 #endif // end of guard _opengltexture_h_