RigsofRods
Soft-body Physics Simulation
GPUNormalMapManager.cpp
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of Hydrax.
4 Visit ---
5 
6 Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7  <xavyiy@gmail.com>
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 --------------------------------------------------------------------------------
23 */
24 
25 #include <GPUNormalMapManager.h>
26 
27 #include <Hydrax.h>
28 
29 namespace Hydrax
30 {
32  : mHydrax(h)
33  , mRttManager(h->getRttManager())
34  , mCreated(false)
35  {
38 
39  mNormalMapMaterial.setNull();
40  }
41 
43  {
44  remove();
45  }
46 
48  {
50 
52 
54  {
56  }
57 
58  mCreated = true;
59  }
60 
62  {
63  if (!mCreated)
64  {
65  return;
66  }
67 
68  for (unsigned int k = 0; k < mTextures.size(); k++)
69  {
70  Ogre::TextureManager::getSingleton().remove(mTextures.at(k)->getName());
71  }
72 
73  mTextures.clear();
74 
76 
77  Ogre::HighLevelGpuProgramManager::getSingleton().unload(mNormalMapMaterial->getTechnique(0)->getPass(0)->getVertexProgramName());
78  Ogre::HighLevelGpuProgramManager::getSingleton().unload(mNormalMapMaterial->getTechnique(0)->getPass(0)->getFragmentProgramName());
79  Ogre::HighLevelGpuProgramManager::getSingleton().remove(mNormalMapMaterial->getTechnique(0)->getPass(0)->getVertexProgramName());
80  Ogre::HighLevelGpuProgramManager::getSingleton().remove(mNormalMapMaterial->getTechnique(0)->getPass(0)->getFragmentProgramName());
81 
82  Ogre::MaterialManager::getSingleton().remove(mNormalMapMaterial->getName());
83  mNormalMapMaterial.setNull();
84 
85  mCreated = false;
86  }
87 }
Hydrax::GPUNormalMapManager::mCreated
bool mCreated
Has been create() already called?
Definition: GPUNormalMapManager.h:144
Hydrax::MaterialManager::MAT_UNDERWATER
@ MAT_UNDERWATER
Definition: MaterialManager.h:57
Hydrax::RttManager::NOC_3
@ NOC_3
Definition: RttManager.h:75
Hydrax::RttManager::setBitsPerChannel
void setBitsPerChannel(const RttType &Rtt, const BitsPerChannel &BPC)
Definition: RttManager.h:194
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::GPUNormalMapManager::mHydrax
Hydrax * mHydrax
Hydrax main pointer.
Definition: GPUNormalMapManager.h:139
Hydrax::Hydrax::getMaterialManager
MaterialManager * getMaterialManager()
Get Hydrax::MaterialManager.
Definition: Hydrax.h:325
Hydrax::RttManager::RTT_GPU_NORMAL_MAP
@ RTT_GPU_NORMAL_MAP
Definition: RttManager.h:57
Hydrax::GPUNormalMapManager::mRttManager
RttManager * mRttManager
Rtt manager pointer.
Definition: GPUNormalMapManager.h:141
Hydrax.h
Hydrax::GPUNormalMapManager::mTextures
std::vector< Ogre::TexturePtr > mTextures
The normal map material needs some textures wich will be filled by code.
Definition: GPUNormalMapManager.h:157
Hydrax::GPUNormalMapManager::mNormalMapMaterial
Ogre::MaterialPtr mNormalMapMaterial
This material must be created in the noise module, in order to be according with the Hydrax modulable...
Definition: GPUNormalMapManager.h:151
Hydrax::Hydrax::isComponent
bool isComponent(const HydraxComponent &Component)
Returns if the especified component is active.
Definition: Hydrax.cpp:611
GPUNormalMapManager.h
Hydrax::GPUNormalMapManager::~GPUNormalMapManager
~GPUNormalMapManager()
Destructor.
Definition: GPUNormalMapManager.cpp:42
Hydrax::MaterialManager::reload
void reload(const MaterialType &Material)
Reload material.
Definition: MaterialManager.cpp:3143
Hydrax::GPUNormalMapManager::remove
void remove()
Remove.
Definition: GPUNormalMapManager.cpp:61
Hydrax::GPUNormalMapManager::GPUNormalMapManager
GPUNormalMapManager(Hydrax *h)
Constructor.
Definition: GPUNormalMapManager.cpp:31
Hydrax::GPUNormalMapManager::create
void create()
Create.
Definition: GPUNormalMapManager.cpp:47
Hydrax::MaterialManager::MAT_WATER
@ MAT_WATER
Definition: MaterialManager.h:53
Hydrax::RttManager::BPC_16
@ BPC_16
Definition: RttManager.h:65
Hydrax::RttManager::setNumberOfChannels
void setNumberOfChannels(const RttType &Rtt, const NumberOfChannels &NOC)
Definition: RttManager.h:179
Hydrax::RttManager::initialize
void initialize(const RttType &Rtt)
Initialize a RTT.
Definition: RttManager.cpp:78
Hydrax::HYDRAX_COMPONENT_UNDERWATER
@ HYDRAX_COMPONENT_UNDERWATER
Definition: Enums.h:65
Hydrax::RttManager::remove
void remove(const RttType &Rtt)
Removes a RTT.
Definition: RttManager.cpp:128