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
00076 ShTextureTraits(unsigned int interpolation,
00077 Filtering filtering,
00078 Wrapping wrapping)
00079 : m_interpolation(interpolation),
00080 m_filtering(filtering),
00081 m_wrapping(wrapping)
00082 {
00083 }
00084
00085 bool operator==(const ShTextureTraits& other) const
00086 {
00087 return m_interpolation == other.m_interpolation
00088 && m_filtering == other.m_filtering
00089 && m_wrapping == other.m_wrapping;
00090 }
00091
00092 bool operator!=(const ShTextureTraits& other) const { return !(*this == other); }
00093
00094 unsigned int interpolation() const { return m_interpolation; }
00095 ShTextureTraits& interpolation(unsigned int interp) { m_interpolation = interp; return *this; }
00096
00097 Filtering filtering() const { return m_filtering; }
00098 ShTextureTraits& filtering(Filtering filtering) { m_filtering = filtering; return *this; }
00099
00100 Wrapping wrapping() const { return m_wrapping; }
00101 ShTextureTraits& wrapping(Wrapping wrapping) { m_wrapping = wrapping; return *this; }
00102
00103
00104 private:
00105 unsigned int m_interpolation;
00106 Filtering m_filtering;
00107 Wrapping m_wrapping;
00108 };
00109
00110 class
00111 SH_DLLEXPORT ShTextureNode : public ShVariableNode {
00112 public:
00113 ShTextureNode(ShTextureDims dims,
00114 int size,
00115 ShValueType valueType,
00116 const ShTextureTraits&,
00117 int width, int height = 1, int depth = 1, int max_nb_elements = -1);
00118 virtual ~ShTextureNode();
00119
00120 ShTextureDims dims() const;
00121
00122
00123 ShPointer<const ShMemory> memory(int n = 0) const;
00124 ShPointer<const ShMemory> memory(ShCubeDirection dir) const;
00125 ShMemoryPtr memory(int n = 0);
00126 ShMemoryPtr memory(ShCubeDirection dir);
00127 void memory(ShMemoryPtr memory, int n = 0);
00128 void memory(ShMemoryPtr memory, ShCubeDirection dir);
00129
00130
00131 const ShTextureTraits& traits() const;
00132 ShTextureTraits& traits();
00133 int width() const;
00134 int height() const;
00135 int depth() const;
00136 int count() const;
00137
00138 void setTexSize(int w);
00139 void setTexSize(int w, int h);
00140 void setTexSize(int w, int h, int d);
00141 const ShVariable& texSizeVar() const;
00142
00143 void count(int n);
00144
00145 private:
00146 int m_count;
00147
00148 ShTextureDims m_dims;
00149
00150 ShMemoryPtr* m_memory;
00151
00152 ShTextureTraits m_traits;
00153 int m_width, m_height, m_depth;
00154
00155 ShVariable m_texSizeVar;
00156
00157
00158 ShTextureNode(const ShTextureNode& other);
00159 ShTextureNode& operator=(const ShTextureNode& other);
00160 };
00161
00162 typedef ShPointer<ShTextureNode> ShTextureNodePtr;
00163 typedef ShPointer<const ShTextureNode> ShTextureNodeCPtr;
00164
00165 }
00166 #endif