[148] | 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-2013 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 __RenderTargetListener_H__ |
---|
| 29 | #define __RenderTargetListener_H__ |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | #include "OgrePrerequisites.h" |
---|
| 33 | |
---|
| 34 | namespace Ogre { |
---|
| 35 | |
---|
| 36 | /** \addtogroup Core |
---|
| 37 | * @{ |
---|
| 38 | */ |
---|
| 39 | /** \addtogroup RenderSystem |
---|
| 40 | * @{ |
---|
| 41 | */ |
---|
| 42 | /** Struct containing information about a RenderTarget event. |
---|
| 43 | */ |
---|
| 44 | struct RenderTargetEvent |
---|
| 45 | { |
---|
| 46 | /// The source of the event being raised |
---|
| 47 | RenderTarget* source; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | /** Struct containing information about a RenderTarget Viewport-specific event. |
---|
| 51 | */ |
---|
| 52 | struct RenderTargetViewportEvent |
---|
| 53 | { |
---|
| 54 | /// The source of the event being raised |
---|
| 55 | Viewport* source; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | /** A interface class defining a listener which can be used to receive |
---|
| 59 | notifications of RenderTarget events. |
---|
| 60 | @remarks |
---|
| 61 | A 'listener' is an interface designed to be called back when |
---|
| 62 | particular events are called. This class defines the |
---|
| 63 | interface relating to RenderTarget events. In order to receive |
---|
| 64 | notifications of RenderTarget events, you should create a subclass of |
---|
| 65 | RenderTargetListener and override the methods for which you would like |
---|
| 66 | to customise the resulting processing. You should then call |
---|
| 67 | RenderTarget::addListener passing an instance of this class. |
---|
| 68 | There is no limit to the number of RenderTarget listeners you can register, |
---|
| 69 | allowing you to register multiple listeners for different purposes. |
---|
| 70 | |
---|
| 71 | RenderTarget events occur before and after the target is updated as a whole, |
---|
| 72 | and before and after each viewport on that target is updated. Each RenderTarget |
---|
| 73 | holds it's own set of listeners, but you can register the same listener on |
---|
| 74 | multiple render targets if you like since the event contains details of the |
---|
| 75 | originating RenderTarget. |
---|
| 76 | */ |
---|
| 77 | class _OgreExport RenderTargetListener |
---|
| 78 | { |
---|
| 79 | /* |
---|
| 80 | Note that this could have been an abstract class, but I made |
---|
| 81 | the explicit choice not to do this, because I wanted to give |
---|
| 82 | people the option of only implementing the methods they wanted, |
---|
| 83 | rather than having to create 'do nothing' implementations for |
---|
| 84 | those they weren't interested in. As such this class follows |
---|
| 85 | the 'Adapter' classes in Java rather than pure interfaces. |
---|
| 86 | */ |
---|
| 87 | public: |
---|
| 88 | virtual ~RenderTargetListener() {} |
---|
| 89 | /** Called just before a RenderTarget is about to be rendered into. |
---|
| 90 | @remarks |
---|
| 91 | This event is raised just before any of the viewports on the target |
---|
| 92 | are rendered to. You can perform manual rendering operations here if |
---|
| 93 | you want, but please note that if the Viewport objects attached to this |
---|
| 94 | target are set up to clear the background, you will lose whatever you |
---|
| 95 | render. If you want some kind of backdrop in this event |
---|
| 96 | you should turn off background clearing off on the viewports, and either |
---|
| 97 | clear the viewports yourself in this event handler before doing your rendering |
---|
| 98 | or just render over the top if you don't need to. |
---|
| 99 | */ |
---|
| 100 | virtual void preRenderTargetUpdate(const RenderTargetEvent& evt) |
---|
| 101 | { (void)evt; } |
---|
| 102 | |
---|
| 103 | /** Called just after a RenderTarget has been rendered to. |
---|
| 104 | @remarks |
---|
| 105 | This event is called just after all the viewports attached to the target |
---|
| 106 | in question have been rendered to. You can perform your own manual rendering |
---|
| 107 | commands in this event handler if you like, these will be composited with |
---|
| 108 | the contents of the target already there (depending on the material settings |
---|
| 109 | you use etc). |
---|
| 110 | */ |
---|
| 111 | virtual void postRenderTargetUpdate(const RenderTargetEvent& evt) |
---|
| 112 | { (void)evt; } |
---|
| 113 | |
---|
| 114 | /* Called just before a Viewport on a RenderTarget is to be updated. |
---|
| 115 | @remarks |
---|
| 116 | This method is called before each viewport on the RenderTarget is |
---|
| 117 | rendered to. You can use this to perform per-viewport settings changes, |
---|
| 118 | such as showing / hiding particular overlays. |
---|
| 119 | */ |
---|
| 120 | virtual void preViewportUpdate(const RenderTargetViewportEvent& evt) |
---|
| 121 | { (void)evt; } |
---|
| 122 | |
---|
| 123 | /* Called just after a Viewport on a RenderTarget is to be updated. |
---|
| 124 | @remarks |
---|
| 125 | This method is called after each viewport on the RenderTarget is |
---|
| 126 | rendered to. |
---|
| 127 | */ |
---|
| 128 | virtual void postViewportUpdate(const RenderTargetViewportEvent& evt) |
---|
| 129 | { (void)evt; } |
---|
| 130 | |
---|
| 131 | /** Called to notify listener that a Viewport has been added to the |
---|
| 132 | target in question. |
---|
| 133 | */ |
---|
| 134 | virtual void viewportAdded(const RenderTargetViewportEvent& evt) |
---|
| 135 | { (void)evt; } |
---|
| 136 | /** Called to notify listener that a Viewport has been removed from the |
---|
| 137 | target in question. |
---|
| 138 | */ |
---|
| 139 | virtual void viewportRemoved(const RenderTargetViewportEvent& evt) |
---|
| 140 | { (void)evt; } |
---|
| 141 | }; |
---|
| 142 | /** @} */ |
---|
| 143 | /** @} */ |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | #endif |
---|