00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHBASETEXTURE_HPP
00025 #define SHBASETEXTURE_HPP
00026
00027 #include <string>
00028 #include "ShDllExport.hpp"
00029 #include "ShTextureNode.hpp"
00030 #include "ShMemory.hpp"
00031 #include "ShVariable.hpp"
00032 #include "ShAttrib.hpp"
00033 #include "ShMetaForwarder.hpp"
00034
00035 namespace SH {
00036
00037 class
00038 SH_DLLEXPORT ShBaseTexture : public ShMetaForwarder {
00039 public:
00040 ShBaseTexture(const ShTextureNodePtr& node);
00041
00042 protected:
00043 ShTextureNodePtr m_node;
00044 };
00045
00048 template<typename T>
00049 class ShBaseTexture1D : public ShBaseTexture {
00050 public:
00051 ShBaseTexture1D(const ShTextureTraits& traits);
00052 ShBaseTexture1D(int width, const ShTextureTraits& traits);
00053
00054 template<typename T2>
00055 T operator()(const ShGeneric<1, T2>& coords) const;
00056
00057 template<typename T2>
00058 T operator[](const ShGeneric<1, T2>& coords) const;
00059
00060 ShMemoryPtr memory();
00061 void memory(ShMemoryPtr memory);
00062 void size(int width);
00063
00064 ShAttrib1f size() const;
00065 int width() const { 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 template<typename T2>
00079 T operator()(const ShGeneric<2, T2>& coords) const;
00080
00082 template<typename T2, typename T3, typename T4>
00083 T operator()(const ShGeneric<2, T2>& coords,
00084 const ShGeneric<2, T3>& dx,
00085 const ShGeneric<2, T4>& dy) const;
00086
00087 template<typename T2>
00088 T operator[](const ShGeneric<2, T2>& coords) const;
00089
00090 ShMemoryPtr memory();
00091 void memory(ShMemoryPtr memory);
00092 void size(int width, int height);
00093
00094 ShAttrib2f size() const;
00095
00096 int width() const { return m_node->width(); }
00097 int height() const { return m_node->height(); }
00098
00099 typedef T return_type;
00100 };
00101
00104 template<typename T>
00105 class ShBaseTextureRect : public ShBaseTexture {
00106 public:
00107 ShBaseTextureRect(const ShTextureTraits& traits);
00108 ShBaseTextureRect(int width, int height, const ShTextureTraits& traits);
00109
00110 template<typename T2>
00111 T operator()(const ShGeneric<2, T2>& coords) const;
00112
00113 template<typename T2>
00114 T operator[](const ShGeneric<2, T2>& coords) const;
00115
00116 ShMemoryPtr memory();
00117 void memory(ShMemoryPtr memory);
00118 void size(int width, int height);
00119
00120 ShAttrib2f size() const;
00121
00122 int width() const { return m_node->width(); }
00123 int height() const { return m_node->height(); }
00124
00125 typedef T return_type;
00126 };
00127
00130 template<typename T>
00131 class ShBaseTexture3D : public ShBaseTexture {
00132 public:
00133 ShBaseTexture3D(const ShTextureTraits& traits);
00134 ShBaseTexture3D(int width, int height, int depth, const ShTextureTraits& traits);
00135
00136 template<typename T2>
00137 T operator()(const ShGeneric<3, T2>& coords) const;
00138
00139 template<typename T2>
00140 T operator[](const ShGeneric<3, T2>& coords) const;
00141
00142 ShMemoryPtr memory();
00143 void memory(ShMemoryPtr memory);
00144 void size(int width, int height, int depth);
00145
00146 ShAttrib3f size() const;
00147 int width() const { return m_node->width(); }
00148 int height() const { return m_node->height(); }
00149 int depth() const { return m_node->depth(); }
00150
00151 typedef T return_type;
00152 };
00153
00156 template<typename T>
00157 class ShBaseTextureCube : public ShBaseTexture {
00158 public:
00159 ShBaseTextureCube(const ShTextureTraits& traits);
00160 ShBaseTextureCube(int width, int height, const ShTextureTraits& traits);
00161
00162 template<typename T2>
00163 T operator()(const ShGeneric<3, T2>& coords) const;
00164
00165 ShMemoryPtr memory(ShCubeDirection face);
00166 void memory(ShMemoryPtr memory, ShCubeDirection face);
00167 void size(int width, int height);
00168
00169 ShAttrib2f size() const;
00170
00171 int width() const { return m_node->width(); }
00172 int height() const { return m_node->height(); }
00173
00174 typedef T return_type;
00175 };
00176
00177 }
00178
00179 #include "ShBaseTextureImpl.hpp"
00180
00181 #endif