1 | #include "OgrePhaseTextureRenderingRun.h"
|
---|
2 | #include "OgreIlluminationManager.h"
|
---|
3 |
|
---|
4 |
|
---|
5 | OgrePhaseTextureRenderingRun::OgrePhaseTextureRenderingRun( String name,
|
---|
6 | unsigned int resolutionX,
|
---|
7 | unsigned int resolutionY,
|
---|
8 | String materialName
|
---|
9 | )
|
---|
10 | :PhaseTextureRenderingRun(resolutionX, resolutionY)
|
---|
11 | , OgreRenderingRun(1, 1)
|
---|
12 | , RenderingRun(1, 1)
|
---|
13 | {
|
---|
14 | this->name = name;
|
---|
15 |
|
---|
16 | this->materialName = materialName;
|
---|
17 | createPhaseTexture();
|
---|
18 | }
|
---|
19 |
|
---|
20 | void OgrePhaseTextureRenderingRun::createPhaseTexture()
|
---|
21 | {
|
---|
22 |
|
---|
23 | TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name,
|
---|
24 | "default",
|
---|
25 | TEX_TYPE_2D,
|
---|
26 | resolutionX,
|
---|
27 | resolutionY,
|
---|
28 | 0,
|
---|
29 | 0,
|
---|
30 | PF_FLOAT16_RGBA,
|
---|
31 | TU_RENDERTARGET);
|
---|
32 | phaseTexture = texPtr.getPointer();
|
---|
33 | phaseCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
|
---|
34 | //add viewport to rendertarget
|
---|
35 | HardwarePixelBuffer* hpb = (phaseTexture->getBuffer()).getPointer();
|
---|
36 | RenderTarget* rt = hpb->getRenderTarget();
|
---|
37 | Viewport* v = rt->addViewport(phaseCamera);
|
---|
38 | v->setOverlaysEnabled(false);
|
---|
39 | rt->setAutoUpdated(false);
|
---|
40 | }
|
---|
41 |
|
---|
42 | void OgrePhaseTextureRenderingRun::updateFrame(unsigned long frameNum)
|
---|
43 | {
|
---|
44 | RenderTarget* rt = phaseTexture->getBuffer().getPointer()->getRenderTarget();
|
---|
45 |
|
---|
46 | renderFullscreenQuad(materialName, rt);
|
---|
47 | }
|
---|
48 |
|
---|
49 | void OgrePhaseTextureRenderingRun::freeAllResources()
|
---|
50 | {
|
---|
51 | this->phaseTexture = 0;
|
---|
52 | TextureManager::getSingleton().remove(name);
|
---|
53 | Root::getSingleton()._getCurrentSceneManager()->destroyCamera(name + "_CAMERA");
|
---|
54 | }
|
---|