ShBaseTextureImpl.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2006 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHBASETEXTUREIMPL_HPP
00021 #define SHBASETEXTUREIMPL_HPP
00022 
00023 #include "ShBaseTexture.hpp"
00024 #include "ShContext.hpp"
00025 #include "ShError.hpp"
00026 
00027 namespace SH {
00028 
00029 template<typename T>
00030 ShBaseTexture1D<T>::ShBaseTexture1D(int width, const ShTextureTraits& traits)
00031   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_1D, T::typesize, T::value_type, traits, width))
00032 {
00033 }
00034 
00035 template<typename T>
00036 ShBaseTexture2D<T>::ShBaseTexture2D(int width, int height, const ShTextureTraits& traits)
00037   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_2D, T::typesize, T::value_type, traits, width, height))
00038 {
00039 }
00040 
00041 template<typename T>
00042 ShBaseTextureRect<T>::ShBaseTextureRect(int width, int height, const ShTextureTraits& traits)
00043   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_RECT, T::typesize, T::value_type, traits, width, height))
00044 {
00045 }
00046 
00047 template<typename T>
00048 ShBaseTexture3D<T>::ShBaseTexture3D(int width, int height, int depth, const ShTextureTraits& traits)
00049   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_3D, T::typesize, T::value_type, traits, width, height, depth))
00050 {
00051 }
00052 
00053 template<typename T>
00054 ShBaseTextureCube<T>::ShBaseTextureCube(int width, int height, const ShTextureTraits& traits)
00055   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_CUBE, T::typesize, T::value_type, traits, width, height))
00056 {
00057 }
00058 
00059 template<typename T>
00060 ShBaseTexture1D<T>::ShBaseTexture1D(const ShTextureTraits& traits)
00061   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_1D, T::typesize, T::value_type, traits, 0))
00062 {
00063 }
00064 
00065 template<typename T>
00066 ShBaseTexture2D<T>::ShBaseTexture2D(const ShTextureTraits& traits)
00067   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_2D, T::typesize, T::value_type, traits, 0, 0))
00068 {
00069 }
00070 
00071 template<typename T>
00072 ShBaseTextureRect<T>::ShBaseTextureRect(const ShTextureTraits& traits)
00073   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_RECT, T::typesize, T::value_type, traits, 0, 0))
00074 {
00075 }
00076 
00077 template<typename T>
00078 ShBaseTexture3D<T>::ShBaseTexture3D(const ShTextureTraits& traits)
00079   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_3D, T::typesize, T::value_type, traits, 0, 0, 0))
00080 {
00081 }
00082 
00083 template<typename T>
00084 ShBaseTextureCube<T>::ShBaseTextureCube(const ShTextureTraits& traits)
00085   : ShBaseTexture(new ShTextureNode(SH_TEXTURE_CUBE, T::typesize, T::value_type, traits, 0, 0))
00086 {
00087 }
00088 
00089 template<typename T>
00090 template<typename T2>
00091 ShTexData<T, 1, T2> ShBaseTexture1D<T>::operator()(const ShGeneric<1, T2>& coords) const
00092 {
00093   return ShTexData<T, 1, T2>(m_node, coords, false);
00094 }
00095 
00096 template<typename T>
00097 template<typename T2> 
00098 ShTexData<T, 2, T2> ShBaseTexture2D<T>::operator()(const ShGeneric<2, T2>& coords) const
00099 {
00100   return ShTexData<T, 2, T2>(m_node, coords, false);
00101 }
00102 
00103 template<typename T>
00104 template<typename T2>
00105 ShTexData<T, 2, T2> ShBaseTexture2D<T>::operator()(const ShGeneric<2, T2>& coords,
00106                                                    const ShGeneric<2, T2>& dx,
00107                                                    const ShGeneric<2, T2>& dy) const
00108 {
00109   return ShTexData<T, 2, T2>(m_node, coords, dx, dy);
00110 }
00111 
00112 template<typename T>
00113 template<typename T2>
00114 ShTexData<T, 2, T2> ShBaseTextureRect<T>::operator()(const ShGeneric<2, T2>& coords) const
00115 {
00116   return ShTexData<T, 2, T2>(m_node, coords, false);
00117 }
00118 
00119 template<typename T>
00120 template<typename T2>
00121 ShTexData<T, 3, T2> ShBaseTexture3D<T>::operator()(const ShGeneric<3, T2>& coords) const
00122 {
00123   return ShTexData<T, 3, T2>(m_node, coords, false);
00124 } 
00125 
00126 template<typename T>
00127 template<typename T2>
00128 ShTexData<T, 3, T2> ShBaseTextureCube<T>::operator()(const ShGeneric<3, T2>& coords) const
00129 {
00130   return ShTexData<T, 3, T2>(m_node, coords, false);
00131 } 
00132 
00133 template<typename T>
00134 template<typename T2>
00135 ShTexData<T, 1, T2> ShBaseTexture1D<T>::operator[](const ShGeneric<1, T2>& coords) const
00136 {
00137   return ShTexData<T, 1, T2>(m_node, coords, true);
00138 }
00139 
00140 template<typename T>
00141 template<typename T2>
00142 ShTexData<T, 2, T2> ShBaseTexture2D<T>::operator[](const ShGeneric<2, T2>& coords) const
00143 {
00144   return ShTexData<T, 2, T2>(m_node, coords, true);
00145 }
00146 
00147 template<typename T>
00148 template<typename T2>
00149 ShTexData<T, 2, T2> ShBaseTextureRect<T>::operator[](const ShGeneric<2, T2>& coords) const
00150 {
00151   return ShTexData<T, 2, T2>(m_node, coords, true);
00152 }
00153 
00154 template<typename T>
00155 template<typename T2>
00156 ShTexData<T, 3, T2> ShBaseTexture3D<T>::operator[](const ShGeneric<3, T2>& coords) const
00157 {
00158   return ShTexData<T, 3, T2>(m_node, coords, true);
00159 }
00160 
00161 // setMemory
00162 
00163 template<typename T>
00164 void ShBaseTexture1D<T>::memory(const ShMemoryPtr& memory, int mipmap_level)
00165 {
00166   m_node->memory(memory, mipmap_level);
00167 }
00168 
00169 template<typename T>
00170 void ShBaseTexture2D<T>::memory(const ShMemoryPtr& memory, int mipmap_level)
00171 {
00172   m_node->memory(memory, mipmap_level);
00173 }
00174 
00175 template<typename T>
00176 void ShBaseTextureRect<T>::memory(const ShMemoryPtr& memory, int mipmap_level)
00177 {
00178   m_node->memory(memory, mipmap_level);
00179 }
00180 
00181 template<typename T>
00182 void ShBaseTexture3D<T>::memory(const ShMemoryPtr& memory, int mipmap_level)
00183 {
00184   m_node->memory(memory, mipmap_level);
00185 }
00186 
00187 template<typename T>
00188 void ShBaseTextureCube<T>::memory(const ShMemoryPtr& memory, ShCubeDirection face, 
00189                                   int mipmap_level)
00190 {
00191   m_node->memory(memory, face, mipmap_level);
00192 }
00193 
00194 // get memory
00195 
00196 template<typename T>
00197 ShMemoryPtr ShBaseTexture1D<T>::memory(int mipmap_level)
00198 {
00199   return m_node->memory(mipmap_level);
00200 }
00201 
00202 template<typename T>
00203 ShMemoryPtr ShBaseTexture2D<T>::memory(int mipmap_level)
00204 {
00205   return m_node->memory(mipmap_level);
00206 }
00207 
00208 template<typename T>
00209 ShMemoryPtr ShBaseTextureRect<T>::memory(int mipmap_level)
00210 {
00211   return m_node->memory(mipmap_level);
00212 }
00213 
00214 template<typename T>
00215 ShMemoryPtr ShBaseTexture3D<T>::memory(int mipmap_level)
00216 {
00217   return m_node->memory(mipmap_level);
00218 }
00219 
00220 template<typename T>
00221 ShMemoryPtr ShBaseTextureCube<T>::memory(ShCubeDirection face, int mipmap_level)
00222 {
00223   return m_node->memory(face, mipmap_level);
00224 }
00225 
00226 // get size
00227 
00228 template<typename T>
00229 ShAttrib1f ShBaseTexture1D<T>::size() const
00230 {
00231   ShAttrib1f t(m_node->texSizeVar().node(), ShSwizzle(m_node->texSizeVar().size()), false);
00232   return t;
00233 }
00234 
00235 template<typename T>
00236 ShAttrib2f ShBaseTexture2D<T>::size() const
00237 {
00238   ShAttrib2f t(m_node->texSizeVar().node(), ShSwizzle(m_node->texSizeVar().size()), false);
00239   return t;
00240 }
00241 
00242 template<typename T>
00243 ShAttrib2f ShBaseTextureRect<T>::size() const
00244 {
00245   ShAttrib2f t(m_node->texSizeVar().node(), ShSwizzle(m_node->texSizeVar().size()), false);
00246   return t;
00247 }
00248 
00249 template<typename T>
00250 ShAttrib3f ShBaseTexture3D<T>::size() const
00251 {
00252   ShAttrib3f t(m_node->texSizeVar().node(), ShSwizzle(m_node->texSizeVar().size()), false);
00253   return t;
00254 }
00255 
00256 template<typename T>
00257 ShAttrib2f ShBaseTextureCube<T>::size() const
00258 {
00259   ShAttrib2f t(m_node->texSizeVar().node(), ShSwizzle(m_node->texSizeVar().size()), false);
00260   return t;
00261 }
00262 
00263 // set size
00264 
00265 template<typename T>
00266 void ShBaseTexture1D<T>::size(int width)
00267 {
00268   m_node->setTexSize(width);
00269 }
00270 
00271 template<typename T>
00272 void ShBaseTexture2D<T>::size(int width, int height)
00273 {
00274   m_node->setTexSize(width, height);
00275 }
00276 
00277 template<typename T>
00278 void ShBaseTextureRect<T>::size(int width, int height)
00279 {
00280   m_node->setTexSize(width, height);
00281 }
00282 
00283 template<typename T>
00284 void ShBaseTexture3D<T>::size(int width, int height, int depth)
00285 {
00286   m_node->setTexSize(width, height, depth);
00287 }
00288 
00289 template<typename T>
00290 void ShBaseTextureCube<T>::size(int width, int height)
00291 {
00292   m_node->setTexSize(width, height);
00293 }
00294 
00295 }
00296 
00297 #endif

Generated on Thu Feb 16 14:51:31 2006 for Sh by  doxygen 1.4.6