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 - Kened

Pages: [1]
1
Graphics / [solved] sfml2 - Origin of shapes
« on: August 24, 2011, 11:03:04 pm »
Thank you very much for your answer!
I blindly assumed that
Code: [Select]
sf::Shape line1 = sf::Shape::Line(300.f, 100.f, 350.f, 100.f, 1.f, sf::Color::Blue);
means "Make a shape with two points, with origin(0,0) relative to the shape, which is (300,100) in absolute coordinates in this case".
If only I had carefully read sf::Shape's detailed description. Sorry.

2
Graphics / [solved] sfml2 - Origin of shapes
« on: August 24, 2011, 08:42:54 pm »
Hi, I've noticed something strange and I'm sorry if I overlooked something.
The documentation says
Quote
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a drawable object is (0, 0).

This is true for sprites. However, when I was trying to rotate a line, I've noticed that shapes use the RenderWindow's 0, 0 point as origin. Is this at all intended behavior? It is not mentioned anywhere I've looked.
For instance, the following code:
Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow app(sf::VideoMode(400, 400, 32), "Lines");

    sf::Shape line1 = sf::Shape::Line(300.f, 100.f, 350.f, 100.f, 1.f, sf::Color::Blue);
    sf::Shape line2 = sf::Shape::Line(300.f, 100.f, 350.f, 100.f, 1.f, sf::Color::White);

    line1.SetRotation(10.f);
    line2.SetRotation(20.f);

    while (app.IsOpened())
    {
        sf::Event event;
        while (app.PollEvent(event)) {}

        app.Clear(sf::Color::Black);
        app.Draw(line1);
        app.Draw(line2);
        app.Display();

        //if I add these two lines, I can see the shapes orbiting around the top-left corner
        line1.Rotate(0.1f);
        line2.Rotate(0.1f);
    }

    return 0;
}

produces this:

To get the desired (and expected) effect, I'd have to do:
Code: [Select]

    sf::Shape line1 = sf::Shape::Line(300.f, 100.f, 350.f, 100.f, 1.f, sf::Color::Blue);
    sf::Shape line2 = sf::Shape::Line(300.f, 100.f, 350.f, 100.f, 1.f, sf::Color::White);
    line1.SetOrigin(300.f, 100.f);
    line1.Move(300.f, 100.f);
    line2.SetOrigin(300.f, 100.f);
    line2.Move(300.f, 100.f);
    line1.SetRotation(10.f);
    line2.SetRotation(20.f);

which feels very unnatural.

Am I doing something wrong? Did I miss something? I'd expect some mention of this in the documentation.

3
SFML projects / Thor C++ Library – An SFML extension
« on: June 21, 2011, 09:56:09 am »
Oh, so that was the stupid mistake I made. Thank you, it works now.

4
SFML projects / Thor C++ Library – An SFML extension
« on: June 20, 2011, 07:22:22 pm »
First of all, I'm C#.NET-spoiled guy so this is my first time doing something like building libraries. Therefore it's very likely I've made some dumb mistake along the way.
I built and installed sfml2 (the recommended version) without issues and tested some basic stuff.
Then I made makefile (following the tutorial) for the Thor library (the latest from SVN), but when I tried to build it (MinGW 4.4.1) I got this:
Code: [Select]
c:\dev\thor-build>mingw32-make
[  2%] Building CXX object src/CMakeFiles/thor.dir/Random.cpp.obj
C:\dev\svn\thor\src\Random.cpp:96: error: 'Uint64' in namespace 'sf' does not name a type
C:\dev\svn\thor\src\Random.cpp: In member function 'sf::Uint32 thor::<unnamed>::Engine::operator()()':
C:\dev\svn\thor\src\Random.cpp:71: error: 'Uint64' in namespace 'sf' does not name a type
C:\dev\svn\thor\src\Random.cpp:73: error: 'x' was not declared in this scope
C:\dev\svn\thor\src\Random.cpp:73: error: 'a' was not declared in this scope
C:\dev\svn\thor\src\Random.cpp: In member function 'void thor::<unnamed>::Engine::seed(sf::Uint32)':
C:\dev\svn\thor\src\Random.cpp:80: error: 'x' was not declared in this scope
mingw32-make[2]: *** [src/CMakeFiles/thor.dir/Random.cpp.obj] Error 1
mingw32-make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
mingw32-make: *** [all] Error 2

Pages: [1]
anything