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.


Messages - Dobi

Pages: [1]
1
Graphics / Re: rotate a rectangle around its center (SFML 1.6)
« on: June 26, 2012, 08:50:15 am »
Ah, great. Thank you very much. :)

2
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

3
Graphics / Re: [solved] Resizing the view with the window
« on: June 25, 2012, 09:15:32 am »
Yeah, it's valid standard c++. ;)
Quote
5.17 Assignment and compound assignment operators [expr.ass]
1 The assignment operator (=) and the compound assignment operators all group right-to-left. All require a
modifiable lvalue as their left operand and return an lvalue referring to the left operand.

4
General / Re: a problen when making .exe with release
« on: June 23, 2012, 04:11:49 pm »
2 - im a student at college and we all using SFML library.
all my colleagues did exactly what i did (linker configuration etc..) and for them it works fine.
Are your colleagues running the exact same code or are they just using the same configuration as you but for their own code?
If the second is true: Perhaps you are relying on behaviour of your compiler in debug mode (preinitialize otherwise randomly garbage filled memory ranges with zero or something like that). Or are u using sprite instances that were initialized (and thus point to) image instanced that already ran out of scope? Perhaps you can reduce your problem to a minimum example that reproduces this bevaviour for you and that you can post here.

5
Graphics / Re: Resizing the view with the window
« on: June 22, 2012, 12:12:41 pm »
Oh, I should have figured that our from the sources. Thank you for the quick help.

For future searchers:
#include <SFML/Graphics.hpp>
int main()
{
        sf::RenderWindow App(sf::VideoMode(640, 480), "Resize test");
        sf::View view(App.GetDefaultView());
        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(view = 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;
}

6
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]