Added Window::GetPosition, and renamed some setters in Window for better consistency

This commit is contained in:
Laurent Gomila 2012-03-07 23:29:54 +01:00
parent 90854907b5
commit 15e9d999b3
26 changed files with 473 additions and 492 deletions
examples

View file

@ -5,6 +5,7 @@
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
@ -15,7 +16,7 @@ int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML OpenGL", sf::Style::Default, sf::ContextSettings(32));
window.EnableVerticalSync(true);
window.SetVerticalSyncEnabled(true);
// Create a sprite for the background
sf::Texture backgroundTexture;
@ -90,8 +91,8 @@ int main()
glClear(GL_DEPTH_BUFFER_BIT);
// We get the position of the mouse cursor, so that we can move the box accordingly
float x = sf::Mouse::GetPosition(window).x * 200.f / window.GetWidth() - 100.f;
float y = -sf::Mouse::GetPosition(window).y * 200.f / window.GetHeight() + 100.f;
float x = sf::Mouse::GetPosition(window).x * 200.f / window.GetSize().x - 100.f;
float y = -sf::Mouse::GetPosition(window).y * 200.f / window.GetSize().y + 100.f;
// Apply some transformations
glMatrixMode(GL_MODELVIEW);

View file

@ -28,7 +28,7 @@ int main()
// Create the window of the application
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Pong");
window.EnableVerticalSync(true);
window.SetVerticalSyncEnabled(true);
// Load the sounds used in the game
sf::SoundBuffer ballSoundBuffer;

View file

@ -265,7 +265,7 @@ int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");
window.EnableVerticalSync(true);
window.SetVerticalSyncEnabled(true);
// Create the effects
std::vector<Effect*> effects;
@ -348,8 +348,8 @@ int main()
}
// Update the current example
float x = static_cast<float>(sf::Mouse::GetPosition(window).x) / window.GetWidth();
float y = static_cast<float>(sf::Mouse::GetPosition(window).y) / window.GetHeight();
float x = static_cast<float>(sf::Mouse::GetPosition(window).x) / window.GetSize().x;
float y = static_cast<float>(sf::Mouse::GetPosition(window).y) / window.GetSize().y;
effects[current]->Update(clock.GetElapsedTime().AsSeconds(), x, y);
// Clear the window