]> git.sesse.net Git - casparcg/blob - dependencies64/sfml/include/SFML/Graphics/View.hpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / dependencies64 / sfml / include / SFML / Graphics / View.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_VIEW_HPP\r
26 #define SFML_VIEW_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <SFML/Config.hpp>\r
32 #include <SFML/Graphics/Rect.hpp>\r
33 #include <SFML/Graphics/Matrix3.hpp>\r
34 #include <SFML/System/Vector2.hpp>\r
35 \r
36 \r
37 namespace sf\r
38 {\r
39 class RenderTarget;\r
40 \r
41 ////////////////////////////////////////////////////////////\r
42 /// This class defines a view (position, size, etc.) ;\r
43 /// you can consider it as a 2D camera\r
44 ////////////////////////////////////////////////////////////\r
45 class SFML_API View\r
46 {\r
47 public :\r
48 \r
49     ////////////////////////////////////////////////////////////\r
50     /// Construct the view from a rectangle\r
51     ///\r
52     /// \param ViewRect : Rectangle defining the position and size of the view (1000x1000 by default)\r
53     ///\r
54     ////////////////////////////////////////////////////////////\r
55     explicit View(const FloatRect& ViewRect = FloatRect(0, 0, 1000, 1000));\r
56 \r
57     ////////////////////////////////////////////////////////////\r
58     /// Construct the view from its center and half-size\r
59     ///\r
60     /// \param Center :   Center of the view\r
61     /// \param HalfSize : Half-size of the view (from center to corner)\r
62     ///\r
63     ////////////////////////////////////////////////////////////\r
64     View(const sf::Vector2f& Center, const sf::Vector2f& HalfSize);\r
65 \r
66     ////////////////////////////////////////////////////////////\r
67     /// Change the center of the view (take 2 values)\r
68     ///\r
69     /// \param X : X coordinate of the new center\r
70     /// \param Y : Y coordinate of the new center\r
71     ///\r
72     ////////////////////////////////////////////////////////////\r
73     void SetCenter(float X, float Y);\r
74 \r
75     ////////////////////////////////////////////////////////////\r
76     /// Change the center of the view (take a vector)\r
77     ///\r
78     /// \param Center : New center\r
79     ///\r
80     ////////////////////////////////////////////////////////////\r
81     void SetCenter(const sf::Vector2f& Center);\r
82 \r
83     ////////////////////////////////////////////////////////////\r
84     /// Change the half-size of the view (take 2 values)\r
85     ///\r
86     /// \param HalfWidth :  New half-width\r
87     /// \param HalfHeight : New half-height\r
88     ///\r
89     ////////////////////////////////////////////////////////////\r
90     void SetHalfSize(float HalfWidth, float HalfHeight);\r
91 \r
92     ////////////////////////////////////////////////////////////\r
93     /// Change the half-size of the view (take a vector)\r
94     ///\r
95     /// \param HalfSize : New half-size\r
96     ///\r
97     ////////////////////////////////////////////////////////////\r
98     void SetHalfSize(const sf::Vector2f& HalfSize);\r
99 \r
100     ////////////////////////////////////////////////////////////\r
101     /// Rebuild the view from a rectangle\r
102     ///\r
103     /// \param ViewRect : Rectangle defining the position and size of the view\r
104     ///\r
105     ////////////////////////////////////////////////////////////\r
106     void SetFromRect(const FloatRect& ViewRect);\r
107 \r
108     ////////////////////////////////////////////////////////////\r
109     /// Get the center of the view\r
110     ///\r
111     /// \return Center of the view\r
112     ///\r
113     ////////////////////////////////////////////////////////////\r
114     const sf::Vector2f& GetCenter() const;\r
115 \r
116     ////////////////////////////////////////////////////////////\r
117     /// Get the half-size of the view\r
118     ///\r
119     /// \return Half-size of the view\r
120     ///\r
121     ////////////////////////////////////////////////////////////\r
122     const sf::Vector2f& GetHalfSize() const;\r
123 \r
124     ////////////////////////////////////////////////////////////\r
125     /// Get the bounding rectangle of the view\r
126     ///\r
127     /// \return Bounding rectangle of the view\r
128     ///\r
129     ////////////////////////////////////////////////////////////\r
130     const sf::FloatRect& GetRect() const;\r
131 \r
132     ////////////////////////////////////////////////////////////\r
133     /// Move the view (take 2 values)\r
134     ///\r
135     /// \param OffsetX : Offset to move the view, on X axis\r
136     /// \param OffsetY : Offset to move the view, on Y axis\r
137     ///\r
138     ////////////////////////////////////////////////////////////\r
139     void Move(float OffsetX, float OffsetY);\r
140 \r
141     ////////////////////////////////////////////////////////////\r
142     /// Move the view (take a vector)\r
143     ///\r
144     /// \param Offset : Offset to move the view\r
145     ///\r
146     ////////////////////////////////////////////////////////////\r
147     void Move(const sf::Vector2f& Offset);\r
148 \r
149     ////////////////////////////////////////////////////////////\r
150     /// Resize the view rectangle to simulate a zoom / unzoom effect\r
151     ///\r
152     /// \param Factor : Zoom factor to apply, relative to the current zoom\r
153     ///\r
154     ////////////////////////////////////////////////////////////\r
155     void Zoom(float Factor);\r
156 \r
157 private :\r
158 \r
159     friend class RenderTarget;\r
160 \r
161     ////////////////////////////////////////////////////////////\r
162     /// Get the projection matrix of the view\r
163     ///\r
164     /// \return Projection matrix containing the view settings\r
165     ///\r
166     ////////////////////////////////////////////////////////////\r
167     const Matrix3& GetMatrix() const;\r
168 \r
169     ////////////////////////////////////////////////////////////\r
170     /// Recompute the view rectangle and the projection matrix\r
171     ///\r
172     ////////////////////////////////////////////////////////////\r
173     void RecomputeMatrix();\r
174 \r
175     ////////////////////////////////////////////////////////////\r
176     // Member data\r
177     ////////////////////////////////////////////////////////////\r
178     sf::Vector2f myCenter;     ///< Center of the view\r
179     sf::Vector2f myHalfSize;   ///< Half-size of the view\r
180     FloatRect    myRect;       ///< Rectangle defining the bounds of the view\r
181     Matrix3      myMatrix;     ///< Precomputed projection matrix corresponding to the view\r
182     bool         myNeedUpdate; ///< Internal state telling if the matrix needs to be updated\r
183 };\r
184 \r
185 } // namespace sf\r
186 \r
187 \r
188 #endif // SFML_VIEW_HPP\r