Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00099             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00100             pRep = static_cast<GLTexture*>(r.getPointer());
00101             pUseCount = r.useCountPointer();
00102             if (pUseCount)
00103             {
00104                 ++(*pUseCount);
00105             }
00106         }
00107 
00109         GLTexturePtr& operator=(const ResourcePtr& r)
00110         {
00111             if (pRep == static_cast<GLTexture*>(r.getPointer()))
00112                 return *this;
00113             release();
00114             // lock & copy other mutex pointer
00115             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00116             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00117             pRep = static_cast<GLTexture*>(r.getPointer());
00118             pUseCount = r.useCountPointer();
00119             if (pUseCount)
00120             {
00121                 ++(*pUseCount);
00122             }
00123             return *this;
00124         }
00126         GLTexturePtr& operator=(const TexturePtr& r)
00127         {
00128             if (pRep == static_cast<GLTexture*>(r.getPointer()))
00129                 return *this;
00130             release();
00131             // lock & copy other mutex pointer
00132             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00133             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00134             pRep = static_cast<GLTexture*>(r.getPointer());
00135             pUseCount = r.useCountPointer();
00136             if (pUseCount)
00137             {
00138                 ++(*pUseCount);
00139             }
00140             return *this;
00141         }
00142     };
00143 }
00144 
00145 #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 Mar 12 14:37:41 2006