View.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 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 CPP3DS_VIEW_HPP
26 #define CPP3DS_VIEW_HPP
27 
29 // Headers
31 #include <cpp3ds/Graphics/Rect.hpp>
32 #include <cpp3ds/Graphics/Transform.hpp>
33 #include <cpp3ds/System/Vector2.hpp>
34 
35 
36 namespace cpp3ds
37 {
42 class View
43 {
44 public :
45 
52  View();
53 
60  explicit View(const FloatRect& rectangle);
61 
69  View(const Vector2f& center, const Vector2f& size);
70 
80  void setCenter(float x, float y);
81 
90  void setCenter(const Vector2f& center);
91 
101  void setSize(float width, float height);
102 
111  void setSize(const Vector2f& size);
112 
123  void setRotation(float angle);
124 
140  void setViewport(const FloatRect& viewport);
141 
152  void reset(const FloatRect& rectangle);
153 
162  const Vector2f& getCenter() const;
163 
172  const Vector2f& getSize() const;
173 
182  float getRotation() const;
183 
192  const FloatRect& getViewport() const;
193 
203  void move(float offsetX, float offsetY);
204 
213  void move(const Vector2f& offset);
214 
223  void rotate(float angle);
224 
240  void zoom(float factor);
241 
252  const Transform& getTransform() const;
253 
264  const Transform& getInverseTransform() const;
265 
266 private :
267 
269  // Member data
271  Vector2f m_center;
272  Vector2f m_size;
273  float m_rotation;
274  FloatRect m_viewport;
275  mutable Transform m_transform;
276  mutable Transform m_inverseTransform;
277  mutable bool m_transformUpdated;
278  mutable bool m_invTransformUpdated;
279 };
280 
281 } // namespace sf
282 
283 
284 #endif // SFML_VIEW_HPP
285 
286 
const Vector2f & getSize() const
Get the size of the view.
void rotate(float angle)
Rotate the view relatively to its current orientation.
const Vector2f & getCenter() const
Get the center of the view.
const Transform & getTransform() const
Get the projection transform of the view.
View()
Default constructor.
void reset(const FloatRect &rectangle)
Reset the view to the given rectangle.
float getRotation() const
Get the current orientation of the view.
void setRotation(float angle)
Set the orientation of the view.
void setViewport(const FloatRect &viewport)
Set the target viewport.
void setCenter(float x, float y)
Set the center of the view.
void setSize(float width, float height)
Set the size of the view.
const FloatRect & getViewport() const
Get the target viewport rectangle of the view.
void move(float offsetX, float offsetY)
Move the view relatively to its current position.
2D camera that defines what region is shown on screen
Definition: View.hpp:42
Define a 3x3 transform matrix.
Definition: Transform.hpp:41
void zoom(float factor)
Resize the view rectangle relatively to its current size.
const Transform & getInverseTransform() const
Get the inverse projection transform of the view.