00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 #ifndef SH_DO_NOT_INCLUDE_GENERIC_IMPL
00029 #define SH_DO_NOT_INCLUDE_GENERIC_IMPL
00030 #include "ShAttrib.hpp"
00031 #undef SH_DO_NOT_INCLUDE_GENERIC_IMPL
00032 #else
00033 #include "ShAttrib.hpp"
00034 #endif
00035 #include "ShMetaForwarder.hpp"
00036 #include "ShTexData.hpp"
00037
00038 namespace SH {
00039
00040 class
00041 SH_DLLEXPORT ShBaseTexture : public ShMetaForwarder {
00042 public:
00043 ShBaseTexture(const ShTextureNodePtr& node);
00044
00045 void build_mipmaps() { m_node->build_mipmaps(); }
00046
00048 const ShTextureNodePtr & node() const { return m_node; }
00049
00050 protected:
00051 ShTextureNodePtr m_node;
00052 };
00053
00056 template<typename T>
00057 class ShBaseTexture1D : public ShBaseTexture {
00058 public:
00059 ShBaseTexture1D(const ShTextureTraits& traits);
00060 ShBaseTexture1D(int width, const ShTextureTraits& traits);
00061
00062 template<typename T2>
00063 ShTexData<T, 1, T2> operator()(const ShGeneric<1, T2>& coords) const;
00064
00065 template<typename T2>
00066 ShTexData<T, 1, T2> operator[](const ShGeneric<1, T2>& coords) const;
00067
00068 ShMemoryPtr memory(int mipmap_level=0);
00069 void memory(const ShMemoryPtr& memory, int mipmap_level=0);
00070 void size(int width);
00071
00072 ShAttrib1f size() const;
00073 int width() const { return m_node->width(); }
00074
00075 typedef T return_type;
00076 };
00077
00080 template<typename T>
00081 class ShBaseTexture2D : public ShBaseTexture {
00082 public:
00083 ShBaseTexture2D(const ShTextureTraits& traits);
00084 ShBaseTexture2D(int width, int height, const ShTextureTraits& traits);
00085
00086 template<typename T2>
00087 ShTexData<T, 2, T2> operator()(const ShGeneric<2, T2>& coords) const;
00088
00090 template<typename T2>
00091 ShTexData<T, 2, T2> operator()(const ShGeneric<2, T2>& coords,
00092 const ShGeneric<2, T2>& dx,
00093 const ShGeneric<2, T2>& dy) const;
00094
00095 template<typename T2>
00096 ShTexData<T, 2, T2> operator[](const ShGeneric<2, T2>& coords) const;
00097
00098 ShMemoryPtr memory(int mipmap_level=0);
00099 void memory(const ShMemoryPtr& memory, int mipmap_level=0);
00100 void size(int width, int height);
00101
00102 ShAttrib2f size() const;
00103
00104 int width() const { return m_node->width(); }
00105 int height() const { return m_node->height(); }
00106
00107 typedef T return_type;
00108 };
00109
00112 template<typename T>
00113 class ShBaseTextureRect : public ShBaseTexture {
00114 public:
00115 ShBaseTextureRect(const ShTextureTraits& traits);
00116 ShBaseTextureRect(int width, int height, const ShTextureTraits& traits);
00117
00118 template<typename T2>
00119 ShTexData<T, 2, T2> operator()(const ShGeneric<2, T2>& coords) const;
00120
00121 template<typename T2>
00122 ShTexData<T, 2, T2> operator[](const ShGeneric<2, T2>& coords) const;
00123
00124 ShMemoryPtr memory(int mipmap_level=0);
00125 void memory(const ShMemoryPtr& memory, int mipmap_level=0);
00126 void size(int width, int height);
00127
00128 ShAttrib2f size() const;
00129
00130 int width() const { return m_node->width(); }
00131 int height() const { return m_node->height(); }
00132
00133 typedef T return_type;
00134 };
00135
00138 template<typename T>
00139 class ShBaseTexture3D : public ShBaseTexture {
00140 public:
00141 ShBaseTexture3D(const ShTextureTraits& traits);
00142 ShBaseTexture3D(int width, int height, int depth, const ShTextureTraits& traits);
00143
00144 template<typename T2>
00145 ShTexData<T, 3, T2> operator()(const ShGeneric<3, T2>& coords) const;
00146
00147 template<typename T2>
00148 ShTexData<T, 3, T2> operator[](const ShGeneric<3, T2>& coords) const;
00149
00150 ShMemoryPtr memory(int mipmap_level=0);
00151 void memory(const ShMemoryPtr& memory, int mipmap_level=0);
00152 void size(int width, int height, int depth);
00153
00154 ShAttrib3f size() const;
00155 int width() const { return m_node->width(); }
00156 int height() const { return m_node->height(); }
00157 int depth() const { return m_node->depth(); }
00158
00159 typedef T return_type;
00160 };
00161
00164 template<typename T>
00165 class ShBaseTextureCube : public ShBaseTexture {
00166 public:
00167 ShBaseTextureCube(const ShTextureTraits& traits);
00168 ShBaseTextureCube(int width, int height, const ShTextureTraits& traits);
00169
00170 template<typename T2>
00171 ShTexData<T, 3, T2> operator()(const ShGeneric<3, T2>& coords) const;
00172
00173 ShMemoryPtr memory(ShCubeDirection face, int mipmap_level=0);
00174 void memory(const ShMemoryPtr& memory, ShCubeDirection face, int mipmap_level=0);
00175 void size(int width, int height);
00176
00177 ShAttrib2f size() const;
00178
00179 int width() const { return m_node->width(); }
00180 int height() const { return m_node->height(); }
00181
00182 typedef T return_type;
00183 };
00184
00185 }
00186
00187 #include "ShBaseTextureImpl.hpp"
00188
00189 #endif