28 #include <SFML/Graphics/RenderWindow.hpp>
29 #include <SFML/Graphics/Drawable.hpp>
30 #include <SFML/Graphics/Image.hpp>
31 #include <SFML/Graphics/GraphicsContext.hpp>
51 Create(Mode, Title, WindowStyle, Params);
76 bool RenderWindow::Activate(
bool Active)
110 const unsigned int Width =
GetWidth();
117 priv::GraphicsContext Ctx;
120 std::vector<Uint8> Pixels(Width * Height * 4);
121 Uint8* PixelsPtr = &Pixels[0];
122 GLCheck(glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, PixelsPtr));
125 unsigned int Pitch = Width * 4;
126 for (
unsigned int y = 0; y < Height / 2; ++y)
127 std::swap_ranges(PixelsPtr + y * Pitch, PixelsPtr + (y + 1) * Pitch, PixelsPtr + (Height - y - 1) * Pitch);
130 return Image(Width, Height, PixelsPtr);
154 Top + WindowY * (Bottom - Top) /
GetHeight());
161 void RenderWindow::OnCreate()
virtual unsigned int GetWidth() const
Get the width of the rendering region of the window.
This class defines a view (position, size, etc.) ; you can consider it as a 2D camera.
Structure defining the creation settings of windows.
unsigned int GetWidth() const
Get the width of the rendering region of the window.
T x
X coordinate of the vector.
Image Capture() const
Save the content of the window to an image.
sf::Vector2f ConvertCoords(unsigned int WindowX, unsigned int WindowY, const View *TargetView=NULL) const
Convert a point in window coordinates into view coordinates.
RenderWindow()
Default constructor.
const sf::Vector2f & GetCenter() const
Get the center of the view.
const View & GetView() const
Get the current view.
VideoMode defines a video mode (width, height, bpp, frequency) and provides static functions for gett...
const sf::Vector2f & GetHalfSize() const
Get the half-size of the view.
Image is the low-level class for loading and manipulating images.
bool SetActive(bool Active=true) const
Activate of deactivate the window as the current target for rendering.
static const Color White
White predefined color.
unsigned int GetHeight() const
Get the height of the rendering region of the window.
void Initialize()
Called by the derived class when it's ready to be initialized.
T y
Y coordinate of the vector.
void Create(VideoMode Mode, const std::string &Title, unsigned long WindowStyle=Style::Resize|Style::Close, const WindowSettings &Params=WindowSettings())
Create (or recreate) the window.
virtual ~RenderWindow()
Destructor.
virtual unsigned int GetHeight() const
Get the height of the rendering region of the window.