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

GlTextureName.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory
00004 // Project administrator: Michael D. McCool
00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa,
00006 //          Michael D. McCool
00007 // 
00008 // This software is provided 'as-is', without any express or implied
00009 // warranty. In no event will the authors be held liable for any damages
00010 // arising from the use of this software.
00011 // 
00012 // Permission is granted to anyone to use this software for any purpose,
00013 // including commercial applications, and to alter it and redistribute it
00014 // freely, subject to the following restrictions:
00015 // 
00016 // 1. The origin of this software must not be misrepresented; you must
00017 // not claim that you wrote the original software. If you use this
00018 // software in a product, an acknowledgment in the product documentation
00019 // would be appreciated but is not required.
00020 // 
00021 // 2. Altered source versions must be plainly marked as such, and must
00022 // not be misrepresented as being the original software.
00023 // 
00024 // 3. This notice may not be removed or altered from any source
00025 // distribution.
00027 #ifndef SH_GLTEXTURENAME_HPP
00028 #define SH_GLTEXTURENAME_HPP
00029 
00030 #include "GlBackend.hpp"
00031 #include "ShMemory.hpp"
00032 
00033 
00034 namespace shgl {
00035 
00036 class GlTextureName : public SH::ShRefCountable {
00037 public:
00038   GlTextureName(GLenum target);
00039   // Create an unmanaged texture name, i.e. one that is not allocated
00040   // and destroyed by this object
00041   GlTextureName(GLenum target, GLuint name);
00042   
00043   ~GlTextureName();
00044 
00045   GLuint value() const { return m_name; }
00046   GLenum target() const { return m_target; }
00047   const SH::ShTextureTraits& params() const { return m_params; }
00048   void params(const SH::ShTextureTraits& params);
00049 
00050   void addStorage(SH::ShStorage* storage);
00051   void removeStorage(SH::ShStorage* storage);
00052 
00053   typedef std::list<SH::ShStorage*> StorageList;
00054   StorageList::const_iterator beginStorages() const { return m_storages.begin(); }
00055   StorageList::const_iterator endStorages() const { return m_storages.end(); }
00056 
00057   typedef std::list<GlTextureName*> NameList;
00058   static NameList::const_iterator beginNames() { return m_names.begin(); }
00059   static NameList::const_iterator endNames() { return m_names.end(); }
00060 
00061   // Utility class to bind texture temporarily
00062   struct Binding {
00063     Binding(const SH::ShPointer<const GlTextureName>& name);
00064     ~Binding();
00065   
00066     GLenum target;
00067     GLint last;
00068   };
00069   
00070 private:
00071   GLenum m_target;
00072   GLuint m_name;
00073   StorageList m_storages;
00074   static NameList m_names;
00075   SH::ShTextureTraits m_params;
00076 
00077   bool m_managed; // True if we generated our own name
00078 };
00079 
00080 typedef SH::ShPointer<GlTextureName> GlTextureNamePtr;
00081 
00082 }
00083 
00084 #endif

Generated on Mon Jan 24 18:36:29 2005 for Sh by  doxygen 1.4.1