1 ////////////////////////////////////////////////////////////
\r
3 // SFML - Simple and Fast Multimedia Library
\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
\r
6 // This software is provided 'as-is', without any express or implied warranty.
\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.
\r
9 // Permission is granted to anyone to use this software for any purpose,
\r
10 // including commercial applications, and to alter it and redistribute it freely,
\r
11 // subject to the following restrictions:
\r
13 // 1. The origin of this software must not be misrepresented;
\r
14 // you must not claim that you wrote the original software.
\r
15 // If you use this software in a product, an acknowledgment
\r
16 // in the product documentation would be appreciated but is not required.
\r
18 // 2. Altered source versions must be plainly marked as such,
\r
19 // and must not be misrepresented as being the original software.
\r
21 // 3. This notice may not be removed or altered from any source distribution.
\r
23 ////////////////////////////////////////////////////////////
\r
25 #ifndef SFML_RENDERTARGET_HPP
\r
26 #define SFML_RENDERTARGET_HPP
\r
28 ////////////////////////////////////////////////////////////
\r
30 ////////////////////////////////////////////////////////////
\r
31 #include <SFML/Graphics/Color.hpp>
\r
32 #include <SFML/Graphics/View.hpp>
\r
33 #include <SFML/Graphics/Rect.hpp>
\r
40 ////////////////////////////////////////////////////////////
\r
41 /// Base class for all render targets (window, image, ...)
\r
42 ////////////////////////////////////////////////////////////
\r
43 class SFML_API RenderTarget
\r
47 ////////////////////////////////////////////////////////////
\r
50 ////////////////////////////////////////////////////////////
\r
51 virtual ~RenderTarget();
\r
53 ////////////////////////////////////////////////////////////
\r
54 /// Clear the entire target with a single color
\r
56 /// \param FillColor : Color to use to clear the render target
\r
58 ////////////////////////////////////////////////////////////
\r
59 void Clear(const Color& FillColor = Color(0, 0, 0));
\r
61 ////////////////////////////////////////////////////////////
\r
62 /// Draw something into the target
\r
64 /// \param Object : Object to draw
\r
66 ////////////////////////////////////////////////////////////
\r
67 virtual void Draw(const Drawable& Object);
\r
69 ////////////////////////////////////////////////////////////
\r
70 /// Get the width of the rendering region of the target
\r
72 /// \return Width in pixels
\r
74 ////////////////////////////////////////////////////////////
\r
75 virtual unsigned int GetWidth() const = 0;
\r
77 ////////////////////////////////////////////////////////////
\r
78 /// Get the height of the rendering region of the target
\r
80 /// \return Height in pixels
\r
82 ////////////////////////////////////////////////////////////
\r
83 virtual unsigned int GetHeight() const = 0;
\r
85 ////////////////////////////////////////////////////////////
\r
86 /// Change the current active view.
\r
88 /// \param NewView : New view to use (pass GetDefaultView() to set the default view)
\r
90 ////////////////////////////////////////////////////////////
\r
91 void SetView(const View& NewView);
\r
93 ////////////////////////////////////////////////////////////
\r
94 /// Get the current view
\r
96 /// \return Current view active in the window
\r
98 ////////////////////////////////////////////////////////////
\r
99 const View& GetView() const;
\r
101 ////////////////////////////////////////////////////////////
\r
102 /// Get the default view of the window for read / write
\r
104 /// \return Default view
\r
106 ////////////////////////////////////////////////////////////
\r
107 View& GetDefaultView();
\r
109 ////////////////////////////////////////////////////////////
\r
110 /// Tell SFML to preserve external OpenGL states, at the expense of
\r
111 /// more CPU charge. Use this function if you don't want SFML
\r
112 /// to mess up your own OpenGL states (if any).
\r
113 /// Don't enable state preservation if not needed, as it will allow
\r
114 /// SFML to do internal optimizations and improve performances.
\r
115 /// This parameter is false by default
\r
117 /// \param Preserve : True to preserve OpenGL states, false to let SFML optimize
\r
119 ////////////////////////////////////////////////////////////
\r
120 void PreserveOpenGLStates(bool Preserve);
\r
124 ////////////////////////////////////////////////////////////
\r
125 /// Default constructor
\r
127 ////////////////////////////////////////////////////////////
\r
130 ////////////////////////////////////////////////////////////
\r
131 /// Called by the derived class when it's ready to be initialized
\r
133 ////////////////////////////////////////////////////////////
\r
138 ////////////////////////////////////////////////////////////
\r
139 /// Activate the target for rendering
\r
141 /// \param Active : True to activate rendering, false to deactivate
\r
143 /// \return True if activation succeeded
\r
145 ////////////////////////////////////////////////////////////
\r
146 virtual bool Activate(bool Active) = 0;
\r
148 ////////////////////////////////////////////////////////////
\r
149 /// Set the OpenGL render states needed for the SFML rendering
\r
151 ////////////////////////////////////////////////////////////
\r
152 void SetRenderStates();
\r
154 ////////////////////////////////////////////////////////////
\r
156 ////////////////////////////////////////////////////////////
\r
157 View myDefaultView; ///< Default view
\r
158 const View* myCurrentView; ///< Current active view
\r
159 bool myPreserveStates; ///< Should we preserve external OpenGL states ?
\r
160 bool myIsDrawing; ///< True when Draw is called from inside, to allow some renderstates optimizations
\r
166 #endif // SFML_RENDERTARGET_HPP
\r