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

ShBaseTexture.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 SHBASETEXTURE_HPP 00028 #define SHBASETEXTURE_HPP 00029 00030 #include <string> 00031 #include "ShDllExport.hpp" 00032 #include "ShTextureNode.hpp" 00033 #include "ShMemory.hpp" 00034 #include "ShVariable.hpp" 00035 #include "ShAttrib.hpp" 00036 #include "ShMetaForwarder.hpp" 00037 00038 namespace SH { 00039 00040 class 00041 SH_DLLEXPORT ShBaseTexture : public ShMetaForwarder { 00042 public: 00043 ShBaseTexture(const ShTextureNodePtr& node); 00044 00045 protected: 00046 ShTextureNodePtr m_node; 00047 }; 00048 00051 template<typename T> 00052 class ShBaseTexture1D : public ShBaseTexture { 00053 public: 00054 ShBaseTexture1D(const ShTextureTraits& traits); 00055 ShBaseTexture1D(int width, const ShTextureTraits& traits); 00056 00057 T operator()(const ShGeneric<1, float>& coords) const; 00058 T operator[](const ShGeneric<1, float>& coords) const; 00059 00060 ShMemoryPtr memory(); 00061 void memory(ShMemoryPtr memory); 00062 void size(int width); 00063 00064 ShAttrib1f size() const; 00065 int width() { return m_node->width(); } 00066 00067 typedef T return_type; 00068 }; 00069 00072 template<typename T> 00073 class ShBaseTexture2D : public ShBaseTexture { 00074 public: 00075 ShBaseTexture2D(const ShTextureTraits& traits); 00076 ShBaseTexture2D(int width, int height, const ShTextureTraits& traits); 00077 00078 T operator()(const ShGeneric<2, float>& coords) const; 00079 T operator[](const ShGeneric<2, float>& coords) const; 00081 T operator()(const ShGeneric<2, float>& coords, 00082 const ShGeneric<2, float>& dx, 00083 const ShGeneric<2, float>& dy) const; 00084 00085 ShMemoryPtr memory(); 00086 void memory(ShMemoryPtr memory); 00087 void size(int width, int height); 00088 00089 ShAttrib2f size() const; 00090 00091 int width() { return m_node->width(); } 00092 int height() { return m_node->height(); } 00093 00094 typedef T return_type; 00095 }; 00096 00099 template<typename T> 00100 class ShBaseTextureRect : public ShBaseTexture { 00101 public: 00102 ShBaseTextureRect(const ShTextureTraits& traits); 00103 ShBaseTextureRect(int width, int height, const ShTextureTraits& traits); 00104 00105 T operator()(const ShGeneric<2, float>& coords) const; 00106 T operator[](const ShGeneric<2, float>& coords) const; 00107 00108 ShMemoryPtr memory(); 00109 void memory(ShMemoryPtr memory); 00110 void size(int width, int height); 00111 00112 ShAttrib2f size() const; 00113 00114 int width() { return m_node->width(); } 00115 int height() { return m_node->height(); } 00116 00117 typedef T return_type; 00118 }; 00119 00122 template<typename T> 00123 class ShBaseTexture3D : public ShBaseTexture { 00124 public: 00125 ShBaseTexture3D(const ShTextureTraits& traits); 00126 ShBaseTexture3D(int width, int height, int depth, const ShTextureTraits& traits); 00127 00128 T operator()(const ShGeneric<3, float>& coords) const; 00129 T operator[](const ShGeneric<3, float>& coords) const; 00130 00131 ShMemoryPtr memory(); 00132 void memory(ShMemoryPtr memory); 00133 void size(int width, int height, int depth); 00134 00135 ShAttrib3f size() const; 00136 int width() { return m_node->width(); } 00137 int height() { return m_node->height(); } 00138 int depth() { return m_node->depth(); } 00139 00140 typedef T return_type; 00141 }; 00142 00145 template<typename T> 00146 class ShBaseTextureCube : public ShBaseTexture { 00147 public: 00148 ShBaseTextureCube(const ShTextureTraits& traits); 00149 ShBaseTextureCube(int width, int height, const ShTextureTraits& traits); 00150 00151 T operator()(const ShGeneric<3, float>& coords) const; 00152 00153 ShMemoryPtr memory(ShCubeDirection face); 00154 void memory(ShMemoryPtr memory, ShCubeDirection face); 00155 void size(int width, int height); 00156 00157 ShAttrib2f size() const; 00158 00159 int width() { return m_node->width(); } 00160 int height() { return m_node->height(); } 00161 00162 typedef T return_type; 00163 }; 00164 00165 } 00166 00167 #include "ShBaseTextureImpl.hpp" 00168 00169 #endif

Generated on Mon Oct 18 14:17:38 2004 for Sh by doxygen 1.3.7