mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Use sf::Vector2<T>
for numeric parameter pairs
This commit is contained in:
parent
488b139ea7
commit
0785093ebc
@ -87,8 +87,8 @@ int main(int argc, char *argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
sf::Sprite image(texture);
|
sf::Sprite image(texture);
|
||||||
image.setPosition({screen.width / 2.f, screen.height / 2.f});
|
image.setPosition(sf::Vector2f(screen.size) / 2.f);
|
||||||
image.setOrigin({texture.getSize().x / 2.f, texture.getSize().y / 2.f});
|
image.setOrigin(sf::Vector2f(texture.getSize()) / 2.f);
|
||||||
|
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("tuffy.ttf"))
|
if (!font.loadFromFile("tuffy.ttf"))
|
||||||
@ -123,8 +123,8 @@ int main(int argc, char *argv[])
|
|||||||
window.close();
|
window.close();
|
||||||
break;
|
break;
|
||||||
case sf::Event::Resized:
|
case sf::Event::Resized:
|
||||||
view.setSize(event.size.width, event.size.height);
|
view.setSize(sf::Vector2f(event.size.width, event.size.height));
|
||||||
view.setCenter({event.size.width / 2.f, event.size.height / 2.f});
|
view.setCenter(sf::Vector2f(event.size.width, event.size.height) / 2.f);
|
||||||
window.setView(view);
|
window.setView(view);
|
||||||
break;
|
break;
|
||||||
case sf::Event::LostFocus:
|
case sf::Event::LostFocus:
|
||||||
|
@ -87,7 +87,7 @@ void generateTerrain(sf::Vertex* vertexBuffer);
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "SFML Island",
|
sf::RenderWindow window(sf::VideoMode({windowWidth, windowHeight}), "SFML Island",
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
sf::Style::Titlebar | sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode(400, 775), "Joystick", sf::Style::Close);
|
sf::RenderWindow window(sf::VideoMode({400, 775}), "Joystick", sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
// Load the text font
|
// Load the text font
|
||||||
|
@ -45,7 +45,7 @@ int main()
|
|||||||
contextSettings.sRgbCapable = sRgb;
|
contextSettings.sRgbCapable = sRgb;
|
||||||
|
|
||||||
// Create the main window
|
// Create the main window
|
||||||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
|
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
// Create a sprite for the background
|
// Create a sprite for the background
|
||||||
|
@ -192,7 +192,7 @@ public:
|
|||||||
bool onLoad() override
|
bool onLoad() override
|
||||||
{
|
{
|
||||||
// Create the off-screen surface
|
// Create the off-screen surface
|
||||||
if (!m_surface.create(800, 600))
|
if (!m_surface.create({800, 600}))
|
||||||
return false;
|
return false;
|
||||||
m_surface.setSmooth(true);
|
m_surface.setSmooth(true);
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ private:
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the main window
|
// Create the main window
|
||||||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader",
|
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML Shader",
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
sf::Style::Titlebar | sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ int main()
|
|||||||
float ballRadius = 10.f;
|
float ballRadius = 10.f;
|
||||||
|
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode(static_cast<unsigned int>(gameWidth), static_cast<unsigned int>(gameHeight), 32), "SFML Tennis",
|
sf::RenderWindow window(sf::VideoMode({static_cast<unsigned int>(gameWidth), static_cast<unsigned int>(gameHeight)}, 32), "SFML Tennis",
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
sf::Style::Titlebar | sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ int main()
|
|||||||
if (event.type == sf::Event::Resized)
|
if (event.type == sf::Event::Resized)
|
||||||
{
|
{
|
||||||
sf::View view;
|
sf::View view;
|
||||||
view.setSize(gameWidth, gameHeight);
|
view.setSize({gameWidth, gameHeight});
|
||||||
view.setCenter({gameWidth / 2.f, gameHeight / 2.f});
|
view.setCenter({gameWidth / 2.f, gameHeight / 2.f});
|
||||||
window.setView(view);
|
window.setView(view);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ class VulkanExample
|
|||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
VulkanExample() :
|
VulkanExample() :
|
||||||
window(sf::VideoMode(800, 600), "SFML window with Vulkan", sf::Style::Default),
|
window(sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default),
|
||||||
vulkanAvailable(sf::Vulkan::isAvailable()),
|
vulkanAvailable(sf::Vulkan::isAvailable()),
|
||||||
maxFramesInFlight(2),
|
maxFramesInFlight(2),
|
||||||
currentFrame(0),
|
currentFrame(0),
|
||||||
|
@ -27,7 +27,7 @@ int main()
|
|||||||
contextSettings.depthBits = 24;
|
contextSettings.depthBits = 24;
|
||||||
|
|
||||||
// Create the main window
|
// Create the main window
|
||||||
sf::Window window(sf::VideoMode(640, 480), "SFML window with OpenGL", sf::Style::Default, contextSettings);
|
sf::Window window(sf::VideoMode({640, 480}), "SFML window with OpenGL", sf::Style::Default, contextSettings);
|
||||||
|
|
||||||
// Make it the active window for OpenGL calls
|
// Make it the active window for OpenGL calls
|
||||||
if (!window.setActive())
|
if (!window.setActive())
|
||||||
|
@ -395,14 +395,13 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Find a suitable rectangle within the texture for a glyph
|
/// \brief Find a suitable rectangle within the texture for a glyph
|
||||||
///
|
///
|
||||||
/// \param page Page of glyphs to search in
|
/// \param page Page of glyphs to search in
|
||||||
/// \param width Width of the rectangle
|
/// \param size Width and height of the rectangle
|
||||||
/// \param height Height of the rectangle
|
|
||||||
///
|
///
|
||||||
/// \return Found rectangle within the texture
|
/// \return Found rectangle within the texture
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
IntRect findGlyphRect(Page& page, unsigned int width, unsigned int height) const;
|
IntRect findGlyphRect(Page& page, const Vector2u& size) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Make sure that the given size is the current one
|
/// \brief Make sure that the given size is the current one
|
||||||
|
@ -89,12 +89,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the image and fill it with a unique color
|
/// \brief Create the image and fill it with a unique color
|
||||||
///
|
///
|
||||||
/// \param width Width of the image
|
/// \param size Width and height of the image
|
||||||
/// \param height Height of the image
|
/// \param color Fill color
|
||||||
/// \param color Fill color
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
|
void create(const Vector2u& size, const Color& color = Color(0, 0, 0));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the image from an array of pixels
|
/// \brief Create the image from an array of pixels
|
||||||
@ -104,12 +103,11 @@ public:
|
|||||||
/// an undefined behavior.
|
/// an undefined behavior.
|
||||||
/// If \a pixels is null, an empty image is created.
|
/// If \a pixels is null, an empty image is created.
|
||||||
///
|
///
|
||||||
/// \param width Width of the image
|
/// \param size Width and height of the image
|
||||||
/// \param height Height of the image
|
|
||||||
/// \param pixels Array of pixels to copy to the image
|
/// \param pixels Array of pixels to copy to the image
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void create(unsigned int width, unsigned int height, const Uint8* pixels);
|
void create(const Vector2u& size, const Uint8* pixels);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the image from a file on disk
|
/// \brief Load the image from a file on disk
|
||||||
@ -237,13 +235,12 @@ public:
|
|||||||
/// details on the \b over operator.
|
/// details on the \b over operator.
|
||||||
///
|
///
|
||||||
/// \param source Source image to copy
|
/// \param source Source image to copy
|
||||||
/// \param destX X coordinate of the destination position
|
/// \param dest Coordinates of the destination position
|
||||||
/// \param destY Y coordinate of the destination position
|
|
||||||
/// \param sourceRect Sub-rectangle of the source image to copy
|
/// \param sourceRect Sub-rectangle of the source image to copy
|
||||||
/// \param applyAlpha Should the copy take into account the source transparency?
|
/// \param applyAlpha Should the copy take into account the source transparency?
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect({0, 0}, {0, 0}), bool applyAlpha = false);
|
void copy(const Image& source, const Vector2u& dest, const IntRect& sourceRect = IntRect({0, 0}, {0, 0}), bool applyAlpha = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the color of a pixel
|
/// \brief Change the color of a pixel
|
||||||
@ -252,14 +249,13 @@ public:
|
|||||||
/// coordinates, using out-of-range values will result in
|
/// coordinates, using out-of-range values will result in
|
||||||
/// an undefined behavior.
|
/// an undefined behavior.
|
||||||
///
|
///
|
||||||
/// \param x X coordinate of pixel to change
|
/// \param coords Coordinates of pixel to change
|
||||||
/// \param y Y coordinate of pixel to change
|
/// \param color New color of the pixel
|
||||||
/// \param color New color of the pixel
|
|
||||||
///
|
///
|
||||||
/// \see getPixel
|
/// \see getPixel
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setPixel(unsigned int x, unsigned int y, const Color& color);
|
void setPixel(const Vector2u& coords, const Color& color);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the color of a pixel
|
/// \brief Get the color of a pixel
|
||||||
@ -268,15 +264,14 @@ public:
|
|||||||
/// coordinates, using out-of-range values will result in
|
/// coordinates, using out-of-range values will result in
|
||||||
/// an undefined behavior.
|
/// an undefined behavior.
|
||||||
///
|
///
|
||||||
/// \param x X coordinate of pixel to get
|
/// \param coords Coordinates of pixel to change
|
||||||
/// \param y Y coordinate of pixel to get
|
|
||||||
///
|
///
|
||||||
/// \return Color of the pixel at coordinates (x, y)
|
/// \return Color of the pixel at given coordinates
|
||||||
///
|
///
|
||||||
/// \see setPixel
|
/// \see setPixel
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Color getPixel(unsigned int x, unsigned int y) const;
|
Color getPixel(const Vector2u& coords) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get a read-only pointer to the array of pixels
|
/// \brief Get a read-only pointer to the array of pixels
|
||||||
|
@ -78,14 +78,13 @@ public:
|
|||||||
/// requires a depth or stencil buffer. Otherwise it is unnecessary, and
|
/// requires a depth or stencil buffer. Otherwise it is unnecessary, and
|
||||||
/// you should leave this parameter at its default value.
|
/// you should leave this parameter at its default value.
|
||||||
///
|
///
|
||||||
/// \param width Width of the render-texture
|
/// \param size Width and height of the render-texture
|
||||||
/// \param height Height of the render-texture
|
|
||||||
/// \param settings Additional settings for the underlying OpenGL texture and context
|
/// \param settings Additional settings for the underlying OpenGL texture and context
|
||||||
///
|
///
|
||||||
/// \return True if creation has been successful
|
/// \return True if creation has been successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool create(unsigned int width, unsigned int height, const ContextSettings& settings = ContextSettings());
|
[[nodiscard]] bool create(const Vector2u& size, const ContextSettings& settings = ContextSettings());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the maximum anti-aliasing level supported by the system
|
/// \brief Get the maximum anti-aliasing level supported by the system
|
||||||
|
@ -91,13 +91,12 @@ public:
|
|||||||
///
|
///
|
||||||
/// If this function fails, the texture is left unchanged.
|
/// If this function fails, the texture is left unchanged.
|
||||||
///
|
///
|
||||||
/// \param width Width of the texture
|
/// \param size Width and height of the texture
|
||||||
/// \param height Height of the texture
|
|
||||||
///
|
///
|
||||||
/// \return True if creation was successful
|
/// \return True if creation was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool create(unsigned int width, unsigned int height);
|
[[nodiscard]] bool create(const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from a file on disk
|
/// \brief Load the texture from a file on disk
|
||||||
@ -272,13 +271,11 @@ public:
|
|||||||
/// texture was not previously created.
|
/// texture was not previously created.
|
||||||
///
|
///
|
||||||
/// \param pixels Array of pixels to copy to the texture
|
/// \param pixels Array of pixels to copy to the texture
|
||||||
/// \param width Width of the pixel region contained in \a pixels
|
/// \param size Width and height of the pixel region contained in \a pixels
|
||||||
/// \param height Height of the pixel region contained in \a pixels
|
/// \param dest Coordinates of the destination position
|
||||||
/// \param x X offset in the texture where to copy the source pixels
|
|
||||||
/// \param y Y offset in the texture where to copy the source pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
|
void update(const Uint8* pixels, const Vector2u& size, const Vector2u& dest);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Update a part of this texture from another texture
|
/// \brief Update a part of this texture from another texture
|
||||||
@ -304,18 +301,17 @@ public:
|
|||||||
/// \brief Update a part of this texture from another texture
|
/// \brief Update a part of this texture from another texture
|
||||||
///
|
///
|
||||||
/// No additional check is performed on the size of the texture,
|
/// No additional check is performed on the size of the texture,
|
||||||
/// passing an invalid combination of texture size and offset
|
/// passing an invalid combination of texture size and destination
|
||||||
/// will lead to an undefined behavior.
|
/// will lead to an undefined behavior.
|
||||||
///
|
///
|
||||||
/// This function does nothing if either texture was not
|
/// This function does nothing if either texture was not
|
||||||
/// previously created.
|
/// previously created.
|
||||||
///
|
///
|
||||||
/// \param texture Source texture to copy to this texture
|
/// \param texture Source texture to copy to this texture
|
||||||
/// \param x X offset in this texture where to copy the source texture
|
/// \param dest Coordinates of the destination position
|
||||||
/// \param y Y offset in this texture where to copy the source texture
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void update(const Texture& texture, unsigned int x, unsigned int y);
|
void update(const Texture& texture, const Vector2u& dest);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Update the texture from an image
|
/// \brief Update the texture from an image
|
||||||
@ -341,18 +337,17 @@ public:
|
|||||||
/// \brief Update a part of the texture from an image
|
/// \brief Update a part of the texture from an image
|
||||||
///
|
///
|
||||||
/// No additional check is performed on the size of the image,
|
/// No additional check is performed on the size of the image,
|
||||||
/// passing an invalid combination of image size and offset
|
/// passing an invalid combination of image size and destination
|
||||||
/// will lead to an undefined behavior.
|
/// will lead to an undefined behavior.
|
||||||
///
|
///
|
||||||
/// This function does nothing if the texture was not
|
/// This function does nothing if the texture was not
|
||||||
/// previously created.
|
/// previously created.
|
||||||
///
|
///
|
||||||
/// \param image Image to copy to the texture
|
/// \param image Image to copy to the texture
|
||||||
/// \param x X offset in the texture where to copy the source image
|
/// \param dest Coordinates of the destination position
|
||||||
/// \param y Y offset in the texture where to copy the source image
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void update(const Image& image, unsigned int x, unsigned int y);
|
void update(const Image& image, const Vector2u& dest);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Update the texture from the contents of a window
|
/// \brief Update the texture from the contents of a window
|
||||||
@ -378,18 +373,17 @@ public:
|
|||||||
/// \brief Update a part of the texture from the contents of a window
|
/// \brief Update a part of the texture from the contents of a window
|
||||||
///
|
///
|
||||||
/// No additional check is performed on the size of the window,
|
/// No additional check is performed on the size of the window,
|
||||||
/// passing an invalid combination of window size and offset
|
/// passing an invalid combination of window size and destination
|
||||||
/// will lead to an undefined behavior.
|
/// will lead to an undefined behavior.
|
||||||
///
|
///
|
||||||
/// This function does nothing if either the texture or the window
|
/// This function does nothing if either the texture or the window
|
||||||
/// was not previously created.
|
/// was not previously created.
|
||||||
///
|
///
|
||||||
/// \param window Window to copy to the texture
|
/// \param window Window to copy to the texture
|
||||||
/// \param x X offset in the texture where to copy the source window
|
/// \param dest Coordinates of the destination position
|
||||||
/// \param y Y offset in the texture where to copy the source window
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void update(const Window& window, unsigned int x, unsigned int y);
|
void update(const Window& window, const Vector2u& dest);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enable or disable the smooth filter
|
/// \brief Enable or disable the smooth filter
|
||||||
|
@ -80,17 +80,6 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setCenter(const Vector2f& center);
|
void setCenter(const Vector2f& center);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/// \brief Set the size of the view
|
|
||||||
///
|
|
||||||
/// \param width New width of the view
|
|
||||||
/// \param height New height of the view
|
|
||||||
///
|
|
||||||
/// \see setCenter, getCenter
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void setSize(float width, float height);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Set the size of the view
|
/// \brief Set the size of the view
|
||||||
///
|
///
|
||||||
@ -182,17 +171,6 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const FloatRect& getViewport() const;
|
const FloatRect& getViewport() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/// \brief Move the view relatively to its current position
|
|
||||||
///
|
|
||||||
/// \param offsetX X coordinate of the move offset
|
|
||||||
/// \param offsetY Y coordinate of the move offset
|
|
||||||
///
|
|
||||||
/// \see setCenter, rotate, zoom
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void move(float offsetX, float offsetY);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Move the view relatively to its current position
|
/// \brief Move the view relatively to its current position
|
||||||
///
|
///
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/Export.hpp>
|
#include <SFML/Window/Export.hpp>
|
||||||
#include <SFML/Window/GlResource.hpp>
|
#include <SFML/Window/GlResource.hpp>
|
||||||
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ public:
|
|||||||
/// \param height Back buffer height
|
/// \param height Back buffer height
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Context(const ContextSettings& settings, unsigned int width, unsigned int height);
|
Context(const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/Export.hpp>
|
#include <SFML/Window/Export.hpp>
|
||||||
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -53,12 +54,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the video mode with its attributes
|
/// \brief Construct the video mode with its attributes
|
||||||
///
|
///
|
||||||
/// \param modeWidth Width in pixels
|
/// \param modeSize Width and height in pixels
|
||||||
/// \param modeHeight Height in pixels
|
|
||||||
/// \param modeBitsPerPixel Pixel depths in bits per pixel
|
/// \param modeBitsPerPixel Pixel depths in bits per pixel
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel = 32);
|
explicit VideoMode(const Vector2u& modeSize, unsigned int modeBitsPerPixel = 32);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the current desktop video mode
|
/// \brief Get the current desktop video mode
|
||||||
@ -99,8 +99,7 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
unsigned int width; //!< Video mode width, in pixels
|
Vector2u size; //!< Video mode width and height, in pixels
|
||||||
unsigned int height; //!< Video mode height, in pixels
|
|
||||||
unsigned int bitsPerPixel; //!< Video mode pixel depth, in bits per pixels
|
unsigned int bitsPerPixel; //!< Video mode pixel depth, in bits per pixels
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -273,8 +273,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// The OS default icon is used by default.
|
/// The OS default icon is used by default.
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the array of pixels in memory. The
|
/// \param pixels Pointer to the array of pixels in memory. The
|
||||||
/// pixels are copied, so you need not keep the
|
/// pixels are copied, so you need not keep the
|
||||||
/// source alive after calling this function.
|
/// source alive after calling this function.
|
||||||
@ -282,7 +281,7 @@ public:
|
|||||||
/// \see setTitle
|
/// \see setTitle
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
|
void setIcon(const Vector2u& size, const Uint8* pixels);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -630,7 +630,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
Page& page = loadPage(characterSize);
|
Page& page = loadPage(characterSize);
|
||||||
|
|
||||||
// Find a good position for the new glyph into the texture
|
// Find a good position for the new glyph into the texture
|
||||||
glyph.textureRect = findGlyphRect(page, width, height);
|
glyph.textureRect = findGlyphRect(page, {width, height});
|
||||||
|
|
||||||
// Make sure the texture data is positioned in the center
|
// Make sure the texture data is positioned in the center
|
||||||
// of the allocated texture rectangle
|
// of the allocated texture rectangle
|
||||||
@ -695,7 +695,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
unsigned int y = static_cast<unsigned int>(glyph.textureRect.top) - padding;
|
unsigned int y = static_cast<unsigned int>(glyph.textureRect.top) - padding;
|
||||||
unsigned int w = static_cast<unsigned int>(glyph.textureRect.width) + 2 * padding;
|
unsigned int w = static_cast<unsigned int>(glyph.textureRect.width) + 2 * padding;
|
||||||
unsigned int h = static_cast<unsigned int>(glyph.textureRect.height) + 2 * padding;
|
unsigned int h = static_cast<unsigned int>(glyph.textureRect.height) + 2 * padding;
|
||||||
page.texture.update(m_pixelBuffer.data(), w, h, x, y);
|
page.texture.update(m_pixelBuffer.data(), {w, h}, {x, y});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the FT glyph
|
// Delete the FT glyph
|
||||||
@ -707,21 +707,21 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height) const
|
IntRect Font::findGlyphRect(Page& page, const Vector2u& size) const
|
||||||
{
|
{
|
||||||
// Find the line that fits well the glyph
|
// Find the line that fits well the glyph
|
||||||
Row* row = nullptr;
|
Row* row = nullptr;
|
||||||
float bestRatio = 0;
|
float bestRatio = 0;
|
||||||
for (auto it = page.rows.begin(); it != page.rows.end() && !row; ++it)
|
for (auto it = page.rows.begin(); it != page.rows.end() && !row; ++it)
|
||||||
{
|
{
|
||||||
float ratio = static_cast<float>(height) / static_cast<float>(it->height);
|
float ratio = static_cast<float>(size.y) / static_cast<float>(it->height);
|
||||||
|
|
||||||
// Ignore rows that are either too small or too high
|
// Ignore rows that are either too small or too high
|
||||||
if ((ratio < 0.7f) || (ratio > 1.f))
|
if ((ratio < 0.7f) || (ratio > 1.f))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if there's enough horizontal space left in the row
|
// Check if there's enough horizontal space left in the row
|
||||||
if (width > page.texture.getSize().x - it->width)
|
if (size.x > page.texture.getSize().x - it->width)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Make sure that this new row is the best found so far
|
// Make sure that this new row is the best found so far
|
||||||
@ -736,17 +736,16 @@ IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height)
|
|||||||
// If we didn't find a matching row, create a new one (10% taller than the glyph)
|
// If we didn't find a matching row, create a new one (10% taller than the glyph)
|
||||||
if (!row)
|
if (!row)
|
||||||
{
|
{
|
||||||
unsigned int rowHeight = height + height / 10;
|
unsigned int rowHeight = size.y + size.y / 10;
|
||||||
while ((page.nextRow + rowHeight >= page.texture.getSize().y) || (width >= page.texture.getSize().x))
|
while ((page.nextRow + rowHeight >= page.texture.getSize().y) || (size.x >= page.texture.getSize().x))
|
||||||
{
|
{
|
||||||
// Not enough space: resize the texture if possible
|
// Not enough space: resize the texture if possible
|
||||||
unsigned int textureWidth = page.texture.getSize().x;
|
Vector2u textureSize = page.texture.getSize();
|
||||||
unsigned int textureHeight = page.texture.getSize().y;
|
if ((textureSize.x * 2 <= Texture::getMaximumSize()) && (textureSize.y * 2 <= Texture::getMaximumSize()))
|
||||||
if ((textureWidth * 2 <= Texture::getMaximumSize()) && (textureHeight * 2 <= Texture::getMaximumSize()))
|
|
||||||
{
|
{
|
||||||
// Make the texture 2 times bigger
|
// Make the texture 2 times bigger
|
||||||
Texture newTexture;
|
Texture newTexture;
|
||||||
if (!newTexture.create(textureWidth * 2, textureHeight * 2))
|
if (!newTexture.create(textureSize * 2u))
|
||||||
{
|
{
|
||||||
err() << "Failed to create new page texture" << std::endl;
|
err() << "Failed to create new page texture" << std::endl;
|
||||||
return IntRect({0, 0}, {2, 2});
|
return IntRect({0, 0}, {2, 2});
|
||||||
@ -771,10 +770,10 @@ IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the glyph's rectangle on the selected row
|
// Find the glyph's rectangle on the selected row
|
||||||
IntRect rect(Rect<unsigned int>({row->width, row->top}, {width, height}));
|
IntRect rect(Rect<unsigned int>({row->width, row->top}, size));
|
||||||
|
|
||||||
// Update the row informations
|
// Update the row informations
|
||||||
row->width += width;
|
row->width += size.x;
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@ -828,12 +827,12 @@ nextRow(3)
|
|||||||
{
|
{
|
||||||
// Make sure that the texture is initialized by default
|
// Make sure that the texture is initialized by default
|
||||||
sf::Image image;
|
sf::Image image;
|
||||||
image.create(128, 128, Color(255, 255, 255, 0));
|
image.create({128, 128}, Color(255, 255, 255, 0));
|
||||||
|
|
||||||
// Reserve a 2x2 white square for texturing underlines
|
// Reserve a 2x2 white square for texturing underlines
|
||||||
for (unsigned int x = 0; x < 2; ++x)
|
for (unsigned int x = 0; x < 2; ++x)
|
||||||
for (unsigned int y = 0; y < 2; ++y)
|
for (unsigned int y = 0; y < 2; ++y)
|
||||||
image.setPixel(x, y, Color(255, 255, 255, 255));
|
image.setPixel({x, y}, Color(255, 255, 255, 255));
|
||||||
|
|
||||||
// Create the texture
|
// Create the texture
|
||||||
if (!texture.loadFromImage(image))
|
if (!texture.loadFromImage(image))
|
||||||
|
@ -70,12 +70,12 @@ Image& Image::operator=(Image&&) noexcept = default;
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Image::create(unsigned int width, unsigned int height, const Color& color)
|
void Image::create(const Vector2u& size, const Color& color)
|
||||||
{
|
{
|
||||||
if (width && height)
|
if (size.x && size.y)
|
||||||
{
|
{
|
||||||
// Create a new pixel buffer first for exception safety's sake
|
// Create a new pixel buffer first for exception safety's sake
|
||||||
std::vector<Uint8> newPixels(static_cast<std::size_t>(width) * static_cast<std::size_t>(height) * 4);
|
std::vector<Uint8> newPixels(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4);
|
||||||
|
|
||||||
// Fill it with the specified color
|
// Fill it with the specified color
|
||||||
Uint8* ptr = newPixels.data();
|
Uint8* ptr = newPixels.data();
|
||||||
@ -92,8 +92,7 @@ void Image::create(unsigned int width, unsigned int height, const Color& color)
|
|||||||
m_pixels.swap(newPixels);
|
m_pixels.swap(newPixels);
|
||||||
|
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size.x = width;
|
m_size = size;
|
||||||
m_size.y = height;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -108,19 +107,18 @@ void Image::create(unsigned int width, unsigned int height, const Color& color)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Image::create(unsigned int width, unsigned int height, const Uint8* pixels)
|
void Image::create(const Vector2u& size, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
if (pixels && width && height)
|
if (pixels && size.x && size.y)
|
||||||
{
|
{
|
||||||
// Create a new pixel buffer first for exception safety's sake
|
// Create a new pixel buffer first for exception safety's sake
|
||||||
std::vector<Uint8> newPixels(pixels, pixels + width * height * 4);
|
std::vector<Uint8> newPixels(pixels, pixels + size.x * size.y * 4);
|
||||||
|
|
||||||
// Commit the new pixel buffer
|
// Commit the new pixel buffer
|
||||||
m_pixels.swap(newPixels);
|
m_pixels.swap(newPixels);
|
||||||
|
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size.x = width;
|
m_size = size;
|
||||||
m_size.y = height;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -204,7 +202,7 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Image::copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect, bool applyAlpha)
|
void Image::copy(const Image& source, const Vector2u& dest, const IntRect& sourceRect, bool applyAlpha)
|
||||||
{
|
{
|
||||||
// Make sure that both images are valid
|
// Make sure that both images are valid
|
||||||
if ((source.m_size.x == 0) || (source.m_size.y == 0) || (m_size.x == 0) || (m_size.y == 0))
|
if ((source.m_size.x == 0) || (source.m_size.y == 0) || (m_size.x == 0) || (m_size.y == 0))
|
||||||
@ -230,8 +228,8 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||||||
// Then find the valid bounds of the destination rectangle
|
// Then find the valid bounds of the destination rectangle
|
||||||
auto width = static_cast<unsigned int>(srcRect.width);
|
auto width = static_cast<unsigned int>(srcRect.width);
|
||||||
auto height = static_cast<unsigned int>(srcRect.height);
|
auto height = static_cast<unsigned int>(srcRect.height);
|
||||||
if (destX + width > m_size.x) width = m_size.x - destX;
|
if (dest.x + width > m_size.x) width = m_size.x - dest.x;
|
||||||
if (destY + height > m_size.y) height = m_size.y - destY;
|
if (dest.y + height > m_size.y) height = m_size.y - dest.y;
|
||||||
|
|
||||||
// Make sure the destination area is valid
|
// Make sure the destination area is valid
|
||||||
if ((width <= 0) || (height <= 0))
|
if ((width <= 0) || (height <= 0))
|
||||||
@ -243,7 +241,7 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||||||
int srcStride = static_cast<int>(source.m_size.x) * 4;
|
int srcStride = static_cast<int>(source.m_size.x) * 4;
|
||||||
int dstStride = static_cast<int>(m_size.x) * 4;
|
int dstStride = static_cast<int>(m_size.x) * 4;
|
||||||
const Uint8* srcPixels = source.m_pixels.data() + (static_cast<unsigned int>(srcRect.left) + static_cast<unsigned int>(srcRect.top) * source.m_size.x) * 4;
|
const Uint8* srcPixels = source.m_pixels.data() + (static_cast<unsigned int>(srcRect.left) + static_cast<unsigned int>(srcRect.top) * source.m_size.x) * 4;
|
||||||
Uint8* dstPixels = m_pixels.data() + (destX + destY * m_size.x) * 4;
|
Uint8* dstPixels = m_pixels.data() + (dest.x + dest.y * m_size.x) * 4;
|
||||||
|
|
||||||
// Copy the pixels
|
// Copy the pixels
|
||||||
if (applyAlpha)
|
if (applyAlpha)
|
||||||
@ -290,9 +288,9 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Image::setPixel(unsigned int x, unsigned int y, const Color& color)
|
void Image::setPixel(const Vector2u& coords, const Color& color)
|
||||||
{
|
{
|
||||||
Uint8* pixel = &m_pixels[(x + y * m_size.x) * 4];
|
Uint8* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
||||||
*pixel++ = color.r;
|
*pixel++ = color.r;
|
||||||
*pixel++ = color.g;
|
*pixel++ = color.g;
|
||||||
*pixel++ = color.b;
|
*pixel++ = color.b;
|
||||||
@ -301,9 +299,9 @@ void Image::setPixel(unsigned int x, unsigned int y, const Color& color)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Color Image::getPixel(unsigned int x, unsigned int y) const
|
Color Image::getPixel(const Vector2u& coords) const
|
||||||
{
|
{
|
||||||
const Uint8* pixel = &m_pixels[(x + y * m_size.x) * 4];
|
const Uint8* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
||||||
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,13 +44,13 @@ RenderTexture::~RenderTexture() = default;
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderTexture::create(unsigned int width, unsigned int height, const ContextSettings& settings)
|
bool RenderTexture::create(const Vector2u& size, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
// Set texture to be in sRGB scale if requested
|
// Set texture to be in sRGB scale if requested
|
||||||
m_texture.setSrgb(settings.sRgbCapable);
|
m_texture.setSrgb(settings.sRgbCapable);
|
||||||
|
|
||||||
// Create the texture
|
// Create the texture
|
||||||
if (!m_texture.create(width, height))
|
if (!m_texture.create(size))
|
||||||
{
|
{
|
||||||
err() << "Impossible to create render texture (failed to create the target texture)" << std::endl;
|
err() << "Impossible to create render texture (failed to create the target texture)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -75,7 +75,7 @@ bool RenderTexture::create(unsigned int width, unsigned int height, const Contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the render texture
|
// Initialize the render texture
|
||||||
if (!m_impl->create(width, height, m_texture.m_texture, settings))
|
if (!m_impl->create(size, m_texture.m_texture, settings))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We can now initialize the render target part
|
// We can now initialize the render target part
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#include <SFML/System/Vector2.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -72,15 +73,14 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the render texture implementation
|
/// \brief Create the render texture implementation
|
||||||
///
|
///
|
||||||
/// \param width Width of the texture to render to
|
/// \param size Width and height of the texture to render to
|
||||||
/// \param height Height of the texture to render to
|
|
||||||
/// \param textureId OpenGL identifier of the target texture
|
/// \param textureId OpenGL identifier of the target texture
|
||||||
/// \param settings Context settings to create render-texture with
|
/// \param settings Context settings to create render-texture with
|
||||||
///
|
///
|
||||||
/// \return True if creation has been successful
|
/// \return True if creation has been successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual bool create(unsigned int width, unsigned int height, unsigned int textureId, const ContextSettings& settings) = 0;
|
virtual bool create(const Vector2u& size, unsigned int textureId, const ContextSettings& settings) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Activate or deactivate the render texture for rendering
|
/// \brief Activate or deactivate the render texture for rendering
|
||||||
|
@ -40,8 +40,7 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
RenderTextureImplDefault::RenderTextureImplDefault() :
|
RenderTextureImplDefault::RenderTextureImplDefault() :
|
||||||
m_context(),
|
m_context(),
|
||||||
m_width (0),
|
m_size (0, 0)
|
||||||
m_height (0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -62,14 +61,13 @@ unsigned int RenderTextureImplDefault::getMaximumAntialiasingLevel()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderTextureImplDefault::create(unsigned int width, unsigned int height, unsigned int, const ContextSettings& settings)
|
bool RenderTextureImplDefault::create(const Vector2u& size, unsigned int, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
// Store the dimensions
|
// Store the dimensions
|
||||||
m_width = width;
|
m_size = size;
|
||||||
m_height = height;
|
|
||||||
|
|
||||||
// Create the in-memory OpenGL context
|
// Create the in-memory OpenGL context
|
||||||
m_context = std::make_unique<Context>(settings, width, height);
|
m_context = std::make_unique<Context>(settings, size);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -97,7 +95,7 @@ void RenderTextureImplDefault::updateTexture(unsigned int textureId)
|
|||||||
|
|
||||||
// Copy the rendered pixels to the texture
|
// Copy the rendered pixels to the texture
|
||||||
glCheck(glBindTexture(GL_TEXTURE_2D, textureId));
|
glCheck(glBindTexture(GL_TEXTURE_2D, textureId));
|
||||||
glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, static_cast<GLsizei>(m_width), static_cast<GLsizei>(m_height)));
|
glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, static_cast<GLsizei>(m_size.x), static_cast<GLsizei>(m_size.y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -74,15 +74,14 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the render texture implementation
|
/// \brief Create the render texture implementation
|
||||||
///
|
///
|
||||||
/// \param width Width of the texture to render to
|
/// \param size Width and height of the texture to render to
|
||||||
/// \param height Height of the texture to render to
|
|
||||||
/// \param textureId OpenGL identifier of the target texture
|
/// \param textureId OpenGL identifier of the target texture
|
||||||
/// \param settings Context settings to create render-texture with
|
/// \param settings Context settings to create render-texture with
|
||||||
///
|
///
|
||||||
/// \return True if creation has been successful
|
/// \return True if creation has been successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool create(unsigned int width, unsigned int height, unsigned int textureId, const ContextSettings& settings) override;
|
bool create(const Vector2u& size, unsigned int textureId, const ContextSettings& settings) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Activate or deactivate the render texture for rendering
|
/// \brief Activate or deactivate the render texture for rendering
|
||||||
@ -117,8 +116,7 @@ private:
|
|||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<Context> m_context; //!< P-Buffer based context
|
std::unique_ptr<Context> m_context; //!< P-Buffer based context
|
||||||
unsigned int m_width; //!< Width of the P-Buffer
|
Vector2u m_size; //!< Width and height of the P-Buffer
|
||||||
unsigned int m_height; //!< Height of the P-Buffer
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -119,8 +119,7 @@ namespace priv
|
|||||||
RenderTextureImplFBO::RenderTextureImplFBO() :
|
RenderTextureImplFBO::RenderTextureImplFBO() :
|
||||||
m_depthStencilBuffer(0),
|
m_depthStencilBuffer(0),
|
||||||
m_colorBuffer (0),
|
m_colorBuffer (0),
|
||||||
m_width (0),
|
m_size (0, 0),
|
||||||
m_height (0),
|
|
||||||
m_context (),
|
m_context (),
|
||||||
m_textureId (0),
|
m_textureId (0),
|
||||||
m_multisample (false),
|
m_multisample (false),
|
||||||
@ -212,11 +211,10 @@ void RenderTextureImplFBO::unbind()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsigned int textureId, const ContextSettings& settings)
|
bool RenderTextureImplFBO::create(const Vector2u& size, unsigned int textureId, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
// Store the dimensions
|
// Store the dimensions
|
||||||
m_width = width;
|
m_size = size;
|
||||||
m_height = height;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
TransientContextLock lock;
|
TransientContextLock lock;
|
||||||
@ -268,7 +266,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
||||||
glCheck(GLEXT_glRenderbufferStorage(GLEXT_GL_RENDERBUFFER, GLEXT_GL_DEPTH24_STENCIL8, static_cast<GLsizei>(width), static_cast<GLsizei>(height)));
|
glCheck(GLEXT_glRenderbufferStorage(GLEXT_GL_RENDERBUFFER, GLEXT_GL_DEPTH24_STENCIL8, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y)));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -291,7 +289,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
||||||
glCheck(GLEXT_glRenderbufferStorage(GLEXT_GL_RENDERBUFFER, GLEXT_GL_DEPTH_COMPONENT, static_cast<GLsizei>(width), static_cast<GLsizei>(height)));
|
glCheck(GLEXT_glRenderbufferStorage(GLEXT_GL_RENDERBUFFER, GLEXT_GL_DEPTH_COMPONENT, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -309,7 +307,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_colorBuffer));
|
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_colorBuffer));
|
||||||
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), m_sRgb ? GL_SRGB8_ALPHA8_EXT : GL_RGBA, static_cast<GLsizei>(width), static_cast<GLsizei>(height)));
|
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), m_sRgb ? GL_SRGB8_ALPHA8_EXT : GL_RGBA, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y)));
|
||||||
|
|
||||||
// Create the multisample depth/stencil buffer if requested
|
// Create the multisample depth/stencil buffer if requested
|
||||||
if (settings.stencilBits)
|
if (settings.stencilBits)
|
||||||
@ -323,7 +321,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
||||||
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), GLEXT_GL_DEPTH24_STENCIL8, static_cast<GLsizei>(width), static_cast<GLsizei>(height)));
|
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), GLEXT_GL_DEPTH24_STENCIL8, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y)));
|
||||||
|
|
||||||
m_stencil = true;
|
m_stencil = true;
|
||||||
}
|
}
|
||||||
@ -338,7 +336,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthStencilBuffer));
|
||||||
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), GLEXT_GL_DEPTH_COMPONENT, static_cast<GLsizei>(width), static_cast<GLsizei>(height)));
|
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, static_cast<GLsizei>(settings.antialiasingLevel), GLEXT_GL_DEPTH_COMPONENT, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -592,7 +590,7 @@ void RenderTextureImplFBO::updateTexture(unsigned int)
|
|||||||
|
|
||||||
// In case of multisampling, make sure both FBOs
|
// In case of multisampling, make sure both FBOs
|
||||||
// are already available within the current context
|
// are already available within the current context
|
||||||
if (m_multisample && m_width && m_height && activate(true))
|
if (m_multisample && m_size.x && m_size.y && activate(true))
|
||||||
{
|
{
|
||||||
Uint64 contextId = Context::getActiveContextId();
|
Uint64 contextId = Context::getActiveContextId();
|
||||||
|
|
||||||
@ -605,7 +603,7 @@ void RenderTextureImplFBO::updateTexture(unsigned int)
|
|||||||
{
|
{
|
||||||
// Set up the blit target (draw framebuffer) and blit (from the read framebuffer, our multisample FBO)
|
// Set up the blit target (draw framebuffer) and blit (from the read framebuffer, our multisample FBO)
|
||||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, frameBufferIt->second));
|
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, frameBufferIt->second));
|
||||||
glCheck(GLEXT_glBlitFramebuffer(0, 0, static_cast<GLint>(m_width), static_cast<GLint>(m_height), 0, 0, static_cast<GLint>(m_width), static_cast<GLint>(m_height), GL_COLOR_BUFFER_BIT, GL_NEAREST));
|
glCheck(GLEXT_glBlitFramebuffer(0, 0, static_cast<GLint>(m_size.x), static_cast<GLint>(m_size.y), 0, 0, static_cast<GLint>(m_size.x), static_cast<GLint>(m_size.y), GL_COLOR_BUFFER_BIT, GL_NEAREST));
|
||||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, multisampleIt->second));
|
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, multisampleIt->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,15 +89,14 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the render texture implementation
|
/// \brief Create the render texture implementation
|
||||||
///
|
///
|
||||||
/// \param width Width of the texture to render to
|
/// \param size Width and height of the texture to render to
|
||||||
/// \param height Height of the texture to render to
|
|
||||||
/// \param textureId OpenGL identifier of the target texture
|
/// \param textureId OpenGL identifier of the target texture
|
||||||
/// \param settings Context settings to create render-texture with
|
/// \param settings Context settings to create render-texture with
|
||||||
///
|
///
|
||||||
/// \return True if creation has been successful
|
/// \return True if creation has been successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool create(unsigned int width, unsigned int height, unsigned int textureId, const ContextSettings& settings) override;
|
bool create(const Vector2u& size, unsigned int textureId, const ContextSettings& settings) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create an FBO in the current context
|
/// \brief Create an FBO in the current context
|
||||||
@ -143,8 +142,7 @@ private:
|
|||||||
std::unordered_map<Uint64, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments
|
std::unordered_map<Uint64, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments
|
||||||
unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer
|
unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer
|
||||||
unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer
|
unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer
|
||||||
unsigned int m_width; //!< Width of the attachments
|
Vector2u m_size; //!< Width and height of the attachments
|
||||||
unsigned int m_height; //!< Height of the attachments
|
|
||||||
std::unique_ptr<Context> m_context; //!< Backup OpenGL context, used when none already exist
|
std::unique_ptr<Context> m_context; //!< Backup OpenGL context, used when none already exist
|
||||||
unsigned int m_textureId; //!< The ID of the texture to attach to the FBO
|
unsigned int m_textureId; //!< The ID of the texture to attach to the FBO
|
||||||
bool m_multisample; //!< Whether we have to create a multisample frame buffer as well
|
bool m_multisample; //!< Whether we have to create a multisample frame buffer as well
|
||||||
|
@ -94,7 +94,7 @@ m_cacheId (TextureImpl::getUniqueId())
|
|||||||
{
|
{
|
||||||
if (copy.m_texture)
|
if (copy.m_texture)
|
||||||
{
|
{
|
||||||
if (create(copy.getSize().x, copy.getSize().y))
|
if (create(copy.getSize()))
|
||||||
{
|
{
|
||||||
update(copy);
|
update(copy);
|
||||||
}
|
}
|
||||||
@ -121,12 +121,12 @@ Texture::~Texture()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Texture::create(unsigned int width, unsigned int height)
|
bool Texture::create(const Vector2u& size)
|
||||||
{
|
{
|
||||||
// Check if texture parameters are valid before creating it
|
// Check if texture parameters are valid before creating it
|
||||||
if ((width == 0) || (height == 0))
|
if ((size.x == 0) || (size.y == 0))
|
||||||
{
|
{
|
||||||
err() << "Failed to create texture, invalid size (" << width << "x" << height << ")" << std::endl;
|
err() << "Failed to create texture, invalid size (" << size.x << "x" << size.y << ")" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ bool Texture::create(unsigned int width, unsigned int height)
|
|||||||
priv::ensureExtensionsInit();
|
priv::ensureExtensionsInit();
|
||||||
|
|
||||||
// Compute the internal texture dimensions depending on NPOT textures support
|
// Compute the internal texture dimensions depending on NPOT textures support
|
||||||
Vector2u actualSize(getValidSize(width), getValidSize(height));
|
Vector2u actualSize(getValidSize(size.x), getValidSize(size.y));
|
||||||
|
|
||||||
// Check the maximum texture size
|
// Check the maximum texture size
|
||||||
unsigned int maxSize = getMaximumSize();
|
unsigned int maxSize = getMaximumSize();
|
||||||
@ -150,8 +150,7 @@ bool Texture::create(unsigned int width, unsigned int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All the validity checks passed, we can store the new texture settings
|
// All the validity checks passed, we can store the new texture settings
|
||||||
m_size.x = width;
|
m_size = size;
|
||||||
m_size.y = height;
|
|
||||||
m_actualSize = actualSize;
|
m_actualSize = actualSize;
|
||||||
m_pixelsFlipped = false;
|
m_pixelsFlipped = false;
|
||||||
m_fboAttachment = false;
|
m_fboAttachment = false;
|
||||||
@ -255,7 +254,7 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
|||||||
((area.left <= 0) && (area.top <= 0) && (area.width >= width) && (area.height >= height)))
|
((area.left <= 0) && (area.top <= 0) && (area.width >= width) && (area.height >= height)))
|
||||||
{
|
{
|
||||||
// Load the entire image
|
// Load the entire image
|
||||||
if (create(image.getSize().x, image.getSize().y))
|
if (create(image.getSize()))
|
||||||
{
|
{
|
||||||
update(image);
|
update(image);
|
||||||
|
|
||||||
@ -278,7 +277,7 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
|||||||
if (rectangle.top + rectangle.height > height) rectangle.height = height - rectangle.top;
|
if (rectangle.top + rectangle.height > height) rectangle.height = height - rectangle.top;
|
||||||
|
|
||||||
// Create the texture and upload the pixels
|
// Create the texture and upload the pixels
|
||||||
if (create(static_cast<unsigned int>(rectangle.width), static_cast<unsigned int>(rectangle.height)))
|
if (create(Vector2u(rectangle.getSize())))
|
||||||
{
|
{
|
||||||
TransientContextLock lock;
|
TransientContextLock lock;
|
||||||
|
|
||||||
@ -394,7 +393,7 @@ Image Texture::copyToImage() const
|
|||||||
|
|
||||||
// Create the image
|
// Create the image
|
||||||
Image image;
|
Image image;
|
||||||
image.create(m_size.x, m_size.y, pixels.data());
|
image.create(m_size, pixels.data());
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@ -404,15 +403,15 @@ Image Texture::copyToImage() const
|
|||||||
void Texture::update(const Uint8* pixels)
|
void Texture::update(const Uint8* pixels)
|
||||||
{
|
{
|
||||||
// Update the whole texture
|
// Update the whole texture
|
||||||
update(pixels, m_size.x, m_size.y, 0, 0);
|
update(pixels, m_size, {0, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Texture::update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
|
void Texture::update(const Uint8* pixels, const Vector2u& size, const Vector2u& dest)
|
||||||
{
|
{
|
||||||
assert(x + width <= m_size.x);
|
assert(dest.x + size.x <= m_size.x);
|
||||||
assert(y + height <= m_size.y);
|
assert(dest.y + size.y <= m_size.y);
|
||||||
|
|
||||||
if (pixels && m_texture)
|
if (pixels && m_texture)
|
||||||
{
|
{
|
||||||
@ -423,7 +422,7 @@ void Texture::update(const Uint8* pixels, unsigned int width, unsigned int heigh
|
|||||||
|
|
||||||
// Copy pixels from the given array to the texture
|
// Copy pixels from the given array to the texture
|
||||||
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
||||||
glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height), GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(dest.x), static_cast<GLint>(dest.y), static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y), GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
m_pixelsFlipped = false;
|
m_pixelsFlipped = false;
|
||||||
@ -440,15 +439,15 @@ void Texture::update(const Uint8* pixels, unsigned int width, unsigned int heigh
|
|||||||
void Texture::update(const Texture& texture)
|
void Texture::update(const Texture& texture)
|
||||||
{
|
{
|
||||||
// Update the whole texture
|
// Update the whole texture
|
||||||
update(texture, 0, 0);
|
update(texture, {0, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Texture::update(const Texture& texture, unsigned int x, unsigned int y)
|
void Texture::update(const Texture& texture, const Vector2u& dest)
|
||||||
{
|
{
|
||||||
assert(x + texture.m_size.x <= m_size.x);
|
assert(dest.x + texture.m_size.x <= m_size.x);
|
||||||
assert(y + texture.m_size.y <= m_size.y);
|
assert(dest.y + texture.m_size.y <= m_size.y);
|
||||||
|
|
||||||
if (!m_texture || !texture.m_texture)
|
if (!m_texture || !texture.m_texture)
|
||||||
return;
|
return;
|
||||||
@ -505,7 +504,7 @@ void Texture::update(const Texture& texture, unsigned int x, unsigned int y)
|
|||||||
// Blit the texture contents from the source to the destination texture
|
// Blit the texture contents from the source to the destination texture
|
||||||
glCheck(GLEXT_glBlitFramebuffer(
|
glCheck(GLEXT_glBlitFramebuffer(
|
||||||
0, texture.m_pixelsFlipped ? static_cast<GLint>(texture.m_size.y) : 0, static_cast<GLint>(texture.m_size.x), texture.m_pixelsFlipped ? 0 : static_cast<GLint>(texture.m_size.y), // Source rectangle, flip y if source is flipped
|
0, texture.m_pixelsFlipped ? static_cast<GLint>(texture.m_size.y) : 0, static_cast<GLint>(texture.m_size.x), texture.m_pixelsFlipped ? 0 : static_cast<GLint>(texture.m_size.y), // Source rectangle, flip y if source is flipped
|
||||||
static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLint>(x + texture.m_size.x), static_cast<GLint>(y + texture.m_size.y), // Destination rectangle
|
static_cast<GLint>(dest.x), static_cast<GLint>(dest.y), static_cast<GLint>(dest.x + texture.m_size.x), static_cast<GLint>(dest.y + texture.m_size.y), // Destination rectangle
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST
|
GL_COLOR_BUFFER_BIT, GL_NEAREST
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -541,7 +540,7 @@ void Texture::update(const Texture& texture, unsigned int x, unsigned int y)
|
|||||||
|
|
||||||
#endif // SFML_OPENGL_ES
|
#endif // SFML_OPENGL_ES
|
||||||
|
|
||||||
update(texture.copyToImage(), x, y);
|
update(texture.copyToImage(), dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -549,29 +548,29 @@ void Texture::update(const Texture& texture, unsigned int x, unsigned int y)
|
|||||||
void Texture::update(const Image& image)
|
void Texture::update(const Image& image)
|
||||||
{
|
{
|
||||||
// Update the whole texture
|
// Update the whole texture
|
||||||
update(image.getPixelsPtr(), image.getSize().x, image.getSize().y, 0, 0);
|
update(image.getPixelsPtr(), image.getSize(), {0, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Texture::update(const Image& image, unsigned int x, unsigned int y)
|
void Texture::update(const Image& image, const Vector2u& dest)
|
||||||
{
|
{
|
||||||
update(image.getPixelsPtr(), image.getSize().x, image.getSize().y, x, y);
|
update(image.getPixelsPtr(), image.getSize(), dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Texture::update(const Window& window)
|
void Texture::update(const Window& window)
|
||||||
{
|
{
|
||||||
update(window, 0, 0);
|
update(window, {0, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Texture::update(const Window& window, unsigned int x, unsigned int y)
|
void Texture::update(const Window& window, const Vector2u& dest)
|
||||||
{
|
{
|
||||||
assert(x + window.getSize().x <= m_size.x);
|
assert(dest.x + window.getSize().x <= m_size.x);
|
||||||
assert(y + window.getSize().y <= m_size.y);
|
assert(dest.y + window.getSize().y <= m_size.y);
|
||||||
|
|
||||||
if (m_texture && window.setActive(true))
|
if (m_texture && window.setActive(true))
|
||||||
{
|
{
|
||||||
@ -582,7 +581,7 @@ void Texture::update(const Window& window, unsigned int x, unsigned int y)
|
|||||||
|
|
||||||
// Copy pixels from the back-buffer to the texture
|
// Copy pixels from the back-buffer to the texture
|
||||||
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
||||||
glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(x), static_cast<GLint>(y), 0, 0, static_cast<GLsizei>(window.getSize().x), static_cast<GLsizei>(window.getSize().y)));
|
glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(dest.x), static_cast<GLint>(dest.y), 0, 0, static_cast<GLsizei>(window.getSize().x), static_cast<GLsizei>(window.getSize().y)));
|
||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
m_pixelsFlipped = true;
|
m_pixelsFlipped = true;
|
||||||
|
@ -78,22 +78,13 @@ void View::setCenter(const Vector2f& center)
|
|||||||
m_invTransformUpdated = false;
|
m_invTransformUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void View::setSize(float width, float height)
|
|
||||||
{
|
|
||||||
m_size.x = width;
|
|
||||||
m_size.y = height;
|
|
||||||
|
|
||||||
m_transformUpdated = false;
|
|
||||||
m_invTransformUpdated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void View::setSize(const Vector2f& size)
|
void View::setSize(const Vector2f& size)
|
||||||
{
|
{
|
||||||
setSize(size.x, size.y);
|
m_size = size;
|
||||||
|
|
||||||
|
m_transformUpdated = false;
|
||||||
|
m_invTransformUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +164,7 @@ void View::rotate(Angle angle)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void View::zoom(float factor)
|
void View::zoom(float factor)
|
||||||
{
|
{
|
||||||
setSize(m_size.x * factor, m_size.y * factor);
|
setSize(m_size * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
// Return both portrait and landscape resolutions
|
// Return both portrait and landscape resolutions
|
||||||
std::vector<VideoMode> modes;
|
std::vector<VideoMode> modes;
|
||||||
modes.push_back(desktop);
|
modes.push_back(desktop);
|
||||||
modes.emplace_back(desktop.height, desktop.width, desktop.bitsPerPixel);
|
modes.emplace_back(Vector2u(desktop.size.y, desktop.size.x), desktop.bitsPerPixel);
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ VideoMode VideoModeImpl::getDesktopMode()
|
|||||||
priv::ActivityStates& states = priv::getActivity();
|
priv::ActivityStates& states = priv::getActivity();
|
||||||
std::scoped_lock lock(states.mutex);
|
std::scoped_lock lock(states.mutex);
|
||||||
|
|
||||||
return VideoMode(static_cast<unsigned int>(states.screenSize.x), static_cast<unsigned int>(states.screenSize.y));
|
return VideoMode(Vector2u(states.screenSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -61,7 +61,7 @@ WindowImplAndroid::WindowImplAndroid(WindowHandle /* handle */)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& /* title */, unsigned long style, const ContextSettings& /* settings */)
|
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& /* title */, unsigned long style, const ContextSettings& /* settings */)
|
||||||
: m_size(mode.width, mode.height)
|
: m_size(mode.size)
|
||||||
, m_windowBeingCreated(false)
|
, m_windowBeingCreated(false)
|
||||||
, m_windowBeingDestroyed(false)
|
, m_windowBeingDestroyed(false)
|
||||||
, m_hasFocus(false)
|
, m_hasFocus(false)
|
||||||
@ -160,7 +160,7 @@ void WindowImplAndroid::setTitle(const String& /* title */)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplAndroid::setIcon(unsigned int /* width */, unsigned int /* height */, const Uint8* /* pixels */)
|
void WindowImplAndroid::setIcon(const Vector2u& /* size */, const Uint8* /* pixels */)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -118,8 +118,8 @@ GlFunctionPointer Context::getFunction(const char* name)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Context::Context(const ContextSettings& settings, unsigned int width, unsigned int height)
|
Context::Context(const ContextSettings& settings, const Vector2u& size)
|
||||||
: m_context(priv::GlContext::create(settings, width, height))
|
: m_context(priv::GlContext::create(settings, size))
|
||||||
{
|
{
|
||||||
if (!setActive(true))
|
if (!setActive(true))
|
||||||
{
|
{
|
||||||
|
@ -204,8 +204,7 @@ m_config (nullptr),
|
|||||||
m_currentBO (nullptr),
|
m_currentBO (nullptr),
|
||||||
m_nextBO (nullptr),
|
m_nextBO (nullptr),
|
||||||
m_gbmSurface (nullptr),
|
m_gbmSurface (nullptr),
|
||||||
m_width (0),
|
m_size (0, 0),
|
||||||
m_height (0),
|
|
||||||
m_shown (false),
|
m_shown (false),
|
||||||
m_scanOut (false)
|
m_scanOut (false)
|
||||||
{
|
{
|
||||||
@ -222,9 +221,9 @@ m_scanOut (false)
|
|||||||
createContext(shared);
|
createContext(shared);
|
||||||
|
|
||||||
if (shared)
|
if (shared)
|
||||||
createSurface(shared->m_width, shared->m_height, VideoMode::getDesktopMode().bitsPerPixel, false);
|
createSurface(shared->m_size, VideoMode::getDesktopMode().bitsPerPixel, false);
|
||||||
else // create a surface to force the GL to initialize (seems to be required for glGetString() etc )
|
else // create a surface to force the GL to initialize (seems to be required for glGetString() etc )
|
||||||
createSurface(1, 1, VideoMode::getDesktopMode().bitsPerPixel, false);
|
createSurface({1, 1}, VideoMode::getDesktopMode().bitsPerPixel, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,8 +236,7 @@ m_config (nullptr),
|
|||||||
m_currentBO (nullptr),
|
m_currentBO (nullptr),
|
||||||
m_nextBO (nullptr),
|
m_nextBO (nullptr),
|
||||||
m_gbmSurface (nullptr),
|
m_gbmSurface (nullptr),
|
||||||
m_width (0),
|
m_size (0, 0),
|
||||||
m_height (0),
|
|
||||||
m_shown (false),
|
m_shown (false),
|
||||||
m_scanOut (false)
|
m_scanOut (false)
|
||||||
{
|
{
|
||||||
@ -255,12 +253,12 @@ m_scanOut (false)
|
|||||||
createContext(shared);
|
createContext(shared);
|
||||||
|
|
||||||
Vector2u size = owner.getSize();
|
Vector2u size = owner.getSize();
|
||||||
createSurface(size.x, size.y, bitsPerPixel, true);
|
createSurface(size, bitsPerPixel, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
|
DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, const Vector2u& size) :
|
||||||
m_display (EGL_NO_DISPLAY),
|
m_display (EGL_NO_DISPLAY),
|
||||||
m_context (EGL_NO_CONTEXT),
|
m_context (EGL_NO_CONTEXT),
|
||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
@ -268,8 +266,7 @@ m_config (nullptr),
|
|||||||
m_currentBO (nullptr),
|
m_currentBO (nullptr),
|
||||||
m_nextBO (nullptr),
|
m_nextBO (nullptr),
|
||||||
m_gbmSurface (nullptr),
|
m_gbmSurface (nullptr),
|
||||||
m_width (0),
|
m_size (0, 0),
|
||||||
m_height (0),
|
|
||||||
m_shown (false),
|
m_shown (false),
|
||||||
m_scanOut (false)
|
m_scanOut (false)
|
||||||
{
|
{
|
||||||
@ -284,7 +281,7 @@ m_scanOut (false)
|
|||||||
|
|
||||||
// Create EGL context
|
// Create EGL context
|
||||||
createContext(shared);
|
createContext(shared);
|
||||||
createSurface(width, height, VideoMode::getDesktopMode().bitsPerPixel, false);
|
createSurface(size, VideoMode::getDesktopMode().bitsPerPixel, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +428,7 @@ void DRMContext::createContext(DRMContext* shared)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void DRMContext::createSurface(unsigned int width, unsigned int height, unsigned int /*bpp*/, bool scanout)
|
void DRMContext::createSurface(const Vector2u& size, unsigned int /*bpp*/, bool scanout)
|
||||||
{
|
{
|
||||||
sf::Uint32 flags = GBM_BO_USE_RENDERING;
|
sf::Uint32 flags = GBM_BO_USE_RENDERING;
|
||||||
|
|
||||||
@ -441,8 +438,8 @@ void DRMContext::createSurface(unsigned int width, unsigned int height, unsigned
|
|||||||
|
|
||||||
m_gbmSurface = gbm_surface_create(
|
m_gbmSurface = gbm_surface_create(
|
||||||
gbmDevice,
|
gbmDevice,
|
||||||
width,
|
size.x,
|
||||||
height,
|
size.y,
|
||||||
GBM_FORMAT_ARGB8888,
|
GBM_FORMAT_ARGB8888,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
@ -452,8 +449,7 @@ void DRMContext::createSurface(unsigned int width, unsigned int height, unsigned
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_width = width;
|
m_size = size;
|
||||||
m_height = height;
|
|
||||||
|
|
||||||
m_surface = eglCheck(eglCreateWindowSurface(m_display, m_config, reinterpret_cast<EGLNativeWindowType>(m_gbmSurface), nullptr));
|
m_surface = eglCheck(eglCreateWindowSurface(m_display, m_config, reinterpret_cast<EGLNativeWindowType>(m_gbmSurface), nullptr));
|
||||||
|
|
||||||
|
@ -76,11 +76,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
DRMContext(DRMContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height);
|
DRMContext(DRMContext* shared, const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
@ -131,13 +130,12 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the EGL surface
|
/// \brief Create the EGL surface
|
||||||
///
|
///
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
/// \param bpp Pixel depth, in bits per pixel
|
/// \param bpp Pixel depth, in bits per pixel
|
||||||
/// \param scanout True to present the surface to the screen
|
/// \param scanout True to present the surface to the screen
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void createSurface(unsigned int width, unsigned int height, unsigned int bpp, bool scanout);
|
void createSurface(const Vector2u& size, unsigned int bpp, bool scanout);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destroy the EGL surface
|
/// \brief Destroy the EGL surface
|
||||||
@ -200,8 +198,7 @@ private:
|
|||||||
gbm_bo* m_currentBO;
|
gbm_bo* m_currentBO;
|
||||||
gbm_bo* m_nextBO;
|
gbm_bo* m_nextBO;
|
||||||
gbm_surface* m_gbmSurface;
|
gbm_surface* m_gbmSurface;
|
||||||
unsigned int m_width;
|
Vector2u m_size;
|
||||||
unsigned int m_height;
|
|
||||||
bool m_shown;
|
bool m_shown;
|
||||||
bool m_scanOut;
|
bool m_scanOut;
|
||||||
};
|
};
|
||||||
|
@ -47,8 +47,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < conn->count_modes; i++)
|
for (int i = 0; i < conn->count_modes; i++)
|
||||||
modes.push_back(
|
modes.push_back(
|
||||||
VideoMode(conn->modes[i].hdisplay,
|
VideoMode({conn->modes[i].hdisplay, conn->modes[i].vdisplay}));
|
||||||
conn->modes[i].vdisplay));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
modes.push_back(getDesktopMode());
|
modes.push_back(getDesktopMode());
|
||||||
@ -63,9 +62,9 @@ VideoMode VideoModeImpl::getDesktopMode()
|
|||||||
drm* drm = sf::priv::DRMContext::getDRM();
|
drm* drm = sf::priv::DRMContext::getDRM();
|
||||||
drmModeModeInfoPtr ptr = drm->mode;
|
drmModeModeInfoPtr ptr = drm->mode;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
return VideoMode(ptr->hdisplay, ptr->vdisplay);
|
return VideoMode({ptr->hdisplay, ptr->vdisplay});
|
||||||
else
|
else
|
||||||
return VideoMode(0, 0);
|
return VideoMode({0, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -48,7 +48,7 @@ m_size(0, 0)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplDRM::WindowImplDRM(VideoMode mode, const String& /*title*/, unsigned long /*style*/, const ContextSettings& /*settings*/) :
|
WindowImplDRM::WindowImplDRM(VideoMode mode, const String& /*title*/, unsigned long /*style*/, const ContextSettings& /*settings*/) :
|
||||||
m_size(mode.width, mode.height)
|
m_size(mode.size)
|
||||||
{
|
{
|
||||||
sf::priv::InputImpl::setTerminalConfig();
|
sf::priv::InputImpl::setTerminalConfig();
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ void WindowImplDRM::setTitle(const String& /*title*/)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplDRM::setIcon(unsigned int /*width*/, unsigned int /*height*/, const Uint8* /*pixels*/)
|
void WindowImplDRM::setIcon(const Vector2u& /*size*/, const Uint8* /*pixels*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,12 +119,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
virtual void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -171,7 +171,7 @@ m_config (nullptr)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EglContext::EglContext(EglContext* /*shared*/, const ContextSettings& /*settings*/, unsigned int /*width*/, unsigned int /*height*/) :
|
EglContext::EglContext(EglContext* /*shared*/, const ContextSettings& /*settings*/, const Vector2u& /*size*/) :
|
||||||
m_display (EGL_NO_DISPLAY),
|
m_display (EGL_NO_DISPLAY),
|
||||||
m_context (EGL_NO_CONTEXT),
|
m_context (EGL_NO_CONTEXT),
|
||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
@ -179,7 +179,7 @@ m_config (nullptr)
|
|||||||
{
|
{
|
||||||
EglContextImpl::ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
sf::err() << "Warning: context has not been initialized. The constructor EglContext(shared, settings, width, height) is currently not implemented." << std::endl;
|
sf::err() << "Warning: context has not been initialized. The constructor EglContext(shared, settings, size) is currently not implemented." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,11 +71,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EglContext(EglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height);
|
EglContext(EglContext* shared, const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
|
@ -501,7 +501,7 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, co
|
|||||||
// Re-create our shared context as a core context
|
// Re-create our shared context as a core context
|
||||||
ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags);
|
ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags);
|
||||||
|
|
||||||
sharedContext = std::make_unique<ContextType>(nullptr, sharedSettings, 1, 1);
|
sharedContext = std::make_unique<ContextType>(nullptr, sharedSettings, Vector2u(1, 1));
|
||||||
sharedContext->initialize(sharedSettings);
|
sharedContext->initialize(sharedSettings);
|
||||||
|
|
||||||
// Reload our extensions vector
|
// Reload our extensions vector
|
||||||
@ -530,7 +530,7 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, co
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, unsigned int width, unsigned int height)
|
std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, const Vector2u& size)
|
||||||
{
|
{
|
||||||
using GlContextImpl::mutex;
|
using GlContextImpl::mutex;
|
||||||
using GlContextImpl::resourceCount;
|
using GlContextImpl::resourceCount;
|
||||||
@ -553,7 +553,7 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, un
|
|||||||
// Re-create our shared context as a core context
|
// Re-create our shared context as a core context
|
||||||
ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags);
|
ContextSettings sharedSettings(0, 0, 0, settings.majorVersion, settings.minorVersion, settings.attributeFlags);
|
||||||
|
|
||||||
sharedContext = std::make_unique<ContextType>(nullptr, sharedSettings, 1, 1);
|
sharedContext = std::make_unique<ContextType>(nullptr, sharedSettings, Vector2u(1, 1));
|
||||||
sharedContext->initialize(sharedSettings);
|
sharedContext->initialize(sharedSettings);
|
||||||
|
|
||||||
// Reload our extensions vector
|
// Reload our extensions vector
|
||||||
@ -569,7 +569,7 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, un
|
|||||||
sharedContext->setActive(true);
|
sharedContext->setActive(true);
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
context = std::make_unique<ContextType>(sharedContext.get(), settings, width, height);
|
context = std::make_unique<ContextType>(sharedContext.get(), settings, size);
|
||||||
|
|
||||||
sharedContext->setActive(false);
|
sharedContext->setActive(false);
|
||||||
}
|
}
|
||||||
|
@ -128,13 +128,12 @@ public:
|
|||||||
/// to use according to the OS.
|
/// to use according to the OS.
|
||||||
///
|
///
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width
|
/// \param size Back buffer width and height
|
||||||
/// \param height Back buffer height
|
|
||||||
///
|
///
|
||||||
/// \return Pointer to the created context
|
/// \return Pointer to the created context
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static std::unique_ptr<GlContext> create(const ContextSettings& settings, unsigned int width, unsigned int height);
|
static std::unique_ptr<GlContext> create(const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -155,7 +155,7 @@ Vector2i InputImpl::getMousePosition()
|
|||||||
AutoreleasePool pool;
|
AutoreleasePool pool;
|
||||||
// Reverse Y axis to match SFML coord.
|
// Reverse Y axis to match SFML coord.
|
||||||
NSPoint pos = [NSEvent mouseLocation];
|
NSPoint pos = [NSEvent mouseLocation];
|
||||||
pos.y = sf::VideoMode::getDesktopMode().height - pos.y;
|
pos.y = sf::VideoMode::getDesktopMode().size.y - pos.y;
|
||||||
|
|
||||||
int scale = static_cast<int>([[NSScreen mainScreen] backingScaleFactor]);
|
int scale = static_cast<int>([[NSScreen mainScreen] backingScaleFactor]);
|
||||||
return Vector2i(static_cast<int>(pos.x), static_cast<int>(pos.y)) * scale;
|
return Vector2i(static_cast<int>(pos.x), static_cast<int>(pos.y)) * scale;
|
||||||
|
@ -90,12 +90,11 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext(SFContext* shared, const ContextSettings& settings,
|
SFContext(SFContext* shared, const ContextSettings& settings,
|
||||||
unsigned int width, unsigned int height);
|
const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
|
@ -81,7 +81,7 @@ m_window(0)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||||
unsigned int width, unsigned int height) :
|
const Vector2u& size) :
|
||||||
m_context(0),
|
m_context(0),
|
||||||
m_view(0),
|
m_view(0),
|
||||||
m_window(0)
|
m_window(0)
|
||||||
@ -94,11 +94,11 @@ m_window(0)
|
|||||||
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
|
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
|
||||||
|
|
||||||
// Create a dummy window/view pair (hidden) and assign it our context.
|
// Create a dummy window/view pair (hidden) and assign it our context.
|
||||||
m_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, width, height)
|
m_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, size.x, size.y)
|
||||||
styleMask:NSBorderlessWindowMask
|
styleMask:NSBorderlessWindowMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO]; // Don't defer it!
|
defer:NO]; // Don't defer it!
|
||||||
m_view = [[NSOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
|
m_view = [[NSOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, size.x, size.y)];
|
||||||
[m_window setContentView:m_view];
|
[m_window setContentView:m_view];
|
||||||
[m_view setOpenGLContext:m_context];
|
[m_view setOpenGLContext:m_context];
|
||||||
[m_context setView:m_view];
|
[m_context setView:m_view];
|
||||||
|
@ -247,7 +247,7 @@
|
|||||||
// Send a resize event if the scaling factor changed
|
// Send a resize event if the scaling factor changed
|
||||||
if ((m_scaleFactor != oldScaleFactor) && (m_requester != 0)) {
|
if ((m_scaleFactor != oldScaleFactor) && (m_requester != 0)) {
|
||||||
NSSize newSize = [self frame].size;
|
NSSize newSize = [self frame].size;
|
||||||
m_requester->windowResized(static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height));
|
m_requester->windowResized({static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@
|
|||||||
|
|
||||||
// The new size
|
// The new size
|
||||||
NSSize newSize = [self frame].size;
|
NSSize newSize = [self frame].size;
|
||||||
m_requester->windowResized(static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height));
|
m_requester->windowResized({static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height)});
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
// Create a screen-sized window on the main display
|
// Create a screen-sized window on the main display
|
||||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||||
sf::priv::scaleInWidthHeight(desktop, nil);
|
sf::priv::scaleInWidthHeight(desktop, nil);
|
||||||
NSRect windowRect = NSMakeRect(0, 0, desktop.width, desktop.height);
|
NSRect windowRect = NSMakeRect(0, 0, desktop.size.x, desktop.size.y);
|
||||||
m_window = [[SFWindow alloc] initWithContentRect:windowRect
|
m_window = [[SFWindow alloc] initWithContentRect:windowRect
|
||||||
styleMask:NSBorderlessWindowMask
|
styleMask:NSBorderlessWindowMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
@ -223,10 +223,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create our OpenGL view size and the view
|
// Create our OpenGL view size and the view
|
||||||
CGFloat width = std::min(mode.width, desktop.width);
|
CGFloat width = std::min(mode.size.x, desktop.size.x);
|
||||||
CGFloat height = std::min(mode.height, desktop.height);
|
CGFloat height = std::min(mode.size.y, desktop.size.y);
|
||||||
CGFloat x = (desktop.width - width) / 2.0;
|
CGFloat x = (desktop.size.x - width) / 2.0;
|
||||||
CGFloat y = (desktop.height - height) / 2.0;
|
CGFloat y = (desktop.size.y - height) / 2.0;
|
||||||
NSRect oglRect = NSMakeRect(x, y, width, height);
|
NSRect oglRect = NSMakeRect(x, y, width, height);
|
||||||
|
|
||||||
m_oglView = [[SFOpenGLView alloc] initWithFrame:oglRect
|
m_oglView = [[SFOpenGLView alloc] initWithFrame:oglRect
|
||||||
@ -253,7 +253,7 @@
|
|||||||
// We know that style & sf::Style::Fullscreen is false.
|
// We know that style & sf::Style::Fullscreen is false.
|
||||||
|
|
||||||
// Create our window size.
|
// Create our window size.
|
||||||
NSRect rect = NSMakeRect(0, 0, mode.width, mode.height);
|
NSRect rect = NSMakeRect(0, 0, mode.size.x, mode.size.y);
|
||||||
|
|
||||||
// Convert the SFML window style to Cocoa window style.
|
// Convert the SFML window style to Cocoa window style.
|
||||||
unsigned int nsStyle = NSBorderlessWindowMask;
|
unsigned int nsStyle = NSBorderlessWindowMask;
|
||||||
@ -451,11 +451,11 @@
|
|||||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||||
sf::priv::scaleInWidthHeight(desktop, nil);
|
sf::priv::scaleInWidthHeight(desktop, nil);
|
||||||
|
|
||||||
width = std::min(width, desktop.width);
|
width = std::min(width, desktop.size.x);
|
||||||
height = std::min(height, desktop.height);
|
height = std::min(height, desktop.size.y);
|
||||||
|
|
||||||
CGFloat x = (desktop.width - width) / 2.0;
|
CGFloat x = (desktop.size.x - width) / 2.0;
|
||||||
CGFloat y = (desktop.height - height) / 2.0;
|
CGFloat y = (desktop.size.y - height) / 2.0;
|
||||||
NSRect oglRect = NSMakeRect(x, y, width, height);
|
NSRect oglRect = NSMakeRect(x, y, width, height);
|
||||||
|
|
||||||
[m_oglView setFrame:oglRect];
|
[m_oglView setFrame:oglRect];
|
||||||
@ -482,7 +482,7 @@
|
|||||||
|
|
||||||
// The size is not the requested one, we fire an event
|
// The size is not the requested one, we fire an event
|
||||||
if (m_requester != 0)
|
if (m_requester != 0)
|
||||||
m_requester->windowResized(width, height - static_cast<unsigned int>([self titlebarHeight]));
|
m_requester->windowResized({width, height - static_cast<unsigned int>([self titlebarHeight])});
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRect frame = NSMakeRect([m_window frame].origin.x,
|
NSRect frame = NSMakeRect([m_window frame].origin.x,
|
||||||
|
@ -60,8 +60,8 @@ void scaleIn(T& in, id<WindowImplDelegateProtocol> delegate)
|
|||||||
template <class T>
|
template <class T>
|
||||||
void scaleInWidthHeight(T& in, id<WindowImplDelegateProtocol> delegate)
|
void scaleInWidthHeight(T& in, id<WindowImplDelegateProtocol> delegate)
|
||||||
{
|
{
|
||||||
scaleIn(in.width, delegate);
|
scaleIn(in.size.x, delegate);
|
||||||
scaleIn(in.height, delegate);
|
scaleIn(in.size.y, delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -85,10 +85,10 @@ void scaleOut(T& out, id<WindowImplDelegateProtocol> delegate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void scaleOutWidthHeight(T& out, id<WindowImplDelegateProtocol> delegate)
|
void scaleOutWidthHeight(T& width, T& height, id<WindowImplDelegateProtocol> delegate)
|
||||||
{
|
{
|
||||||
scaleOut(out.width, delegate);
|
scaleOut(width, delegate);
|
||||||
scaleOut(out.height, delegate);
|
scaleOut(height, delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -62,7 +62,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
VideoMode mode = convertCGModeToSFMode(cgmode);
|
VideoMode mode = convertCGModeToSFMode(cgmode);
|
||||||
|
|
||||||
// Skip if bigger than desktop as we currently don't perform hard resolution switch
|
// Skip if bigger than desktop as we currently don't perform hard resolution switch
|
||||||
if ((mode.width > desktop.width) || (mode.height > desktop.height))
|
if ((mode.size.x > desktop.size.x) || (mode.size.y > desktop.size.y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If not yet listed we add it to our modes array.
|
// If not yet listed we add it to our modes array.
|
||||||
|
@ -113,11 +113,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// Send the event to SFML WindowImpl class.
|
/// Send the event to SFML WindowImpl class.
|
||||||
///
|
///
|
||||||
/// \param width new width
|
/// \param size new width and height
|
||||||
/// \param height new height
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void windowResized(unsigned int width, unsigned int height);
|
void windowResized(const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Window Lost Focus Event - called by the cocoa window object
|
/// \brief Window Lost Focus Event - called by the cocoa window object
|
||||||
@ -301,12 +300,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -219,13 +219,13 @@ void WindowImplCocoa::windowClosed(void)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::windowResized(unsigned int width, unsigned int height)
|
void WindowImplCocoa::windowResized(const Vector2u& size)
|
||||||
{
|
{
|
||||||
Event event;
|
Event event;
|
||||||
event.type = Event::Resized;
|
event.type = Event::Resized;
|
||||||
event.size.width = width;
|
event.size.width = size.x;
|
||||||
event.size.height = height;
|
event.size.height = size.y;
|
||||||
scaleOutWidthHeight(event.size, m_delegate);
|
scaleOutWidthHeight(event.size.width, event.size.height, m_delegate);
|
||||||
|
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
}
|
}
|
||||||
@ -455,10 +455,10 @@ void WindowImplCocoa::setTitle(const String& title)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::setIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
void WindowImplCocoa::setIcon(const Vector2u& size, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
AutoreleasePool pool;
|
AutoreleasePool pool;
|
||||||
[m_delegate setIconTo:width by:height with:pixels];
|
[m_delegate setIconTo:size.x by:size.y with:pixels];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode)
|
|||||||
//
|
//
|
||||||
// [1]: "APIs for Supporting High Resolution" > "Additions and Changes for OS X v10.8"
|
// [1]: "APIs for Supporting High Resolution" > "Additions and Changes for OS X v10.8"
|
||||||
// https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW27
|
// https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW27
|
||||||
VideoMode mode(static_cast<unsigned int>(CGDisplayModeGetWidth(cgmode)), static_cast<unsigned int>(CGDisplayModeGetHeight(cgmode)), static_cast<unsigned int>(modeBitsPerPixel(cgmode)));
|
VideoMode mode({static_cast<unsigned int>(CGDisplayModeGetWidth(cgmode)), static_cast<unsigned int>(CGDisplayModeGetHeight(cgmode))}, static_cast<unsigned int>(modeBitsPerPixel(cgmode)));
|
||||||
scaleOutWidthHeight(mode, nil);
|
scaleOutWidthHeight(mode.size.x, mode.size.y, nil);
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ m_ownsWindow(false)
|
|||||||
ensureExtensionsInit(m_display, DefaultScreen(m_display));
|
ensureExtensionsInit(m_display, DefaultScreen(m_display));
|
||||||
|
|
||||||
// Create the rendering surface (window or pbuffer if supported)
|
// Create the rendering surface (window or pbuffer if supported)
|
||||||
createSurface(shared, 1, 1, VideoMode::getDesktopMode().bitsPerPixel);
|
createSurface(shared, {1, 1}, VideoMode::getDesktopMode().bitsPerPixel);
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
createContext(shared);
|
createContext(shared);
|
||||||
@ -157,7 +157,7 @@ m_ownsWindow(false)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
|
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const Vector2u& size) :
|
||||||
m_display (nullptr),
|
m_display (nullptr),
|
||||||
m_window (0),
|
m_window (0),
|
||||||
m_context (nullptr),
|
m_context (nullptr),
|
||||||
@ -174,7 +174,7 @@ m_ownsWindow(false)
|
|||||||
ensureExtensionsInit(m_display, DefaultScreen(m_display));
|
ensureExtensionsInit(m_display, DefaultScreen(m_display));
|
||||||
|
|
||||||
// Create the rendering surface (window or pbuffer if supported)
|
// Create the rendering surface (window or pbuffer if supported)
|
||||||
createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel);
|
createSurface(shared, size, VideoMode::getDesktopMode().bitsPerPixel);
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
createContext(shared);
|
createContext(shared);
|
||||||
@ -472,7 +472,7 @@ void GlxContext::updateSettingsFromWindow()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
|
void GlxContext::createSurface(GlxContext* shared, const Vector2u& size, unsigned int bitsPerPixel)
|
||||||
{
|
{
|
||||||
// Choose the visual according to the context settings
|
// Choose the visual according to the context settings
|
||||||
XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);
|
XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);
|
||||||
@ -521,8 +521,8 @@ void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned
|
|||||||
{
|
{
|
||||||
int attributes[] =
|
int attributes[] =
|
||||||
{
|
{
|
||||||
GLX_PBUFFER_WIDTH, static_cast<int>(width),
|
GLX_PBUFFER_WIDTH, static_cast<int>(size.x),
|
||||||
GLX_PBUFFER_HEIGHT, static_cast<int>(height),
|
GLX_PBUFFER_HEIGHT, static_cast<int>(size.y),
|
||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned
|
|||||||
m_window = XCreateWindow(m_display,
|
m_window = XCreateWindow(m_display,
|
||||||
RootWindow(m_display, screen),
|
RootWindow(m_display, screen),
|
||||||
0, 0,
|
0, 0,
|
||||||
width, height,
|
size.x, size.y,
|
||||||
0,
|
0,
|
||||||
DefaultDepth(m_display, screen),
|
DefaultDepth(m_display, screen),
|
||||||
InputOutput,
|
InputOutput,
|
||||||
|
@ -69,11 +69,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height);
|
GlxContext(GlxContext* shared, const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
@ -152,12 +151,11 @@ private:
|
|||||||
/// \brief Create the context's drawing surface
|
/// \brief Create the context's drawing surface
|
||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with (can be a null pointer)
|
/// \param shared Context to share the new one with (can be a null pointer)
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
/// \param bitsPerPixel Pixel depth, in bits per pixel
|
/// \param bitsPerPixel Pixel depth, in bits per pixel
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void createSurface(GlxContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel);
|
void createSurface(GlxContext* shared, const Vector2u& size, unsigned int bitsPerPixel);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the context's drawing surface from an existing window
|
/// \brief Create the context's drawing surface from an existing window
|
||||||
|
@ -74,15 +74,15 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
for (int j = 0; j < nbSizes; ++j)
|
for (int j = 0; j < nbSizes; ++j)
|
||||||
{
|
{
|
||||||
// Convert to VideoMode
|
// Convert to VideoMode
|
||||||
VideoMode mode(static_cast<unsigned int>(sizes[j].width),
|
VideoMode mode({static_cast<unsigned int>(sizes[j].width),
|
||||||
static_cast<unsigned int>(sizes[j].height),
|
static_cast<unsigned int>(sizes[j].height)},
|
||||||
static_cast<unsigned int>(depths[i]));
|
static_cast<unsigned int>(depths[i]));
|
||||||
|
|
||||||
Rotation currentRotation;
|
Rotation currentRotation;
|
||||||
XRRConfigRotations(config, ¤tRotation);
|
XRRConfigRotations(config, ¤tRotation);
|
||||||
|
|
||||||
if (currentRotation == RR_Rotate_90 || currentRotation == RR_Rotate_270)
|
if (currentRotation == RR_Rotate_90 || currentRotation == RR_Rotate_270)
|
||||||
std::swap(mode.width, mode.height);
|
std::swap(mode.size.x, mode.size.y);
|
||||||
|
|
||||||
// Add it only if it is not already in the array
|
// Add it only if it is not already in the array
|
||||||
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
|
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
|
||||||
@ -152,15 +152,15 @@ VideoMode VideoModeImpl::getDesktopMode()
|
|||||||
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
|
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
|
||||||
if (sizes && (nbSizes > 0))
|
if (sizes && (nbSizes > 0))
|
||||||
{
|
{
|
||||||
desktopMode = VideoMode(static_cast<unsigned int>(sizes[currentMode].width),
|
desktopMode = VideoMode({static_cast<unsigned int>(sizes[currentMode].width),
|
||||||
static_cast<unsigned int>(sizes[currentMode].height),
|
static_cast<unsigned int>(sizes[currentMode].height)},
|
||||||
static_cast<unsigned int>(DefaultDepth(display, screen)));
|
static_cast<unsigned int>(DefaultDepth(display, screen)));
|
||||||
|
|
||||||
Rotation modeRotation;
|
Rotation modeRotation;
|
||||||
XRRConfigRotations(config, &modeRotation);
|
XRRConfigRotations(config, &modeRotation);
|
||||||
|
|
||||||
if (modeRotation == RR_Rotate_90 || modeRotation == RR_Rotate_270)
|
if (modeRotation == RR_Rotate_90 || modeRotation == RR_Rotate_270)
|
||||||
std::swap(desktopMode.width, desktopMode.height);
|
std::swap(desktopMode.size.x, desktopMode.size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the configuration instance
|
// Free the configuration instance
|
||||||
|
@ -592,12 +592,12 @@ m_lastInputTime (0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windowPosition.x = (DisplayWidth(m_display, m_screen) - static_cast<int>(mode.width)) / 2;
|
const Vector2i displaySize(DisplayWidth(m_display, m_screen), DisplayHeight(m_display, m_screen));
|
||||||
windowPosition.y = (DisplayHeight(m_display, m_screen) - static_cast<int>(mode.height)) / 2;
|
windowPosition = displaySize - Vector2i(mode.size) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int width = mode.width;
|
unsigned int width = mode.size.x;
|
||||||
unsigned int height = mode.height;
|
unsigned int height = mode.size.y;
|
||||||
|
|
||||||
Visual* visual = nullptr;
|
Visual* visual = nullptr;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
@ -1007,12 +1007,12 @@ void WindowImplX11::setTitle(const String& title)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
void WindowImplX11::setIcon(const Vector2u& size, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
// X11 wants BGRA pixels: swap red and blue channels
|
// X11 wants BGRA pixels: swap red and blue channels
|
||||||
// Note: this memory will be freed by XDestroyImage
|
// Note: this memory will be freed by XDestroyImage
|
||||||
auto* iconPixels = static_cast<Uint8*>(std::malloc(static_cast<std::size_t>(width) * static_cast<std::size_t>(height) * 4));
|
auto* iconPixels = static_cast<Uint8*>(std::malloc(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4));
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(width) * static_cast<std::size_t>(height); ++i)
|
for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i)
|
||||||
{
|
{
|
||||||
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
||||||
iconPixels[i * 4 + 1] = pixels[i * 4 + 1];
|
iconPixels[i * 4 + 1] = pixels[i * 4 + 1];
|
||||||
@ -1023,7 +1023,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
// Create the icon pixmap
|
// Create the icon pixmap
|
||||||
Visual* defVisual = DefaultVisual(m_display, m_screen);
|
Visual* defVisual = DefaultVisual(m_display, m_screen);
|
||||||
auto defDepth = static_cast<unsigned int>(DefaultDepth(m_display, m_screen));
|
auto defDepth = static_cast<unsigned int>(DefaultDepth(m_display, m_screen));
|
||||||
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), width, height, 32, 0);
|
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), size.x, size.y, 32, 0);
|
||||||
if (!iconImage)
|
if (!iconImage)
|
||||||
{
|
{
|
||||||
err() << "Failed to set the window's icon" << std::endl;
|
err() << "Failed to set the window's icon" << std::endl;
|
||||||
@ -1036,31 +1036,31 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
if (m_iconMaskPixmap)
|
if (m_iconMaskPixmap)
|
||||||
XFreePixmap(m_display, m_iconMaskPixmap);
|
XFreePixmap(m_display, m_iconMaskPixmap);
|
||||||
|
|
||||||
m_iconPixmap = XCreatePixmap(m_display, RootWindow(m_display, m_screen), width, height, defDepth);
|
m_iconPixmap = XCreatePixmap(m_display, RootWindow(m_display, m_screen), size.x, size.y, defDepth);
|
||||||
XGCValues values;
|
XGCValues values;
|
||||||
GC iconGC = XCreateGC(m_display, m_iconPixmap, 0, &values);
|
GC iconGC = XCreateGC(m_display, m_iconPixmap, 0, &values);
|
||||||
XPutImage(m_display, m_iconPixmap, iconGC, iconImage, 0, 0, 0, 0, width, height);
|
XPutImage(m_display, m_iconPixmap, iconGC, iconImage, 0, 0, 0, 0, size.x, size.y);
|
||||||
XFreeGC(m_display, iconGC);
|
XFreeGC(m_display, iconGC);
|
||||||
XDestroyImage(iconImage);
|
XDestroyImage(iconImage);
|
||||||
|
|
||||||
// Create the mask pixmap (must have 1 bit depth)
|
// Create the mask pixmap (must have 1 bit depth)
|
||||||
std::size_t pitch = (width + 7) / 8;
|
std::size_t pitch = (size.x + 7) / 8;
|
||||||
std::vector<Uint8> maskPixels(pitch * height, 0);
|
std::vector<Uint8> maskPixels(pitch * size.y, 0);
|
||||||
for (std::size_t j = 0; j < height; ++j)
|
for (std::size_t j = 0; j < size.y; ++j)
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < pitch; ++i)
|
for (std::size_t i = 0; i < pitch; ++i)
|
||||||
{
|
{
|
||||||
for (std::size_t k = 0; k < 8; ++k)
|
for (std::size_t k = 0; k < 8; ++k)
|
||||||
{
|
{
|
||||||
if (i * 8 + k < width)
|
if (i * 8 + k < size.x)
|
||||||
{
|
{
|
||||||
Uint8 opacity = (pixels[(i * 8 + k + j * width) * 4 + 3] > 0) ? 1 : 0;
|
Uint8 opacity = (pixels[(i * 8 + k + j * size.x) * 4 + 3] > 0) ? 1 : 0;
|
||||||
maskPixels[i + j * pitch] |= static_cast<Uint8>(opacity << k);
|
maskPixels[i + j * pitch] |= static_cast<Uint8>(opacity << k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, reinterpret_cast<char*>(maskPixels.data()), width, height, 1, 0, 1);
|
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, reinterpret_cast<char*>(maskPixels.data()), size.x, size.y, 1, 0, 1);
|
||||||
|
|
||||||
// Send our new icon to the window through the WMHints
|
// Send our new icon to the window through the WMHints
|
||||||
XWMHints* hints = XAllocWMHints();
|
XWMHints* hints = XAllocWMHints();
|
||||||
@ -1072,16 +1072,16 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
|
|
||||||
// ICCCM wants BGRA pixels: swap red and blue channels
|
// ICCCM wants BGRA pixels: swap red and blue channels
|
||||||
// ICCCM also wants the first 2 unsigned 32-bit values to be width and height
|
// ICCCM also wants the first 2 unsigned 32-bit values to be width and height
|
||||||
std::vector<unsigned long> icccmIconPixels(2 + width * height, 0);
|
std::vector<unsigned long> icccmIconPixels(2 + size.x * size.y, 0);
|
||||||
unsigned long* ptr = icccmIconPixels.data();
|
unsigned long* ptr = icccmIconPixels.data();
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wnull-dereference" // False positive.
|
#pragma GCC diagnostic ignored "-Wnull-dereference" // False positive.
|
||||||
*ptr++ = width;
|
*ptr++ = size.x;
|
||||||
*ptr++ = height;
|
*ptr++ = size.y;
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(width) * static_cast<std::size_t>(height); ++i)
|
for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i)
|
||||||
{
|
{
|
||||||
*ptr++ = static_cast<unsigned long>((pixels[i * 4 + 2] << 0 ) |
|
*ptr++ = static_cast<unsigned long>((pixels[i * 4 + 2] << 0 ) |
|
||||||
(pixels[i * 4 + 1] << 8 ) |
|
(pixels[i * 4 + 1] << 8 ) |
|
||||||
@ -1098,7 +1098,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
reinterpret_cast<const unsigned char*>(icccmIconPixels.data()),
|
reinterpret_cast<const unsigned char*>(icccmIconPixels.data()),
|
||||||
static_cast<int>(2 + width * height));
|
static_cast<int>(2 + size.x * size.y));
|
||||||
|
|
||||||
XFlush(m_display);
|
XFlush(m_display);
|
||||||
}
|
}
|
||||||
@ -1379,8 +1379,8 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
|
|||||||
std::swap(res->modes[i].height, res->modes[i].width);
|
std::swap(res->modes[i].height, res->modes[i].width);
|
||||||
|
|
||||||
// Check if screen size match
|
// Check if screen size match
|
||||||
if ((res->modes[i].width == mode.width) &&
|
if ((res->modes[i].width == mode.size.x) &&
|
||||||
(res->modes[i].height == mode.height))
|
(res->modes[i].height == mode.size.y))
|
||||||
{
|
{
|
||||||
xRandMode = res->modes[i].id;
|
xRandMode = res->modes[i].id;
|
||||||
modeFound = true;
|
modeFound = true;
|
||||||
|
@ -124,12 +124,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -35,8 +35,7 @@ namespace sf
|
|||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
VideoMode::VideoMode() :
|
VideoMode::VideoMode() :
|
||||||
width (0),
|
size (0, 0),
|
||||||
height (0),
|
|
||||||
bitsPerPixel(0)
|
bitsPerPixel(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -44,9 +43,8 @@ bitsPerPixel(0)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
VideoMode::VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel) :
|
VideoMode::VideoMode(const Vector2u& modeSize, unsigned int modeBitsPerPixel) :
|
||||||
width (modeWidth),
|
size (modeSize),
|
||||||
height (modeHeight),
|
|
||||||
bitsPerPixel(modeBitsPerPixel)
|
bitsPerPixel(modeBitsPerPixel)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -89,8 +87,7 @@ bool VideoMode::isValid() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool operator ==(const VideoMode& left, const VideoMode& right)
|
bool operator ==(const VideoMode& left, const VideoMode& right)
|
||||||
{
|
{
|
||||||
return (left.width == right.width) &&
|
return (left.size == right.size) &&
|
||||||
(left.height == right.height) &&
|
|
||||||
(left.bitsPerPixel == right.bitsPerPixel);
|
(left.bitsPerPixel == right.bitsPerPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,13 +104,13 @@ bool operator <(const VideoMode& left, const VideoMode& right)
|
|||||||
{
|
{
|
||||||
if (left.bitsPerPixel == right.bitsPerPixel)
|
if (left.bitsPerPixel == right.bitsPerPixel)
|
||||||
{
|
{
|
||||||
if (left.width == right.width)
|
if (left.size.x == right.size.x)
|
||||||
{
|
{
|
||||||
return left.height < right.height;
|
return left.size.y < right.size.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return left.width < right.width;
|
return left.size.x < right.size.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -46,7 +46,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
for (int count = 0; EnumDisplaySettings(nullptr, static_cast<DWORD>(count), &win32Mode); ++count)
|
for (int count = 0; EnumDisplaySettings(nullptr, static_cast<DWORD>(count), &win32Mode); ++count)
|
||||||
{
|
{
|
||||||
// Convert to sf::VideoMode
|
// Convert to sf::VideoMode
|
||||||
VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel);
|
VideoMode mode({win32Mode.dmPelsWidth, win32Mode.dmPelsHeight}, win32Mode.dmBitsPerPel);
|
||||||
|
|
||||||
// Add it only if it is not already in the array
|
// Add it only if it is not already in the array
|
||||||
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
|
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
|
||||||
@ -65,7 +65,7 @@ VideoMode VideoModeImpl::getDesktopMode()
|
|||||||
win32Mode.dmDriverExtra = 0;
|
win32Mode.dmDriverExtra = 0;
|
||||||
EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &win32Mode);
|
EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &win32Mode);
|
||||||
|
|
||||||
return VideoMode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel);
|
return VideoMode({win32Mode.dmPelsWidth, win32Mode.dmPelsHeight}, win32Mode.dmBitsPerPel);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -103,7 +103,7 @@ String getErrorString(DWORD errorCode)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WglContext::WglContext(WglContext* shared) :
|
WglContext::WglContext(WglContext* shared) :
|
||||||
WglContext(shared, ContextSettings(), 1u, 1u)
|
WglContext(shared, ContextSettings(), {1u, 1u})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ m_ownsWindow (false)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
|
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const Vector2u& size) :
|
||||||
m_window (nullptr),
|
m_window (nullptr),
|
||||||
m_pbuffer (nullptr),
|
m_pbuffer (nullptr),
|
||||||
m_deviceContext(nullptr),
|
m_deviceContext(nullptr),
|
||||||
@ -143,7 +143,7 @@ m_ownsWindow (false)
|
|||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
// Create the rendering surface (window or pbuffer if supported)
|
// Create the rendering surface (window or pbuffer if supported)
|
||||||
createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel);
|
createSurface(shared, size, VideoMode::getDesktopMode().bitsPerPixel);
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
createContext(shared);
|
createContext(shared);
|
||||||
@ -523,7 +523,7 @@ void WglContext::updateSettingsFromPixelFormat()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
|
void WglContext::createSurface(WglContext* shared, const Vector2u& size, unsigned int bitsPerPixel)
|
||||||
{
|
{
|
||||||
// Check if the shared context already exists and pbuffers are supported
|
// Check if the shared context already exists and pbuffers are supported
|
||||||
if (shared && shared->m_deviceContext && SF_GLAD_WGL_ARB_pbuffer)
|
if (shared && shared->m_deviceContext && SF_GLAD_WGL_ARB_pbuffer)
|
||||||
@ -534,7 +534,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned
|
|||||||
{
|
{
|
||||||
int attributes[] = {0, 0};
|
int attributes[] = {0, 0};
|
||||||
|
|
||||||
m_pbuffer = wglCreatePbufferARB(shared->m_deviceContext, bestFormat, static_cast<int>(width), static_cast<int>(height), attributes);
|
m_pbuffer = wglCreatePbufferARB(shared->m_deviceContext, bestFormat, static_cast<int>(size.x), static_cast<int>(size.y), attributes);
|
||||||
|
|
||||||
if (m_pbuffer)
|
if (m_pbuffer)
|
||||||
{
|
{
|
||||||
@ -563,7 +563,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned
|
|||||||
// with other contexts and thus wglShareLists would always fail
|
// with other contexts and thus wglShareLists would always fail
|
||||||
|
|
||||||
// Create the hidden window
|
// Create the hidden window
|
||||||
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast<int>(width), static_cast<int>(height), nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast<int>(size.x), static_cast<int>(size.y), nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
||||||
ShowWindow(m_window, SW_HIDE);
|
ShowWindow(m_window, SW_HIDE);
|
||||||
m_deviceContext = GetDC(m_window);
|
m_deviceContext = GetDC(m_window);
|
||||||
|
|
||||||
|
@ -68,11 +68,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WglContext(WglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height);
|
WglContext(WglContext* shared, const ContextSettings& settings, const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
@ -152,12 +151,11 @@ private:
|
|||||||
/// \brief Create the context's drawing surface
|
/// \brief Create the context's drawing surface
|
||||||
///
|
///
|
||||||
/// \param shared Shared context (can be a null pointer)
|
/// \param shared Shared context (can be a null pointer)
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
/// \param bitsPerPixel Pixel depth, in bits per pixel
|
/// \param bitsPerPixel Pixel depth, in bits per pixel
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel);
|
void createSurface(WglContext* shared, const Vector2u& size, unsigned int bitsPerPixel);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the context's drawing surface from an existing window
|
/// \brief Create the context's drawing surface from an existing window
|
||||||
|
@ -164,7 +164,7 @@ m_cursorVisible (true), // might need to call GetCursorInfo
|
|||||||
m_lastCursor (LoadCursor(nullptr, IDC_ARROW)),
|
m_lastCursor (LoadCursor(nullptr, IDC_ARROW)),
|
||||||
m_icon (nullptr),
|
m_icon (nullptr),
|
||||||
m_keyRepeatEnabled(true),
|
m_keyRepeatEnabled(true),
|
||||||
m_lastSize (mode.width, mode.height),
|
m_lastSize (mode.size),
|
||||||
m_resizing (false),
|
m_resizing (false),
|
||||||
m_surrogate (0),
|
m_surrogate (0),
|
||||||
m_mouseInside (false),
|
m_mouseInside (false),
|
||||||
@ -180,10 +180,10 @@ m_cursorGrabbed (m_fullscreen)
|
|||||||
|
|
||||||
// Compute position and size
|
// Compute position and size
|
||||||
HDC screenDC = GetDC(nullptr);
|
HDC screenDC = GetDC(nullptr);
|
||||||
int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast<int>(mode.width)) / 2;
|
int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast<int>(mode.size.x)) / 2;
|
||||||
int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.height)) / 2;
|
int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.size.y)) / 2;
|
||||||
int width = static_cast<int>(mode.width);
|
int width = static_cast<int>(mode.size.x);
|
||||||
int height = static_cast<int>(mode.height);
|
int height = static_cast<int>(mode.size.y);
|
||||||
ReleaseDC(nullptr, screenDC);
|
ReleaseDC(nullptr, screenDC);
|
||||||
|
|
||||||
// Choose the window style according to the Style parameter
|
// Choose the window style according to the Style parameter
|
||||||
@ -226,7 +226,7 @@ m_cursorGrabbed (m_fullscreen)
|
|||||||
|
|
||||||
// By default, the OS limits the size of the window the the desktop size,
|
// By default, the OS limits the size of the window the the desktop size,
|
||||||
// we have to resize it after creation to apply the real size
|
// we have to resize it after creation to apply the real size
|
||||||
setSize(Vector2u(mode.width, mode.height));
|
setSize(mode.size);
|
||||||
|
|
||||||
// Switch to fullscreen if requested
|
// Switch to fullscreen if requested
|
||||||
if (m_fullscreen)
|
if (m_fullscreen)
|
||||||
@ -351,14 +351,14 @@ void WindowImplWin32::setTitle(const String& title)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
void WindowImplWin32::setIcon(const Vector2u& size, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
// First destroy the previous one
|
// First destroy the previous one
|
||||||
if (m_icon)
|
if (m_icon)
|
||||||
DestroyIcon(m_icon);
|
DestroyIcon(m_icon);
|
||||||
|
|
||||||
// Windows wants BGRA pixels: swap red and blue channels
|
// Windows wants BGRA pixels: swap red and blue channels
|
||||||
std::vector<Uint8> iconPixels(width * height * 4);
|
std::vector<Uint8> iconPixels(size.x * size.y * 4);
|
||||||
for (std::size_t i = 0; i < iconPixels.size() / 4; ++i)
|
for (std::size_t i = 0; i < iconPixels.size() / 4; ++i)
|
||||||
{
|
{
|
||||||
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
||||||
@ -368,7 +368,7 @@ void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the icon from the pixel array
|
// Create the icon from the pixel array
|
||||||
m_icon = CreateIcon(GetModuleHandleW(nullptr), static_cast<int>(width), static_cast<int>(height), 1, 32, nullptr, iconPixels.data());
|
m_icon = CreateIcon(GetModuleHandleW(nullptr), static_cast<int>(size.x), static_cast<int>(size.y), 1, 32, nullptr, iconPixels.data());
|
||||||
|
|
||||||
// Set it as both big and small icon of the window
|
// Set it as both big and small icon of the window
|
||||||
if (m_icon)
|
if (m_icon)
|
||||||
@ -479,8 +479,8 @@ void WindowImplWin32::switchToFullscreen(const VideoMode& mode)
|
|||||||
{
|
{
|
||||||
DEVMODE devMode;
|
DEVMODE devMode;
|
||||||
devMode.dmSize = sizeof(devMode);
|
devMode.dmSize = sizeof(devMode);
|
||||||
devMode.dmPelsWidth = mode.width;
|
devMode.dmPelsWidth = mode.size.x;
|
||||||
devMode.dmPelsHeight = mode.height;
|
devMode.dmPelsHeight = mode.size.y;
|
||||||
devMode.dmBitsPerPel = mode.bitsPerPixel;
|
devMode.dmBitsPerPel = mode.bitsPerPixel;
|
||||||
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ void WindowImplWin32::switchToFullscreen(const VideoMode& mode)
|
|||||||
SetWindowLongPtr(m_handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
|
SetWindowLongPtr(m_handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
|
||||||
|
|
||||||
// Resize the window so that it fits the entire screen
|
// Resize the window so that it fits the entire screen
|
||||||
SetWindowPos(m_handle, HWND_TOP, 0, 0, static_cast<int>(mode.width), static_cast<int>(mode.height), SWP_FRAMECHANGED);
|
SetWindowPos(m_handle, HWND_TOP, 0, 0, static_cast<int>(mode.size.x), static_cast<int>(mode.size.y), SWP_FRAMECHANGED);
|
||||||
ShowWindow(m_handle, SW_SHOW);
|
ShowWindow(m_handle, SW_SHOW);
|
||||||
|
|
||||||
// Set "this" as the current fullscreen window
|
// Set "this" as the current fullscreen window
|
||||||
|
@ -123,12 +123,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -235,10 +235,10 @@ void WindowBase::setTitle(const String& title)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowBase::setIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
void WindowBase::setIcon(const Vector2u& size, const Uint8* pixels)
|
||||||
{
|
{
|
||||||
if (m_impl)
|
if (m_impl)
|
||||||
m_impl->setIcon(width, height, pixels);
|
m_impl->setIcon(size, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,12 +176,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) = 0;
|
virtual void setIcon(const Vector2u& size, const Uint8* pixels) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -77,12 +77,11 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param shared Context to share the new one with
|
/// \param shared Context to share the new one with
|
||||||
/// \param settings Creation parameters
|
/// \param settings Creation parameters
|
||||||
/// \param width Back buffer width, in pixels
|
/// \param size Back buffer width and height, in pixels
|
||||||
/// \param height Back buffer height, in pixels
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EaglContext(EaglContext* shared, const ContextSettings& settings,
|
EaglContext(EaglContext* shared, const ContextSettings& settings,
|
||||||
unsigned int width, unsigned int height);
|
const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
|
@ -126,7 +126,7 @@ m_clock ()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EaglContext::EaglContext(EaglContext* /* shared */, const ContextSettings& /* settings */,
|
EaglContext::EaglContext(EaglContext* /* shared */, const ContextSettings& /* settings */,
|
||||||
unsigned int /* width */, unsigned int /* height */) :
|
const Vector2u& /* size */) :
|
||||||
m_context (nil),
|
m_context (nil),
|
||||||
m_framebuffer (0),
|
m_framebuffer (0),
|
||||||
m_colorbuffer (0),
|
m_colorbuffer (0),
|
||||||
|
@ -41,7 +41,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
|||||||
// Return both portrait and landscape resolutions
|
// Return both portrait and landscape resolutions
|
||||||
std::vector<VideoMode> modes;
|
std::vector<VideoMode> modes;
|
||||||
modes.push_back(desktop);
|
modes.push_back(desktop);
|
||||||
modes.emplace_back(desktop.height, desktop.width, desktop.bitsPerPixel);
|
modes.emplace_back(Vector2u(desktop.size.y, desktop.size.x), desktop.bitsPerPixel);
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ VideoMode VideoModeImpl::getDesktopMode()
|
|||||||
{
|
{
|
||||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
CGRect bounds = [[UIScreen mainScreen] bounds];
|
||||||
double backingScale = [SFAppDelegate getInstance].backingScaleFactor;
|
double backingScale = [SFAppDelegate getInstance].backingScaleFactor;
|
||||||
return VideoMode(static_cast<unsigned int>(bounds.size.width * backingScale), static_cast<unsigned int>(bounds.size.height * backingScale));
|
return VideoMode({static_cast<unsigned int>(bounds.size.width * backingScale), static_cast<unsigned int>(bounds.size.height * backingScale)});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -126,12 +126,11 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the window's icon
|
/// \brief Change the window's icon
|
||||||
///
|
///
|
||||||
/// \param width Icon's width, in pixels
|
/// \param size Icon's width and height, in pixels
|
||||||
/// \param height Icon's height, in pixels
|
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels) override;
|
void setIcon(const Vector2u& size, const Uint8* pixels) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the window
|
/// \brief Show or hide the window
|
||||||
|
@ -64,7 +64,7 @@ WindowImplUIKit::WindowImplUIKit(VideoMode mode,
|
|||||||
[UIApplication sharedApplication].statusBarHidden = !(style & Style::Titlebar) || (style & Style::Fullscreen);
|
[UIApplication sharedApplication].statusBarHidden = !(style & Style::Titlebar) || (style & Style::Fullscreen);
|
||||||
|
|
||||||
// Set the orientation according to the requested size
|
// Set the orientation according to the requested size
|
||||||
if (mode.width > mode.height)
|
if (mode.size.x > mode.size.y)
|
||||||
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
|
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
|
||||||
else
|
else
|
||||||
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
|
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
|
||||||
@ -180,7 +180,7 @@ void WindowImplUIKit::setTitle(const String& /* title */)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplUIKit::setIcon(unsigned int /* width */, unsigned int /* height */, const Uint8* /* pixels */)
|
void WindowImplUIKit::setIcon(const Vector2u& /* size */, const Uint8* /* pixels */)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ namespace sf
|
|||||||
{
|
{
|
||||||
std::ostream& operator <<(std::ostream& os, const sf::VideoMode& videoMode)
|
std::ostream& operator <<(std::ostream& os, const sf::VideoMode& videoMode)
|
||||||
{
|
{
|
||||||
os << videoMode.width << "x" << videoMode.height << "x" << videoMode.bitsPerPixel;
|
os << videoMode.size.x << "x" << videoMode.size.y << "x" << videoMode.bitsPerPixel;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,24 +10,21 @@ TEST_CASE("sf::VideoMode class - [window]")
|
|||||||
SUBCASE("Default constructor")
|
SUBCASE("Default constructor")
|
||||||
{
|
{
|
||||||
sf::VideoMode videoMode;
|
sf::VideoMode videoMode;
|
||||||
CHECK(videoMode.width == 0);
|
CHECK(videoMode.size == sf::Vector2u(0, 0));
|
||||||
CHECK(videoMode.height == 0);
|
|
||||||
CHECK(videoMode.bitsPerPixel == 0);
|
CHECK(videoMode.bitsPerPixel == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Width, height constructor")
|
SUBCASE("Width, height constructor")
|
||||||
{
|
{
|
||||||
sf::VideoMode videoMode(800, 600);
|
sf::VideoMode videoMode({800, 600});
|
||||||
CHECK(videoMode.width == 800);
|
CHECK(videoMode.size == sf::Vector2u(800, 600));
|
||||||
CHECK(videoMode.height == 600);
|
|
||||||
CHECK(videoMode.bitsPerPixel == 32);
|
CHECK(videoMode.bitsPerPixel == 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Width, height, bit depth constructor")
|
SUBCASE("Width, height, bit depth constructor")
|
||||||
{
|
{
|
||||||
sf::VideoMode videoMode(800, 600, 24);
|
sf::VideoMode videoMode({800, 600}, 24);
|
||||||
CHECK(videoMode.width == 800);
|
CHECK(videoMode.size == sf::Vector2u(800, 600));
|
||||||
CHECK(videoMode.height == 600);
|
|
||||||
CHECK(videoMode.bitsPerPixel == 24);
|
CHECK(videoMode.bitsPerPixel == 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,55 +34,55 @@ TEST_CASE("sf::VideoMode class - [window]")
|
|||||||
SUBCASE("operator==")
|
SUBCASE("operator==")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode() == sf::VideoMode());
|
CHECK(sf::VideoMode() == sf::VideoMode());
|
||||||
CHECK(sf::VideoMode(0, 0, 0) == sf::VideoMode(0, 0, 0));
|
CHECK(sf::VideoMode({0, 0}, 0) == sf::VideoMode({0, 0}, 0));
|
||||||
CHECK(sf::VideoMode(1080, 1920, 64) == sf::VideoMode(1080, 1920, 64));
|
CHECK(sf::VideoMode({1080, 1920}, 64) == sf::VideoMode({1080, 1920}, 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operator!=")
|
SUBCASE("operator!=")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode() != sf::VideoMode(1, 0));
|
CHECK(sf::VideoMode() != sf::VideoMode({1, 0}));
|
||||||
CHECK(sf::VideoMode() != sf::VideoMode(0, 1));
|
CHECK(sf::VideoMode() != sf::VideoMode({0, 1}));
|
||||||
CHECK(sf::VideoMode() != sf::VideoMode(0, 0, 1));
|
CHECK(sf::VideoMode() != sf::VideoMode({0, 0}, 1));
|
||||||
CHECK(sf::VideoMode(720, 720) != sf::VideoMode(720, 720, 24));
|
CHECK(sf::VideoMode({720, 720}) != sf::VideoMode({720, 720}, 24));
|
||||||
CHECK(sf::VideoMode(1080, 1920, 16) != sf::VideoMode(400, 600));
|
CHECK(sf::VideoMode({1080, 1920}, 16) != sf::VideoMode({400, 600}));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operator<")
|
SUBCASE("operator<")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode() < sf::VideoMode(0, 0, 1));
|
CHECK(sf::VideoMode() < sf::VideoMode({0, 0}, 1));
|
||||||
CHECK(sf::VideoMode(800, 800, 24) < sf::VideoMode(1080, 1920, 48));
|
CHECK(sf::VideoMode({800, 800}, 24) < sf::VideoMode({1080, 1920}, 48));
|
||||||
CHECK(sf::VideoMode(400, 600, 48) < sf::VideoMode(600, 400, 48));
|
CHECK(sf::VideoMode({400, 600}, 48) < sf::VideoMode({600, 400}, 48));
|
||||||
CHECK(sf::VideoMode(400, 400, 48) < sf::VideoMode(400, 600, 48));
|
CHECK(sf::VideoMode({400, 400}, 48) < sf::VideoMode({400, 600}, 48));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operator>")
|
SUBCASE("operator>")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode(1, 0) > sf::VideoMode(0, 0, 1));
|
CHECK(sf::VideoMode({1, 0}) > sf::VideoMode({0, 0}, 1));
|
||||||
CHECK(sf::VideoMode(800, 800, 48) > sf::VideoMode(1080, 1920, 24));
|
CHECK(sf::VideoMode({800, 800}, 48) > sf::VideoMode({1080, 1920}, 24));
|
||||||
CHECK(sf::VideoMode(600, 400, 48) > sf::VideoMode(400, 600, 48));
|
CHECK(sf::VideoMode({600, 400}, 48) > sf::VideoMode({400, 600}, 48));
|
||||||
CHECK(sf::VideoMode(400, 600, 48) > sf::VideoMode(400, 400, 48));
|
CHECK(sf::VideoMode({400, 600}, 48) > sf::VideoMode({400, 400}, 48));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operator<=")
|
SUBCASE("operator<=")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode() <= sf::VideoMode(0, 0, 1));
|
CHECK(sf::VideoMode() <= sf::VideoMode({0, 0}, 1));
|
||||||
CHECK(sf::VideoMode(800, 800, 24) <= sf::VideoMode(1080, 1920, 48));
|
CHECK(sf::VideoMode({800, 800}, 24) <= sf::VideoMode({1080, 1920}, 48));
|
||||||
CHECK(sf::VideoMode(400, 600, 48) <= sf::VideoMode(600, 400, 48));
|
CHECK(sf::VideoMode({400, 600}, 48) <= sf::VideoMode({600, 400}, 48));
|
||||||
CHECK(sf::VideoMode(400, 400, 48) <= sf::VideoMode(400, 600, 48));
|
CHECK(sf::VideoMode({400, 400}, 48) <= sf::VideoMode({400, 600}, 48));
|
||||||
CHECK(sf::VideoMode() <= sf::VideoMode());
|
CHECK(sf::VideoMode() <= sf::VideoMode());
|
||||||
CHECK(sf::VideoMode(0, 0, 0) <= sf::VideoMode(0, 0, 0));
|
CHECK(sf::VideoMode({0, 0}, 0) <= sf::VideoMode({0, 0}, 0));
|
||||||
CHECK(sf::VideoMode(1080, 1920, 64) <= sf::VideoMode(1080, 1920, 64));
|
CHECK(sf::VideoMode({1080, 1920}, 64) <= sf::VideoMode({1080, 1920}, 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operator>=")
|
SUBCASE("operator>=")
|
||||||
{
|
{
|
||||||
CHECK(sf::VideoMode(1, 0) >= sf::VideoMode(0, 0, 1));
|
CHECK(sf::VideoMode({1, 0}) >= sf::VideoMode({0, 0}, 1));
|
||||||
CHECK(sf::VideoMode(800, 800, 48) >= sf::VideoMode(1080, 1920, 24));
|
CHECK(sf::VideoMode({800, 800}, 48) >= sf::VideoMode({1080, 1920}, 24));
|
||||||
CHECK(sf::VideoMode(600, 400, 48) >= sf::VideoMode(400, 600, 48));
|
CHECK(sf::VideoMode({600, 400}, 48) >= sf::VideoMode({400, 600}, 48));
|
||||||
CHECK(sf::VideoMode(400, 600, 48) >= sf::VideoMode(400, 400, 48));
|
CHECK(sf::VideoMode({400, 600}, 48) >= sf::VideoMode({400, 400}, 48));
|
||||||
CHECK(sf::VideoMode() >= sf::VideoMode());
|
CHECK(sf::VideoMode() >= sf::VideoMode());
|
||||||
CHECK(sf::VideoMode(0, 0, 0) >= sf::VideoMode(0, 0, 0));
|
CHECK(sf::VideoMode({0, 0}, 0) >= sf::VideoMode({0, 0}, 0));
|
||||||
CHECK(sf::VideoMode(1080, 1920, 64) >= sf::VideoMode(1080, 1920, 64));
|
CHECK(sf::VideoMode({1080, 1920}, 64) >= sf::VideoMode({1080, 1920}, 64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user