Is there a way to force an iteration? Or is there a way to get the cursor coordinates updated so i don't wait for another iteration?
Also, an iteration should happen really fast so i think i might get away with not needing an instant update, but this code won't constantly print 400 300 after pressing 's'. Am i doing something wrong here?
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <map>
#include <math.h>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");
// Create a clock to measure the total time elapsed
sf::Clock clock;
// Start the game loop
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.GetEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();
if (event.Type == sf::Event::KeyPressed)
{
// Escape key : exit
if (event.Key.Code == sf::Key::Escape)
window.Close();
if (event.Key.Code == sf::Key::S)
{
window.SetCursorPosition(400, 300);
printf("%d %d\n", window.GetInput().GetMouseX(), window.GetInput().GetMouseY());
}
}
if (event.Type == sf::Event::MouseMoved)
{
printf("%d %d\n", event.MouseMove.X, event.MouseMove.Y);
}
}
printf("%d %d\n", window.GetInput().GetMouseX(), window.GetInput().GetMouseY());
// Finally, display the rendered frame on screen
window.Display();
}
return EXIT_SUCCESS;
}