ShTexDataImpl.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 SHTEXDATAIMPL_HPP
00021 #define SHTEXDATAIMPL_HPP
00022 
00023 #include "ShTexData.hpp"
00024 #include "ShError.hpp"
00025 #include "ShContext.hpp"
00026 
00027 namespace SH {
00028 
00029 template<typename T, int N, typename T2>
00030 ShTexData<T, N, T2>::ShTexData(const ShTextureNodePtr& node, const ShGeneric<N, T2>& coords, bool indexed)
00031 {
00032   if (ShContext::current()->parsing()) {
00033     ShVariable tex_var(node);
00034     ShStatement stmt(*this, tex_var, indexed ? SH_OP_TEXI : SH_OP_TEX, coords);
00035     ShContext::current()->parsing()->tokenizer.blockList()->addStatement(stmt);
00036   } else {
00037     SH_DEBUG_WARN("Immediate mode texture lookup is not yet implemented.");
00038     // TODO
00039   }
00040 }
00041 
00042 template<typename T, int N, typename T2>
00043 ShTexData<T, N, T2>::ShTexData(const ShTextureNodePtr& node, const ShGeneric<N, T2>& coords,
00044                                const ShGeneric<N, T2>& dx, const ShGeneric<N, T2>& dy)
00045 {
00046   if (ShContext::current()->parsing()) {
00047     ShVariable tex_var(node);
00048     ShStatement stmt(*this, SH_OP_TEXD, tex_var, coords, join(dx, dy));
00049     ShContext::current()->parsing()->tokenizer.blockList()->addStatement(stmt);
00050   } else {
00051     shError(ShScopeException("Cannot do derivative texture lookup in immediate mode"));
00052   }
00053 }
00054 
00055 template<typename T, int N, typename T2>
00056 ShTexData<T, N, T2>& ShTexData<T, N, T2>::operator=(const T& a)
00057 {
00058   if (ShContext::current()->parsing()) {
00059     shError(ShScopeException("Cannot assign to a texture in retained mode"));
00060   } else {
00061     SH_DEBUG_WARN("Immediate mode texture assignment is not yet implemented.");
00062     // TODO
00063   }
00064   return *this;
00065 }
00066 
00067 } // namespace
00068 
00069 #endif // SHTEXDATAIMPL_HPP

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