1 /*********************************************************************** 2 created: Sun Jan 11 2009 3 author: Paul D Turner 4 *************************************************************************/ 5 /*************************************************************************** 6 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining 9 * a copy of this software and associated documentation files (the 10 * "Software"), to deal in the Software without restriction, including 11 * without limitation the rights to use, copy, modify, merge, publish, 12 * distribute, sublicense, and/or sell copies of the Software, and to 13 * permit persons to whom the Software is furnished to do so, subject to 14 * the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be 17 * included in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 * OTHER DEALINGS IN THE SOFTWARE. 26 ***************************************************************************/ 27 #ifndef _CEGUIRenderTarget_h_ 28 #define _CEGUIRenderTarget_h_ 29 30 #include "CEGUI/Base.h" 31 #include "CEGUI/EventSet.h" 32 #include "CEGUI/EventArgs.h" 33 #include "CEGUI/Vector.h" 34 #include "CEGUI/Rect.h" 35 36 // Start of CEGUI namespace section 37 namespace CEGUI 38 { 39 //! EventArgs class passed to subscribers of RenderTarget events. 40 class CEGUIEXPORT RenderTargetEventArgs : public EventArgs 41 { 42 public: RenderTargetEventArgs(RenderTarget * target)43 RenderTargetEventArgs(RenderTarget* target): 44 target(target) 45 {} 46 47 //! pointer to the RenderTarget that triggered the event. 48 RenderTarget* target; 49 }; 50 51 /*! 52 \brief 53 Defines interface to some surface that can be rendered to. Concrete 54 instances of objects that implement the RenderTarget interface are 55 normally created via the Renderer object. 56 */ 57 class CEGUIEXPORT RenderTarget : 58 public EventSet, 59 public AllocatedObject<RenderTarget> 60 { 61 public: 62 //! Namespace for global events 63 static const String EventNamespace; 64 65 /** Event to be fired when the RenderTarget object's area has changed. 66 * Handlers are passed a const RenderTargetEventArgs reference with 67 * RenderTargetEventArgs::target set to the RenderTarget whose area changed. 68 */ 69 static const String EventAreaChanged; 70 71 /*! 72 \brief 73 Draw geometry from the given GeometryBuffer onto the surface that 74 this RenderTarget represents. 75 76 \param buffer 77 GeometryBuffer object holding the geometry that should be drawn to the 78 RenderTarget. 79 */ 80 virtual void draw(const GeometryBuffer& buffer) = 0; 81 82 /*! 83 \brief 84 Draw geometry from the given RenderQueue onto the surface that 85 this RenderTarget represents. 86 87 \param queue 88 RenderQueue object holding the geometry that should be drawn to the 89 RenderTarget. 90 */ 91 virtual void draw(const RenderQueue& queue) = 0; 92 93 /*! 94 \brief 95 Set the area for this RenderTarget. The exact action this function 96 will take depends upon what the concrete class is representing. For 97 example, with a 'view port' style RenderTarget, this should set the area 98 that the view port occupies on the display (or rendering window). 99 100 \param area 101 Rect object describing the new area to be assigned to the RenderTarget. 102 103 \note 104 When implementing this function, you should be sure to fire the event 105 RenderTarget::EventAreaChanged so that interested parties can know that 106 the change has occurred. 107 108 \exception InvalidRequestException 109 May be thrown if the RenderTarget does not support setting or changing 110 its area, or if the area change can not be satisfied for some reason. 111 */ 112 virtual void setArea(const Rectf& area) = 0; 113 114 /*! 115 \brief 116 Return the area defined for this RenderTarget. 117 118 \return 119 Rect object describing the currently defined area for this RenderTarget. 120 */ 121 virtual const Rectf& getArea() const = 0; 122 123 /*! 124 \brief 125 Return whether the RenderTarget is an implementation that caches 126 actual rendered imagery. 127 128 Typically it is expected that texture based RenderTargets would return 129 true in response to this call. Other types of RenderTarget, like 130 view port based targets, will more likely return false. 131 132 \return 133 - true if the RenderTarget does cache rendered imagery. 134 - false if the RenderTarget does not cache rendered imagery. 135 */ 136 virtual bool isImageryCache() const = 0; 137 138 /*! 139 \brief 140 Activate the render target and put it in a state ready to be drawn to. 141 142 \note 143 You MUST call this before doing any rendering - if you do not call this, 144 in the unlikely event that your application actually works, it will 145 likely stop working in some future version. 146 */ 147 virtual void activate() = 0; 148 149 /*! 150 \brief 151 Deactivate the render target after having completed rendering. 152 153 \note 154 You MUST call this after you finish rendering to the target - if you do 155 not call this, in the unlikely event that your application actually 156 works, it will likely stop working in some future version. 157 */ 158 virtual void deactivate() = 0; 159 160 /*! 161 \brief 162 Take point \a p_in unproject it and put the result in \a p_out. 163 Resulting point is local to GeometryBuffer \a buff. 164 */ 165 virtual void unprojectPoint(const GeometryBuffer& buff, 166 const Vector2f& p_in, Vector2f& p_out) const = 0; 167 }; 168 169 } // End of CEGUI namespace section 170 171 #endif // end of guard _CEGUIRenderTarget_h_ 172