• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

CEGUIOpenGLTexture.h

00001 /***********************************************************************
00002     filename:   CEGUIOpenGLTexture.h
00003     created:    Sun Jan 11 2009
00004     author:     Paul D Turner
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIOpenGLTexture_h_
00029 #define _CEGUIOpenGLTexture_h_
00030 
00031 #include "../../CEGUIBase.h"
00032 #include "../../CEGUIRenderer.h"
00033 #include "../../CEGUITexture.h"
00034 #include "CEGUIOpenGLRenderer.h"
00035 
00036 // Start of CEGUI namespace section
00037 namespace CEGUI
00038 {
00040 class OPENGL_GUIRENDERER_API OpenGLTexture : public Texture
00041 {
00042 public:
00048     void setOpenGLTexture(GLuint tex, const Size& size);
00049 
00057     GLuint getOpenGLTexture() const;
00058 
00079     void setTextureSize(const Size& sz);
00080 
00088     void grabTexture();
00089 
00095     void restoreTexture();
00096 
00097     // implement abstract members from base class.
00098     const Size& getSize() const;
00099     const Size& getOriginalDataSize() const;
00100     const Vector2& getTexelScaling() const;
00101     void loadFromFile(const String& filename, const String& resourceGroup);
00102     void loadFromMemory(const void* buffer, const Size& buffer_size,
00103                         PixelFormat pixel_format);
00104     void saveToMemory(void* buffer);
00105 
00106 protected:
00107     // Friends (to allow construction and destruction)
00108     friend Texture& OpenGLRenderer::createTexture(void);
00109     friend Texture& OpenGLRenderer::createTexture(const String&, const String&);
00110     friend Texture& OpenGLRenderer::createTexture(const Size&);
00111     friend Texture& OpenGLRenderer::createTexture(GLuint, const Size&);
00112     friend void OpenGLRenderer::destroyTexture(Texture&);
00113 
00115     OpenGLTexture(OpenGLRenderer& owner);
00117     OpenGLTexture(OpenGLRenderer& owner,
00118                   const String& filename, const String& resourceGroup);
00120     OpenGLTexture(OpenGLRenderer& owner, const Size& size);
00122     OpenGLTexture(OpenGLRenderer& owner, GLuint tex, const Size& size);
00124     virtual ~OpenGLTexture();
00125 
00127     void generateOpenGLTexture();
00128 
00130     void updateCachedScaleValues();
00131 
00133     void cleanupOpenGLTexture();
00134 
00136     GLuint d_ogltexture;
00138     Size d_size;
00140     uint8* d_grabBuffer;
00142     Size d_dataSize;
00144     Vector2 d_texelScaling;
00146     OpenGLRenderer& d_owner;
00147 };
00148 
00149 } // End of  CEGUI namespace section
00150 
00151 
00152 #endif // end of guard _CEGUIOpenGLTexture_h_

Generated on Sat Sep 25 2010 02:10:34 for Crazy Eddies GUI System by  doxygen 1.7.1