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

Generated on Thu Jul 28 17:33:01 2005 for Sh by  doxygen 1.4.3-20050530