Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Dobi

Pages: [1]
1
Graphics / [solved] rotate a rectangle around its center (SFML 1.6)
« on: June 25, 2012, 10:01:42 pm »
Hi,
I am trying to rotate a rectangle around its center in SFML 1.6, but it is rotating around about the upper left corner of the window.
#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML rect rotation");
    float angle(0.f);
    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
            if (Event.Type == sf::Event::Closed)
                App.Close();
        App.Clear();
        sf::Shape thing(sf::Shape::Rectangle(300, 300, 500, 500, sf::Color::Green));
        thing.SetCenter(100, 100);
        thing.Rotate(angle);
        angle += 0.1f;
        App.Draw(thing);
        App.Display();
    }
}
Any idea what I am doing wrong? :)
Regards,
Dobi

2
Graphics / [solved] Resizing the view with the window
« on: June 22, 2012, 11:41:02 am »
Hi,

I want my view to scale with my window, so that I actually see more of my scene when the window is maximized. My test code looks as follows:
#include <SFML/Graphics.hpp>
int main()
{
        sf::RenderWindow App(sf::VideoMode(640, 480), "Resize test");
        while (App.IsOpened())
        {
                sf::Event Event;
                while (App.GetEvent(Event))
                {
                        if (Event.Type == sf::Event::Closed)
                                App.Close();
                        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                                App.Close();
                        if (Event.Type == sf::Event::Resized)
                                App.SetView(sf::View(sf::FloatRect(0.f, 0.f,
                                                static_cast<float>(App.GetWidth()),
                                                static_cast<float>(App.GetHeight()))));
                }
                App.Clear();
                App.Draw(sf::Shape::Rectangle(100.f, 100.f, 300.f, 300.f, sf::Color::Blue));
                App.Draw(sf::Shape::Rectangle(200.f, 200.f, 400.f, 400.f, sf::Color::Red));
                App.Display();
        }
        return EXIT_SUCCESS;
}
The problem is, that nothing is visible any more (all black) after the window's size is changed.
Is this some strange behaviour of my PC or am I just doing something wrong? :)
(I am using SFML 1.6 with Visual C++ 2010 express at the moment.)

Regards,
Dobi

Pages: [1]
anything