/src/ogre/OgreMain/include/OgreRenderTexture.h
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef __RenderTexture_H__ |
29 | | #define __RenderTexture_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreRenderTarget.h" |
33 | | #include "OgreHeaderPrefix.h" |
34 | | |
35 | | namespace Ogre |
36 | | { |
37 | | /** \addtogroup Core |
38 | | * @{ |
39 | | */ |
40 | | /** \addtogroup RenderSystem |
41 | | * @{ |
42 | | */ |
43 | | /** This class represents a RenderTarget that renders to a Texture. There is no 1 on 1 |
44 | | relation between Textures and RenderTextures, as there can be multiple |
45 | | RenderTargets rendering to different mipmaps, faces (for cubemaps) or slices (for 3D textures) |
46 | | of the same Texture. |
47 | | */ |
48 | | class _OgreExport RenderTexture: public RenderTarget |
49 | | { |
50 | | public: |
51 | | RenderTexture(HardwarePixelBuffer *buffer, uint32 zoffset); |
52 | | virtual ~RenderTexture(); |
53 | | |
54 | | using RenderTarget::copyContentsToMemory; |
55 | | void copyContentsToMemory(const Box& src, const PixelBox &dst, FrameBuffer buffer = FB_AUTO) override; |
56 | | PixelFormat suggestPixelFormat() const override; |
57 | | |
58 | | protected: |
59 | | HardwarePixelBuffer *mBuffer; |
60 | | uint32 mZOffset; |
61 | | }; |
62 | | |
63 | | /** This class represents a render target that renders to multiple RenderTextures |
64 | | at once. Surfaces can be bound and unbound at will, as long as the following constraints |
65 | | are met: |
66 | | - All bound surfaces have the same size |
67 | | - All bound surfaces have the same bit depth |
68 | | - Target 0 is bound |
69 | | */ |
70 | | class _OgreExport MultiRenderTarget: public RenderTarget |
71 | | { |
72 | | public: |
73 | | MultiRenderTarget(const String &name); |
74 | | |
75 | | /** Bind a surface to a certain attachment point. |
76 | | @param attachment 0 .. mCapabilities->getNumMultiRenderTargets()-1 |
77 | | @param target RenderTexture to bind. |
78 | | |
79 | | It does not bind the surface and fails with an exception (ERR_INVALIDPARAMS) if: |
80 | | - Not all bound surfaces have the same size |
81 | | - Not all bound surfaces have the same internal format |
82 | | */ |
83 | | void bindSurface(size_t attachment, RenderTexture *target); |
84 | | |
85 | | /** Unbind attachment. |
86 | | */ |
87 | | virtual void unbindSurface(size_t attachment) |
88 | 0 | { |
89 | 0 | if (attachment < mBoundSurfaces.size()) |
90 | 0 | mBoundSurfaces[attachment] = 0; |
91 | 0 | unbindSurfaceImpl(attachment); |
92 | 0 | } |
93 | | |
94 | | using RenderTarget::copyContentsToMemory; |
95 | | |
96 | | /** Error throwing implementation, it's not possible to write a MultiRenderTarget |
97 | | to disk. |
98 | | */ |
99 | | void copyContentsToMemory(const Box& src, const PixelBox &dst, FrameBuffer buffer = FB_AUTO) override; |
100 | | |
101 | | /// Irrelevant implementation since cannot copy |
102 | 0 | PixelFormat suggestPixelFormat() const override { return PF_UNKNOWN; } |
103 | | |
104 | | typedef std::vector<RenderTexture*> BoundSufaceList; |
105 | | /// Get a list of the surfaces which have been bound |
106 | 0 | const BoundSufaceList& getBoundSurfaceList() const { return mBoundSurfaces; } |
107 | | |
108 | | /** Get a pointer to a bound surface */ |
109 | 0 | RenderTexture* getBoundSurface(size_t index) { return mBoundSurfaces.at(index); } |
110 | | |
111 | | protected: |
112 | | BoundSufaceList mBoundSurfaces; |
113 | | |
114 | | /// Implementation of bindSurface, must be provided |
115 | | virtual void bindSurfaceImpl(size_t attachment, RenderTexture *target) = 0; |
116 | | /// Implementation of unbindSurface, must be provided |
117 | | virtual void unbindSurfaceImpl(size_t attachment) = 0; |
118 | | |
119 | | |
120 | | }; |
121 | | /** @} */ |
122 | | /** @} */ |
123 | | } |
124 | | |
125 | | #include "OgreHeaderSuffix.h" |
126 | | |
127 | | #endif |