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