Window/Window.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_WINDOW_HPP
26 #define CPP3DS_WINDOW_HPP
27 
29 // Headers
31 #include <cpp3ds/System/Clock.hpp>
32 #include <cpp3ds/System/Vector2.hpp>
33 #include <cpp3ds/System/NonCopyable.hpp>
34 #include <cpp3ds/System/String.hpp>
35 #include <cpp3ds/Graphics/RenderTexture.hpp>
36 
37 
38 namespace cpp3ds
39 {
40 
41 class Event;
42 
48 {
49 public :
50 
58  Window();
59 
66  virtual ~Window();
67 
80  void create(const ContextSettings& settings = ContextSettings());
81 
92  void close();
93 
104  bool isOpen() const;
105 
117  const ContextSettings& getSettings() const;
118 
130  virtual Vector2u getSize() const;
131 
145  void setVerticalSyncEnabled(bool enabled);
146 
162  void setFramerateLimit(unsigned int limit);
163 
179  bool setActive(bool active = true) const;
180 
189  void display();
190 
205  Image capture() const;
206 
207 private:
208 
217  virtual bool activate(bool active);
218 
219 protected:
220 
225  void initialize();
226 
228  // Member data
230  priv::GlContext* m_context;
234 };
235 
236 }
237 
238 
239 #endif
240 
241 
Window that serves as a target for OpenGL rendering.
Vector2u m_size
Current size of the window.
void close()
Close the window and destroy all the attached resources.
void create(const ContextSettings &settings=ContextSettings())
Create (or recreate) the window.
priv::GlContext * m_context
Platform-specific implementation of the OpenGL context.
Represents a time value.
Definition: Time.hpp:37
bool setActive(bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
void display()
Display on screen what has been rendered to the window so far.
Image capture() const
Copy the current contents of the window to an image.
Clock m_clock
Clock for measuring the elapsed time between frames.
virtual Vector2u getSize() const
Get the size of the rendering region of the window.
Utility class that measures the elapsed time.
Definition: Clock.hpp:42
void initialize()
Perform some common internal initializations.
Class for loading, manipulating and saving images.
Definition: Image.hpp:45
Base class for all render targets (window, texture, ...)
virtual ~Window()
Destructor.
void setVerticalSyncEnabled(bool enabled)
Enable or disable vertical synchronization.
Time m_frameTimeLimit
Current framerate limit.
bool isOpen() const
Tell whether or not the window is open.
const ContextSettings & getSettings() const
Get the settings of the OpenGL context of the window.
Window()
Default constructor.
void setFramerateLimit(unsigned int limit)
Limit the framerate to a maximum fixed frequency.
Structure defining the settings of the OpenGL context attached to a window.
Base class for classes that require an OpenGL context.
Definition: GlResource.hpp:39