Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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   template<typename T2>
00058   T operator()(const ShGeneric<1, T2>& coords) const;
00059 
00060   template<typename T2>
00061   T operator[](const ShGeneric<1, T2>& coords) const;
00062 
00063   ShMemoryPtr memory();
00064   void memory(ShMemoryPtr memory);
00065   void size(int width);
00066 
00067   ShAttrib1f size() const;
00068   int width() { return m_node->width(); }
00069 
00070   typedef T return_type;
00071 };
00072 
00075 template<typename T>
00076 class ShBaseTexture2D : public ShBaseTexture  {
00077 public:
00078   ShBaseTexture2D(const ShTextureTraits& traits);
00079   ShBaseTexture2D(int width, int height, const ShTextureTraits& traits);
00080 
00081   template<typename T2>
00082   T operator()(const ShGeneric<2, T2>& coords) const;
00083 
00085   template<typename T2, typename T3, typename T4>
00086   T operator()(const ShGeneric<2, T2>& coords,
00087                const ShGeneric<2, T3>& dx,
00088                const ShGeneric<2, T4>& dy) const;
00089   
00090   template<typename T2>
00091   T operator[](const ShGeneric<2, T2>& coords) const;
00092 
00093   ShMemoryPtr memory();
00094   void memory(ShMemoryPtr memory);
00095   void size(int width, int height);
00096 
00097   ShAttrib2f size() const;
00098 
00099   int width() { return m_node->width(); }
00100   int height() { return m_node->height(); }
00101 
00102   typedef T return_type;
00103 };
00104 
00107 template<typename T>
00108 class ShBaseTextureRect : public ShBaseTexture  {
00109 public:
00110   ShBaseTextureRect(const ShTextureTraits& traits);
00111   ShBaseTextureRect(int width, int height, const ShTextureTraits& traits);
00112 
00113   template<typename T2>
00114   T operator()(const ShGeneric<2, T2>& coords) const;
00115 
00116   template<typename T2>
00117   T operator[](const ShGeneric<2, T2>& coords) const;
00118 
00119   ShMemoryPtr memory();
00120   void memory(ShMemoryPtr memory);
00121   void size(int width, int height);
00122 
00123   ShAttrib2f size() const;
00124 
00125   int width() { return m_node->width(); }
00126   int height() { return m_node->height(); }
00127 
00128   typedef T return_type;
00129 };
00130 
00133 template<typename T>
00134 class ShBaseTexture3D : public ShBaseTexture  {
00135 public:
00136   ShBaseTexture3D(const ShTextureTraits& traits);
00137   ShBaseTexture3D(int width, int height, int depth, const ShTextureTraits& traits);
00138 
00139   template<typename T2>
00140   T operator()(const ShGeneric<3, T2>& coords) const;
00141 
00142   template<typename T2>
00143   T operator[](const ShGeneric<3, T2>& coords) const;
00144 
00145   ShMemoryPtr memory();
00146   void memory(ShMemoryPtr memory);
00147   void size(int width, int height, int depth);
00148 
00149   ShAttrib3f size() const;
00150   int width() { return m_node->width(); }
00151   int height() { return m_node->height(); }
00152   int depth() { return m_node->depth(); }
00153 
00154   typedef T return_type;
00155 };
00156 
00159 template<typename T>
00160 class ShBaseTextureCube : public ShBaseTexture {
00161 public:
00162   ShBaseTextureCube(const ShTextureTraits& traits);
00163   ShBaseTextureCube(int width, int height, const ShTextureTraits& traits);
00164 
00165   template<typename T2>
00166   T operator()(const ShGeneric<3, T2>& coords) const;
00167 
00168   ShMemoryPtr memory(ShCubeDirection face);
00169   void memory(ShMemoryPtr memory, ShCubeDirection face);
00170   void size(int width, int height);
00171 
00172   ShAttrib2f size() const;
00173 
00174   int width() { return m_node->width(); }
00175   int height() { return m_node->height(); }
00176 
00177   typedef T return_type;
00178 };
00179 
00180 }
00181 
00182 #include "ShBaseTextureImpl.hpp"
00183 
00184 #endif

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