Hello,
SFML does not allow you to modify the window when it is drag by the user, which is extremely annoying.
I'm currently trying to find a workaround but I'm having a lot of trouble, there are errors, OpenGL doesn't seem to like what I'm doing and everything doesn't work as expected...
Could you help me find a workaround for this problem ? Thanks in advance.
Here is my code :
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <Windows.h>
void fonct(sf::RenderWindow * window) {
sf::Texture texture;
if (!texture.loadFromFile("Vernet-Battle_of_Hanau.jpg")) std::cout << "erreur" << std::endl;
sf::Sprite sprite;
sprite.setTexture(texture);
while (window->isOpen()) {
RECT rect;
GetWindowRect(window->getSystemHandle(), &rect);
int taille_x = rect.right - rect.left - (GetSystemMetrics(SM_CXMAXIMIZED) - GetSystemMetrics(SM_CXFULLSCREEN));
int taille_y = rect.bottom - rect.top - (GetSystemMetrics(SM_CYMAXIMIZED) - GetSystemMetrics(SM_CYFULLSCREEN));
sf::FloatRect visibleArea(0.f, 0.f, taille_x, taille_y);
window->setView(sf::View(visibleArea));
window->draw(sprite);
window->display();
}
}
int main() {
sf::Mutex mutex;
sf::Lock lock(mutex);
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setActive(false);
sf::Thread thread(&fonct, &window);
thread.launch();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
if (event.type == sf::Event::Resized) {
sf::FloatRect visibleArea(0.f, 0.f, event.size.width, event.size.height);
window.setView(sf::View(visibleArea));
}
}
}
thread.wait();
}