00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHTEXTURENODE_HPP
00028 #define SHTEXTURENODE_HPP
00029
00030 #include "ShDllExport.hpp"
00031 #include "ShVariableNode.hpp"
00032 #include "ShMemory.hpp"
00033 #include "ShRefCount.hpp"
00034 #include "ShVariable.hpp"
00035
00036 namespace SH {
00037
00041 enum ShTextureDims {
00042 SH_TEXTURE_1D,
00043 SH_TEXTURE_2D,
00044 SH_TEXTURE_RECT,
00045 SH_TEXTURE_3D,
00046 SH_TEXTURE_CUBE,
00047 };
00048
00052 enum ShCubeDirection {
00053 SH_CUBE_POS_X = 0,
00054 SH_CUBE_NEG_X = 1,
00055 SH_CUBE_POS_Y = 2,
00056 SH_CUBE_NEG_Y = 3,
00057 SH_CUBE_POS_Z = 4,
00058 SH_CUBE_NEG_Z = 5,
00059 };
00060
00065 class
00066 SH_DLLEXPORT ShTextureTraits {
00067 public:
00068 enum Filtering {
00069 SH_FILTER_NONE,
00070 SH_FILTER_MIPMAP
00071 };
00072
00073 enum Wrapping {
00074 SH_WRAP_CLAMP,
00075 SH_WRAP_CLAMP_TO_EDGE,
00076 SH_WRAP_REPEAT
00077 };
00078 enum Clamping {
00079 SH_CLAMPED,
00080 SH_UNCLAMPED
00081 };
00082
00083 ShTextureTraits(unsigned int interpolation,
00084 Filtering filtering,
00085 Wrapping wrapping,
00086 Clamping clamping)
00087 : m_interpolation(interpolation),
00088 m_filtering(filtering),
00089 m_wrapping(wrapping),
00090 m_clamping(clamping)
00091 {
00092 }
00093
00094 bool operator==(const ShTextureTraits& other) const
00095 {
00096 return m_interpolation == other.m_interpolation
00097 && m_filtering == other.m_filtering
00098 && m_wrapping == other.m_wrapping
00099 && m_clamping == other.m_clamping;
00100 }
00101
00102 bool operator!=(const ShTextureTraits& other) const { return !(*this == other); }
00103
00104 unsigned int interpolation() const { return m_interpolation; }
00105 ShTextureTraits& interpolation(unsigned int interp) { m_interpolation = interp; return *this; }
00106
00107 Filtering filtering() const { return m_filtering; }
00108 ShTextureTraits& filtering(Filtering filtering) { m_filtering = filtering; return *this; }
00109
00110 Wrapping wrapping() const { return m_wrapping; }
00111 ShTextureTraits& wrapping(Wrapping wrapping) { m_wrapping = wrapping; return *this; }
00112
00113 Clamping clamping() const { return m_clamping; }
00114 ShTextureTraits& clamping(Clamping clamping) { m_clamping = clamping; return *this; }
00115
00116 private:
00117 unsigned int m_interpolation;
00118 Filtering m_filtering;
00119 Wrapping m_wrapping;
00120 Clamping m_clamping;
00121 };
00122
00123 class
00124 SH_DLLEXPORT ShTextureNode : public ShVariableNode {
00125 public:
00126 ShTextureNode(ShTextureDims dims,
00127 int size,
00128 ShValueType valueType,
00129 const ShTextureTraits&,
00130 int width, int height = 1, int depth = 1, int max_nb_elements = -1);
00131 virtual ~ShTextureNode();
00132
00133 ShTextureDims dims() const;
00134
00135
00136 ShPointer<const ShMemory> memory(int n = 0) const;
00137 ShPointer<const ShMemory> memory(ShCubeDirection dir) const;
00138 ShMemoryPtr memory(int n = 0);
00139 ShMemoryPtr memory(ShCubeDirection dir);
00140 void memory(ShMemoryPtr memory, int n = 0);
00141 void memory(ShMemoryPtr memory, ShCubeDirection dir);
00142
00143
00144 const ShTextureTraits& traits() const;
00145 ShTextureTraits& traits();
00146 int width() const;
00147 int height() const;
00148 int depth() const;
00149 int count() const;
00150
00151 void setTexSize(int w);
00152 void setTexSize(int w, int h);
00153 void setTexSize(int w, int h, int d);
00154 const ShVariable& texSizeVar() const;
00155
00156 private:
00157 int m_count;
00158
00159 ShTextureDims m_dims;
00160
00161 ShMemoryPtr* m_memory;
00162
00163 ShTextureTraits m_traits;
00164 int m_width, m_height, m_depth;
00165
00166 ShVariable m_texSizeVar;
00167
00168
00169 ShTextureNode(const ShTextureNode& other);
00170 ShTextureNode& operator=(const ShTextureNode& other);
00171 };
00172
00173 typedef ShPointer<ShTextureNode> ShTextureNodePtr;
00174 typedef ShPointer<const ShTextureNode> ShTextureNodeCPtr;
00175
00176 }
00177 #endif