Project

General

Profile

SO3Engine
SO3RenderToTexture.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3_RENDER_TO_TEXTURE_H__
33#define __SO3_RENDER_TO_TEXTURE_H__
34
37
38namespace SO3
39{
40
41class _SO3_Export SRenderToTexture : public SNode,
42 public Ogre::FrameListener,
43 public Ogre::ManualResourceLoader,
44 public Ogre::RenderTargetListener
45{
46public:
47protected:
48private:
49 Ogre::Camera* rttCamera;
50 Ogre::TexturePtr rttTexture;
51 Ogre::RenderTarget* rttTarget;
52 Ogre::MaterialPtr material;
53 Ogre::TextureUnitState* textureUnitState;
54 Ogre::TexturePtr oldTexture;
55 unsigned int size;
56 bool state;
57 bool autoUpdate;
58 bool needUpdate;
59 bool needTextureUpdate;
60 bool renderingEnable;
61 float cameraOriginalRatio;
62 std::string materialScheme;
63 SCompositorMap compList;
64
65public:
68 SRenderToTexture(SScene* parent, const std::string& rttName, SCamera* povCamera);
69
73
76 void SetMaterial(SMaterial* targetMaterial, const int& targetTechnique, const int& targetPass, const int& targetTextureUnit);
77
80 void SetMaterialScheme(std::string scheme);
81
84 void SetSize(const unsigned int& newSize);
85
88 unsigned int GetSize();
89
92 void SetEnable(const bool& newState);
93
96 bool GetEnable();
97
103 void SetAutoUpdate(const bool& newAutoUpdateValue);
104
108 bool GetAutoUpdate();
109
113 void Update();
114
118 SCompositor* CreateCompositor(const std::string& newCompositorName, const std::string& newSchemeName);
119
123 void DeleteCompositor(SCompositor* existingCompositor);
124
127 void DeleteCompositor(const std::string& existingCompositorName);
128
132 SCompositor* GetCompositor(const std::string& compositorName);
133
137 const SCompositorMap& GetCompositorList() const;
138
142 void ClearCompositors();
143
146 virtual bool frameStarted(const Ogre::FrameEvent& evt);
147
150 virtual bool frameEnded(const Ogre::FrameEvent& evt);
151
154 virtual void loadResource(Ogre::Resource* resource);
155
158 virtual void windowResized(Ogre::RenderWindow* rw);
159
162 virtual void preViewportUpdate(const Ogre::RenderTargetViewportEvent& evt);
163
166 virtual void postViewportUpdate(const Ogre::RenderTargetViewportEvent& evt);
167protected:
171 void AddCompositor(SCompositor* existingCompositor);
172
176 void RemoveCompositor(SCompositor* existingCompositor);
177
181 void RemoveCompositor(const std::string& compositorName);
182private:
187
190 void SetTextureUnit();
191
194 void ResetTextureUnit();
195
198 void _CreateRenderTexture(const unsigned int& newSize);
199
202 void _DeleteRenderTexture();
203
206 void EnableRendering();
207
210 void DisableRendering();
211
214 void UpdateCompositorViewport(Ogre::Viewport* vp);
215};
216
217}
218
219#endif
librairies include
std::unordered_map< std::string, SCompositor * > SCompositorMap