Created
June 16, 2011 17:18
-
-
Save coolhome/1029724 to your computer and use it in GitHub Desktop.
Testing sf::Window::GetPosition();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics.hpp> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
//Hack! I know lol | |
std::string IntToString(int x) | |
{ | |
std::ostringstream output; | |
output << x; | |
return output.str(); | |
} | |
int main() | |
{ | |
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window"); | |
sf::Font arial; | |
if(! arial.LoadFromFile("arial.ttf")) | |
return EXIT_FAILURE; | |
sf::Text coords; | |
coords.SetFont(arial); | |
coords.SetCharacterSize(32); | |
sf::String coordStr; | |
sf::Vector2i windowPos; | |
while(window.IsOpened()) | |
{ | |
sf::Event event; | |
while(window.PollEvent(event)) | |
{ | |
if(event.Type == sf::Event::Closed) | |
window.Close(); | |
} | |
windowPos = window.GetPosition(); | |
coordStr = ("Window Position: " + IntToString(windowPos.x) + ", " + IntToString(windowPos.y)); | |
coords.SetString(coordStr); | |
window.Clear(); | |
window.Draw(coords); | |
window.Display(); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment