source: OGRE/trunk/ogrenew/OgreMain/src/OgreCompositor.cpp @ 692

Revision 692, 5.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

RevLine 
[692]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#include "OgreStableHeaders.h"
26#include "OgreCompositor.h"
27#include "OgreCompositionTechnique.h"
28
29namespace Ogre {
30
31//-----------------------------------------------------------------------
32Compositor::Compositor(ResourceManager* creator, const String& name, ResourceHandle handle,
33            const String& group, bool isManual, ManualResourceLoader* loader):
34    Resource(creator, name, handle, group, isManual, loader),
35    mCompilationRequired(true)
36{
37}
38//-----------------------------------------------------------------------
39
40Compositor::~Compositor()
41{
42    removeAllTechniques();
43    // have to call this here reather than in Resource destructor
44    // since calling virtual methods in base destructors causes crash
45    unload();
46}
47//-----------------------------------------------------------------------
48CompositionTechnique *Compositor::createTechnique()
49{
50    CompositionTechnique *t = new CompositionTechnique(this);
51    mTechniques.push_back(t);
52    mCompilationRequired = true;
53    return t;
54}
55//-----------------------------------------------------------------------
56
57void Compositor::removeTechnique(size_t index)
58{
59    assert (index < mTechniques.size() && "Index out of bounds.");
60    Techniques::iterator i = mTechniques.begin() + index;
61    delete(*i);
62    mTechniques.erase(i);
63    mSupportedTechniques.clear();
64    mCompilationRequired = true;
65}
66//-----------------------------------------------------------------------
67
68CompositionTechnique *Compositor::getTechnique(size_t index)
69{
70    assert (index < mTechniques.size() && "Index out of bounds.");
71    return mTechniques[index];
72}
73//-----------------------------------------------------------------------
74
75size_t Compositor::getNumTechniques()
76{
77    return mTechniques.size();
78}
79//-----------------------------------------------------------------------
80void Compositor::removeAllTechniques()
81{
82    Techniques::iterator i, iend;
83    iend = mTechniques.end();
84    for (i = mTechniques.begin(); i != iend; ++i)
85    {
86        delete(*i);
87    }
88    mTechniques.clear();
89    mSupportedTechniques.clear();
90    mCompilationRequired = true;
91}
92//-----------------------------------------------------------------------
93Compositor::TechniqueIterator Compositor::getTechniqueIterator(void)
94{
95    return TechniqueIterator(mTechniques.begin(), mTechniques.end());
96}
97//-----------------------------------------------------------------------
98
99CompositionTechnique *Compositor::getSupportedTechnique(size_t index)
100{
101    assert (index < mSupportedTechniques.size() && "Index out of bounds.");
102    return mSupportedTechniques[index];
103}
104//-----------------------------------------------------------------------
105
106size_t Compositor::getNumSupportedTechniques()
107{
108    return mSupportedTechniques.size();
109}
110//-----------------------------------------------------------------------
111
112Compositor::TechniqueIterator Compositor::getSupportedTechniqueIterator(void)
113{
114    return TechniqueIterator(mSupportedTechniques.begin(), mSupportedTechniques.end());
115}
116//-----------------------------------------------------------------------
117void Compositor::loadImpl(void)
118{
119    // compile if required
120    if (mCompilationRequired)
121        compile();
122}
123//-----------------------------------------------------------------------
124void Compositor::unloadImpl(void)
125{
126}
127//-----------------------------------------------------------------------
128size_t Compositor::calculateSize(void) const
129{
130    return 0;
131}
132
133//-----------------------------------------------------------------------
134void Compositor::compile()
135{
136    /// Sift out supported techniques
137    mSupportedTechniques.clear();
138    Techniques::iterator i, iend;
139    iend = mTechniques.end();
140
141        // Try looking for exact technique support with no texture fallback
142    for (i = mTechniques.begin(); i != iend; ++i)
143    {
144        // Look for exact texture support first
145        if((*i)->isSupported(false))
146        {
147            mSupportedTechniques.push_back(*i);
148        }
149    }
150
151        if (mSupportedTechniques.empty())
152        {
153                // Check again, being more lenient with textures
154                for (i = mTechniques.begin(); i != iend; ++i)
155                {
156                        // Allow texture support with degraded pixel format
157                        if((*i)->isSupported(true))
158                        {
159                                mSupportedTechniques.push_back(*i);
160                        }
161                }
162        }
163    mCompilationRequired = false;
164}
165
166}
Note: See TracBrowser for help on using the repository browser.