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

Author Topic: How to make transparent RenderTexture?  (Read 2674 times)

0 Members and 1 Guest are viewing this topic.

GOKOP

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to make transparent RenderTexture?
« on: September 26, 2016, 06:54:20 pm »
Hi,

I'm making a tile-based game where there are several layers of tiles on map, so player can be covered by tiles from higher layer. I also render tiles to texture slightly bigger than the screen, which is updated only when view gets close to it's edge. In order to make this layer effect I make two textures, one for tiles below player and one for tiles above him. The problem is that the upper texture needs to be transparent in places where there's no tiles, so tiles from lower texture can be seen, but RenderTexture seems to be initially black and I can't see a way to make it transparent.
Any ideas?

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: How to make transparent RenderTexture?
« Reply #1 on: September 26, 2016, 08:47:04 pm »
Clear it with a transparent colour:

renderTexture.clear(sf::Color::Transparent);
renderTexture.draw(stuff);
renderTexture.display();
 

GOKOP

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to make transparent RenderTexture?
« Reply #2 on: September 28, 2016, 04:03:01 pm »
I tried it and didn't help, but problem was somewhere else, already solved, but thanks anyway.

 

anything