/src/ogre/OgreMain/src/OgreRenderTexture.cpp
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #include "OgreStableHeaders.h" |
29 | | #include "OgreHardwarePixelBuffer.h" |
30 | | |
31 | | namespace Ogre |
32 | | { |
33 | | |
34 | | //----------------------------------------------------------------------------- |
35 | | RenderTexture::RenderTexture(HardwarePixelBuffer *buffer, uint32 zoffset): |
36 | 0 | mBuffer(buffer), mZOffset(zoffset) |
37 | 0 | { |
38 | 0 | mPriority = OGRE_REND_TO_TEX_RT_GROUP; |
39 | 0 | mWidth = mBuffer->getWidth(); |
40 | 0 | mHeight = mBuffer->getHeight(); |
41 | |
|
42 | 0 | if(PixelUtil::isDepth(mBuffer->getFormat())) |
43 | 0 | mDepthBufferPoolId = RBP_NONE; |
44 | 0 | } |
45 | | RenderTexture::~RenderTexture() |
46 | 0 | { |
47 | 0 | mBuffer->_clearSliceRTT(0); |
48 | 0 | } |
49 | | |
50 | | void RenderTexture::copyContentsToMemory(const Box& src, const PixelBox &dst, FrameBuffer buffer) |
51 | 0 | { |
52 | 0 | if (buffer == FB_AUTO) buffer = FB_FRONT; |
53 | 0 | OgreAssert(buffer == FB_FRONT, "Invalid buffer"); |
54 | | |
55 | 0 | mBuffer->blitToMemory(src, dst); |
56 | 0 | } |
57 | | //--------------------------------------------------------------------- |
58 | | PixelFormat RenderTexture::suggestPixelFormat() const |
59 | 0 | { |
60 | 0 | return mBuffer->getFormat(); |
61 | 0 | } |
62 | | //----------------------------------------------------------------------------- |
63 | | MultiRenderTarget::MultiRenderTarget(const String &name) |
64 | 0 | { |
65 | 0 | mPriority = OGRE_REND_TO_TEX_RT_GROUP; |
66 | 0 | mName = name; |
67 | | /// Width and height is unknown with no targets attached |
68 | 0 | mWidth = mHeight = 0; |
69 | 0 | } |
70 | | void MultiRenderTarget::bindSurface(size_t attachment, RenderTexture* target) |
71 | 0 | { |
72 | 0 | if(PixelUtil::isDepth(target->suggestPixelFormat())) |
73 | 0 | setDepthBufferPool(RBP_NONE); // unbinds any previously bound depth render buffer |
74 | |
|
75 | 0 | for (size_t i = mBoundSurfaces.size(); i <= attachment; ++i) |
76 | 0 | { |
77 | 0 | mBoundSurfaces.push_back(0); |
78 | 0 | } |
79 | 0 | mBoundSurfaces[attachment] = target; |
80 | |
|
81 | 0 | bindSurfaceImpl(attachment, target); |
82 | 0 | } |
83 | | |
84 | | //----------------------------------------------------------------------------- |
85 | | void MultiRenderTarget::copyContentsToMemory(const Box& src, const PixelBox &dst, FrameBuffer buffer) |
86 | 0 | { |
87 | | OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, |
88 | 0 | "Cannot get MultiRenderTargets pixels", |
89 | 0 | "MultiRenderTarget::copyContentsToMemory"); |
90 | 0 | } |
91 | | } |