00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright 2003-2005 Serious Hack Inc. 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00018 // MA 02110-1301, USA 00020 #ifndef SH_GLTEXTURENAME_HPP 00021 #define SH_GLTEXTURENAME_HPP 00022 00023 #include "GlBackend.hpp" 00024 #include "ShMemory.hpp" 00025 00026 00027 namespace shgl { 00028 00029 class GlTextureName : public SH::ShRefCountable { 00030 public: 00031 GlTextureName(GLenum target); 00032 // Create an unmanaged texture name, i.e. one that is not allocated 00033 // and destroyed by this object 00034 GlTextureName(GLenum target, GLuint name); 00035 00036 ~GlTextureName(); 00037 00038 GLuint value() const { return m_name; } 00039 GLenum target() const { return m_target; } 00040 const SH::ShTextureTraits& params() const { return m_params; } 00041 void params(const SH::ShTextureTraits& params); 00042 00043 void addStorage(SH::ShStorage* storage); 00044 void removeStorage(SH::ShStorage* storage); 00045 00046 typedef std::list<SH::ShStorage*> StorageList; 00047 StorageList::const_iterator beginStorages() const { return m_storages.begin(); } 00048 StorageList::const_iterator endStorages() const { return m_storages.end(); } 00049 00050 typedef std::list<GlTextureName*> NameList; 00051 static NameList::const_iterator beginNames() { return m_names->begin(); } 00052 static NameList::const_iterator endNames() { return m_names->end(); } 00053 00054 // Utility class to bind texture temporarily 00055 struct Binding { 00056 Binding(const SH::ShPointer<const GlTextureName>& name); 00057 ~Binding(); 00058 00059 GLenum target; 00060 GLint last; 00061 }; 00062 00063 private: 00064 GLenum m_target; 00065 GLuint m_name; 00066 StorageList m_storages; 00067 static NameList* m_names; 00068 SH::ShTextureTraits m_params; 00069 00070 bool m_managed; // True if we generated our own name 00071 }; 00072 00073 typedef SH::ShPointer<GlTextureName> GlTextureNamePtr; 00074 00075 } 00076 00077 #endif
1.4.5