Now that I've found the time to code again, I want to solve an issue that has bugged me ever since. I don't think the code is necessary, since all I'm doing is draw a shape and make it follow the cursor, but there you go.
The problem I have is, that there is an acellerated-mouse efect present when using a sprite-based custom cursor, that gets dramatically amplified by activating vsync. The video shows what I mean. While the effect may become less obvious when hiding the cursor, it is still bothersome.
(The effect with vsync turned off, or an uncapped framerate, however the movement is much more crisp.)
The little game I've set my mind to requires precise and quick mouse input, even while the cursor is moving. This issue however opens up the possibility of registering a click on a location that differs from the one of the cursor-sprite.
Also, but that's a personal opinion, I think the whole acceleration effect is just awful, even if deliberately built in.
(It doesn't even look that bad in the video. But especially when moving in a constant motion, the sprite clearly lags behind. )
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "Title");
window.setVerticalSyncEnabled(true);
sf::CircleShape shape(10.f);
shape.setFillColor(sf::Color::Green);
shape.setOrigin(10, 10);
//window.setMouseCursorVisible(false);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
shape.setPosition(static_cast<sf::Vector2f>(sf::Mouse::getPosition(window)));
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
I have considered alternatives already, like using windows-functionality like "LoadCursorFromFile()", but then I'd have to look for equivalent functions on other Platforms, or lose portability (I'd like to avoid both). Also, I'm wondering if getting the input from a different thread would help. (I have yet to try the latter, as I haven't worked with threads before)
Anyway, any input is very welcome!