~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/environment/hydrax/src/GPUNormalMapManager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
Import upstream version 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
{
 
31
        GPUNormalMapManager::GPUNormalMapManager(Hydrax* h)
 
32
                : mHydrax(h)
 
33
                , mRttManager(h->getRttManager())
 
34
                , mCreated(false)
 
35
        {
 
36
                mRttManager->setBitsPerChannel(RttManager::RTT_GPU_NORMAL_MAP, RttManager::BPC_16);
 
37
                mRttManager->setNumberOfChannels(RttManager::RTT_GPU_NORMAL_MAP, RttManager::NOC_3);
 
38
 
 
39
                mNormalMapMaterial.setNull();
 
40
        }
 
41
 
 
42
        GPUNormalMapManager::~GPUNormalMapManager()
 
43
        {
 
44
                remove();
 
45
        }
 
46
 
 
47
        void GPUNormalMapManager::create()
 
48
        {
 
49
                mRttManager->initialize(RttManager::RTT_GPU_NORMAL_MAP);
 
50
 
 
51
                mHydrax->getMaterialManager()->reload(MaterialManager::MAT_WATER);
 
52
 
 
53
                if (mHydrax->isComponent(HYDRAX_COMPONENT_UNDERWATER))
 
54
                {
 
55
                    mHydrax->getMaterialManager()->reload(MaterialManager::MAT_UNDERWATER);
 
56
                }
 
57
 
 
58
                mCreated = true;
 
59
        }
 
60
 
 
61
        void GPUNormalMapManager::remove()
 
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
 
 
75
                mRttManager->remove(RttManager::RTT_GPU_NORMAL_MAP);
 
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
}
 
 
b'\\ No newline at end of file'