RenderTarget.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_RENDERTARGET_HPP
26#define SFML_RENDERTARGET_HPP
27
29// Headers
31#include <SFML/Graphics/Color.hpp>
32#include <SFML/Graphics/View.hpp>
33#include <SFML/Graphics/Rect.hpp>
34
35
36namespace sf
37{
38class Drawable;
39
43class SFML_API RenderTarget
44{
45public :
46
51 virtual ~RenderTarget();
52
59 void Clear(const Color& FillColor = Color(0, 0, 0));
60
67 virtual void Draw(const Drawable& Object);
68
75 virtual unsigned int GetWidth() const = 0;
76
83 virtual unsigned int GetHeight() const = 0;
84
91 void SetView(const View& NewView);
92
99 const View& GetView() const;
100
108
120 void PreserveOpenGLStates(bool Preserve);
121
122protected :
123
128 RenderTarget();
129
134 void Initialize();
135
136private :
137
146 virtual bool Activate(bool Active) = 0;
147
152 void SetRenderStates();
153
155 // Member data
157 View myDefaultView;
158 const View* myCurrentView;
159 bool myPreserveStates;
160 bool myIsDrawing;
161};
162
163} // namespace sf
164
165
166#endif // SFML_RENDERTARGET_HPP
Color is an utility class for manipulating 32-bits RGBA colors.
Definition Color.hpp:41
Abstract base class for every object that can be drawn into a render window.
Definition Drawable.hpp:59
void Clear(const Color &FillColor=Color(0, 0, 0))
Clear the entire target with a single color.
View & GetDefaultView()
Get the default view of the window for read / write.
virtual void Draw(const Drawable &Object)
Draw something into the target.
const View & GetView() const
Get the current view.
RenderTarget()
Default constructor.
void Initialize()
Called by the derived class when it's ready to be initialized.
virtual unsigned int GetWidth() const =0
Get the width of the rendering region of the target.
void SetView(const View &NewView)
Change the current active view.
virtual unsigned int GetHeight() const =0
Get the height of the rendering region of the target.
void PreserveOpenGLStates(bool Preserve)
Tell SFML to preserve external OpenGL states, at the expense of more CPU charge.
This class defines a view (position, size, etc.) ; you can consider it as a 2D camera.
Definition View.hpp:46