Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShTextureNode.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 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, // Power of two 00043 SH_TEXTURE_2D, // Power of two 00044 SH_TEXTURE_RECT, // Non power of two 00045 SH_TEXTURE_3D, // Power of two, but depth may not be 00046 SH_TEXTURE_CUBE, // 6 "2D" memory objects, power of two 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, // scalars per tuple 00128 const ShTextureTraits&, 00129 int width, int height = 0, int depth = 0); 00130 virtual ~ShTextureNode(); 00131 00132 ShTextureDims dims() const; 00133 00134 // Memory 00135 ShPointer<const ShMemory> memory(int n = 0) const; 00136 ShPointer<const ShMemory> memory(ShCubeDirection dir) const; 00137 ShMemoryPtr memory(int n = 0); 00138 ShMemoryPtr memory(ShCubeDirection dir); 00139 void memory(ShMemoryPtr memory, int n = 0); 00140 void memory(ShMemoryPtr memory, ShCubeDirection dir); 00141 00142 // Basic properties - not all may be valid for all types 00143 const ShTextureTraits& traits() const; // valid for all texture nodes 00144 ShTextureTraits& traits(); // valid for all texture nodes 00145 int width() const; // valid for all texture nodes 00146 int height() const; // not for SH_TEXTURE_1D 00147 int depth() const; // only for SH_TEXTURE_3D 00148 00149 void setTexSize(int w); 00150 void setTexSize(int w, int h); 00151 void setTexSize(int w, int h, int d); 00152 const ShVariable& texSizeVar() const; 00153 00154 private: 00155 ShTextureDims m_dims; 00156 00157 ShMemoryPtr* m_memory; // array of either 1 or 6 (for cubemaps) 00158 00159 ShTextureTraits m_traits; 00160 int m_width, m_height, m_depth; 00161 00162 ShVariable m_texSizeVar; 00163 00164 // NOT IMPLEMENTED 00165 ShTextureNode(const ShTextureNode& other); 00166 ShTextureNode& operator=(const ShTextureNode& other); 00167 }; 00168 00169 typedef ShPointer<ShTextureNode> ShTextureNodePtr; 00170 typedef ShPointer<const ShTextureNode> ShTextureNodeCPtr; 00171 00172 } 00173 #endif

Generated on Mon Oct 18 14:17:40 2004 for Sh by doxygen 1.3.7