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.