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

Pages: [1]
1
Graphics / Re: Question about origin (once it's top left, once bottom left)
« on: December 13, 2013, 04:43:08 pm »
Thanks eXpl+it3r, my bad

2
Graphics / Question about origin (once it's top left, once bottom left)
« on: December 13, 2013, 04:07:07 pm »
Hello everybody!

My situation is as follows: I have 2 different RenderTextures. A circle is drawn onto texture A at the coordinates 100, 100. Then I draw texture A onto texture B using BlendMultiply. After doing that, I draw a rectangle onto texture B at the coordinates 100, 100. Finally, I render the resulting texture to a RenderWindow.
The code slightly looks like this (note that "stencil" is what I called texture A, and "frame" is texture B):
    sf::CircleShape circle( 10 );
    circle.setPosition( 100.0f, 100.0f );
    circle.setFillColor( sf::Color::White );

    sf::RenderTexture stencil;
    stencil.create( 1024, 768 );
    stencil.clear( sf::Color( sf::Color::Black ) );

    stencil.draw( circle );

    sf::RenderTexture frame;
    frame.create( 1024, 768 );
    frame.clear( sf::Color( 0, 128, 128 ) );

    frame.draw( sf::Sprite( stencil.getTexture() ), sf::RenderStates( sf::BlendMultiply ) );

    sf::RectangleShape rect( sf::Vector2f(20, 20) );
    rect.setPosition( 100.0f, 100.0f );
    rect.setFillColor( sf::Color::Green );

    frame.draw( rect, sf::RenderStates( sf::BlendAdd ) );

    renderWindow.draw( sf::Sprite( frame.getTexture() ) );
    renderWindow.display();
 

The circle is where expected - at the coordinates 100, 100 from the top left corner, but for some reason, the rectangle ends up at 100, 100 from the bottom left corner.
Here is the result:

I'd expect both primitives to overlap each other, since SFML's default origin is always located at 0, 0 and I never call a setOrigin function in my actual code.
Is this desired behavior? Is there any other way than doing a negative scaling, in order to line up texture B's origin to 0, 0?

Thanks in advance,
aVoX.

Pages: [1]
anything