Caelum
FastGpuParamRef.cpp
1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2009 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "CaelumPrecompiled.h"
22 #include "FastGpuParamRef.h"
23 
24 using namespace Ogre;
25 
26 namespace Caelum
27 {
28  FastGpuParamRef::FastGpuParamRef(Ogre::GpuProgramParametersSharedPtr paramsPtr, const Ogre::String& name)
29  {
30  this->bind(paramsPtr, name);
31  }
32 
33  void FastGpuParamRef::bind(
34  Ogre::GpuProgramParametersSharedPtr params,
35  const Ogre::String& name,
36  bool throwIfNotFound/* = false*/)
37  {
38  assert(!params.isNull());
39  #if CAELUM_DEBUG_PARAM_REF
40  mParams = params;
41  #endif
42  const GpuConstantDefinition* def = params->_findNamedConstantDefinition(name, throwIfNotFound);
43  if (def) {
44  mPhysicalIndex = def->physicalIndex;
45  assert(this->isBound());
46  } else {
47  mPhysicalIndex = InvalidPhysicalIndex;
48  assert(!this->isBound());
49  }
50  }
51 
52  void FastGpuParamRef::unbind() {
53  #if CAELUM_DEBUG_PARAM_REF
54  mParams.setNull();
55  #endif
56  mPhysicalIndex = InvalidPhysicalIndex;
57  assert(!this->isBound());
58  }
59 }
Caelum namespace.
Definition: Astronomy.cpp:24