]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Graphics/RenderTarget.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Graphics / RenderTarget.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\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
8 //\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
12 //\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
17 //\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
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_RENDERTARGET_HPP\r
26 #define SFML_RENDERTARGET_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <SFML/Graphics/Color.hpp>\r
32 #include <SFML/Graphics/View.hpp>\r
33 #include <SFML/Graphics/Rect.hpp>\r
34 \r
35 \r
36 namespace sf\r
37 {\r
38 class Drawable;\r
39 \r
40 ////////////////////////////////////////////////////////////\r
41 /// Base class for all render targets (window, image, ...)\r
42 ////////////////////////////////////////////////////////////\r
43 class SFML_API RenderTarget\r
44 {\r
45 public :\r
46 \r
47     ////////////////////////////////////////////////////////////\r
48     /// Destructor\r
49     ///\r
50     ////////////////////////////////////////////////////////////\r
51     virtual ~RenderTarget();\r
52 \r
53     ////////////////////////////////////////////////////////////\r
54     /// Clear the entire target with a single color\r
55     ///\r
56     /// \param FillColor : Color to use to clear the render target\r
57     ///\r
58     ////////////////////////////////////////////////////////////\r
59     void Clear(const Color& FillColor = Color(0, 0, 0));\r
60 \r
61     ////////////////////////////////////////////////////////////\r
62     /// Draw something into the target\r
63     ///\r
64     /// \param Object : Object to draw\r
65     ///\r
66     ////////////////////////////////////////////////////////////\r
67     virtual void Draw(const Drawable& Object);\r
68 \r
69     ////////////////////////////////////////////////////////////\r
70     /// Get the width of the rendering region of the target\r
71     ///\r
72     /// \return Width in pixels\r
73     ///\r
74     ////////////////////////////////////////////////////////////\r
75     virtual unsigned int GetWidth() const = 0;\r
76 \r
77     ////////////////////////////////////////////////////////////\r
78     /// Get the height of the rendering region of the target\r
79     ///\r
80     /// \return Height in pixels\r
81     ///\r
82     ////////////////////////////////////////////////////////////\r
83     virtual unsigned int GetHeight() const = 0;\r
84 \r
85     ////////////////////////////////////////////////////////////\r
86     /// Change the current active view.\r
87     ///\r
88     /// \param NewView : New view to use (pass GetDefaultView() to set the default view)\r
89     ///\r
90     ////////////////////////////////////////////////////////////\r
91     void SetView(const View& NewView);\r
92 \r
93     ////////////////////////////////////////////////////////////\r
94     /// Get the current view\r
95     ///\r
96     /// \return Current view active in the window\r
97     ///\r
98     ////////////////////////////////////////////////////////////\r
99     const View& GetView() const;\r
100 \r
101     ////////////////////////////////////////////////////////////\r
102     /// Get the default view of the window for read / write\r
103     ///\r
104     /// \return Default view\r
105     ///\r
106     ////////////////////////////////////////////////////////////\r
107     View& GetDefaultView();\r
108 \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
116     ///\r
117     /// \param Preserve : True to preserve OpenGL states, false to let SFML optimize\r
118     ///\r
119     ////////////////////////////////////////////////////////////\r
120     void PreserveOpenGLStates(bool Preserve);\r
121 \r
122 protected :\r
123 \r
124     ////////////////////////////////////////////////////////////\r
125     /// Default constructor\r
126     ///\r
127     ////////////////////////////////////////////////////////////\r
128     RenderTarget();\r
129 \r
130     ////////////////////////////////////////////////////////////\r
131     /// Called by the derived class when it's ready to be initialized\r
132     ///\r
133     ////////////////////////////////////////////////////////////\r
134     void Initialize();\r
135 \r
136 private :\r
137 \r
138     ////////////////////////////////////////////////////////////\r
139     /// Activate the target for rendering\r
140     ///\r
141     /// \param Active : True to activate rendering, false to deactivate\r
142     ///\r
143     /// \return True if activation succeeded\r
144     ///\r
145     ////////////////////////////////////////////////////////////\r
146     virtual bool Activate(bool Active) = 0;\r
147 \r
148     ////////////////////////////////////////////////////////////\r
149     /// Set the OpenGL render states needed for the SFML rendering\r
150     ///\r
151     ////////////////////////////////////////////////////////////\r
152     void SetRenderStates();\r
153 \r
154     ////////////////////////////////////////////////////////////\r
155     // Member data\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
161 };\r
162 \r
163 } // namespace sf\r
164 \r
165 \r
166 #endif // SFML_RENDERTARGET_HPP\r