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

Author Topic: [Solved] The best way to draw on texture  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Sakurazaki

  • Newbie
  • *
  • Posts: 31
  • `お嬢様を守ります!
    • MSN Messenger - sakurazaki.setsunita@gmail.com
    • View Profile
[Solved] The best way to draw on texture
« on: June 07, 2013, 03:17:46 am »
Hi there,

To deploy some of my images on my HUD I want to load into a texture an image, and
then render into this texture some text and numbers, and then assign this texture to a
Rectangle shape to render it to the RenderWindow.

I declared a sf::RenderTexture but I don't see how can I load to this RenderTexture the image
I want to have as base, so I was wondering if there is any technique to do this, or I'm focusing
wrong the matter and there is another better approach.

I'd be very glad to learn and to be enlighten in this matter.

Thank you!
« Last Edit: June 08, 2013, 01:48:51 am by Sakurazaki »
こんな私も変われるのならもし変われるのなら白になる

MrMuffins

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: The best way to draw on texture
« Reply #1 on: June 07, 2013, 07:29:26 am »
This is pretty much what RenderTexture is capable of.

Just draw your images to the rendertexture (Like your renderwindow), then pass the texture of it to your renderwindow (Or to the shape).

An example:


renderTexture.clear();

renderTexture.draw(Sprite1);
renderTexture.draw(Sprite2);
renderTexture.draw(Sprite3);
//...
renderTexture.display(); //call this otherwise the texture will be flipped on the Y axis

shapeRect.setTexture(&renderTexture.getTexture());

//draw
window.draw(shapeRect);

 

Sakurazaki

  • Newbie
  • *
  • Posts: 31
  • `お嬢様を守ります!
    • MSN Messenger - sakurazaki.setsunita@gmail.com
    • View Profile
Re: The best way to draw on texture
« Reply #2 on: June 07, 2013, 09:01:57 pm »
I see, ok thanks I somehow know how to handle it.

ありがとうございました!
こんな私も変われるのならもし変われるのなら白になる

 

anything