Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OgreGLTexture.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 
00026 #ifndef __GLTEXTURE_H__
00027 #define __GLTEXTURE_H__
00028 
00029 #include "OgreGLPrerequisites.h"
00030 #include "OgrePlatform.h"
00031 #include "OgreRenderTexture.h"
00032 #include "OgreTexture.h"
00033 #include "OgreGLSupport.h"
00034 #include "OgreHardwarePixelBuffer.h"
00035 
00036 namespace Ogre {
00037 
00038     class GLTexture : public Texture
00039     {
00040     public:
00041         // Constructor
00042         GLTexture(ResourceManager* creator, const String& name, ResourceHandle handle,
00043             const String& group, bool isManual, ManualResourceLoader* loader, 
00044             GLSupport& support);
00045 
00046         virtual ~GLTexture();      
00047 
00048         void loadImage( const Image& img );
00049         void createRenderTexture();
00050             
00052         HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap);
00053 
00054         // Takes the OGRE texture type (1d/2d/3d/cube) and returns the appropriate GL one
00055         GLenum getGLTextureTarget(void) const;
00056 
00057         GLuint getGLID() const
00058         { return mTextureID; }
00059 
00060     protected:
00062         void createInternalResourcesImpl(void);
00064         void loadImpl(void);
00066         void freeInternalResourcesImpl(void);
00067 
00073         void _createSurfaceList();
00074     private:
00075         GLuint mTextureID;
00076         GLSupport& mGLSupport;
00077         
00079         typedef std::vector<HardwarePixelBufferSharedPtr> SurfaceList;
00080         SurfaceList mSurfaceList;
00081     };
00082 
00089     class GLTexturePtr : public SharedPtr<GLTexture> 
00090     {
00091     public:
00092         GLTexturePtr() : SharedPtr<GLTexture>() {}
00093         explicit GLTexturePtr(GLTexture* rep) : SharedPtr<GLTexture>(rep) {}
00094         GLTexturePtr(const GLTexturePtr& r) : SharedPtr<GLTexture>(r) {} 
00095         GLTexturePtr(const ResourcePtr& r) : SharedPtr<GLTexture>()
00096         {
00097             // lock & copy other mutex pointer
00098             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00099             {
00100                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00101                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00102                 pRep = static_cast<GLTexture*>(r.getPointer());
00103                 pUseCount = r.useCountPointer();
00104                 if (pUseCount)
00105                 {
00106                     ++(*pUseCount);
00107                 }
00108             }
00109         }
00110 
00112         GLTexturePtr& operator=(const ResourcePtr& r)
00113         {
00114             if (pRep == static_cast<GLTexture*>(r.getPointer()))
00115                 return *this;
00116             release();
00117             // lock & copy other mutex pointer
00118             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00119             {
00120                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00121                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00122                 pRep = static_cast<GLTexture*>(r.getPointer());
00123                 pUseCount = r.useCountPointer();
00124                 if (pUseCount)
00125                 {
00126                     ++(*pUseCount);
00127                 }
00128             }
00129             return *this;
00130         }
00132         GLTexturePtr& operator=(const TexturePtr& r)
00133         {
00134             if (pRep == static_cast<GLTexture*>(r.getPointer()))
00135                 return *this;
00136             release();
00137             // lock & copy other mutex pointer
00138             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00139             {
00140                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00141                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00142                 pRep = static_cast<GLTexture*>(r.getPointer());
00143                 pUseCount = r.useCountPointer();
00144                 if (pUseCount)
00145                 {
00146                     ++(*pUseCount);
00147                 }
00148             }
00149             return *this;
00150         }
00151     };
00152 }
00153 
00154 #endif // __GLTEXTURE_H__

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jan 21 10:01:36 2007