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

Author Topic: sf::Texture::Update No Transperency  (Read 3707 times)

0 Members and 1 Guest are viewing this topic.

Ptlomej

  • Newbie
  • *
  • Posts: 48
    • ICQ Messenger - 353167418
    • View Profile
    • Local
sf::Texture::Update No Transperency
« on: February 25, 2012, 07:34:31 pm »
I using the Update function in Texture to copy Images randomly at randomly positions but the color dont work right i have Transperency pixel.

im using SFML 2.0

a screenshot to see waht i mean


Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
sf::Texture::Update No Transperency
« Reply #1 on: February 25, 2012, 10:28:51 pm »
Update replaces the texels at specified position. It doesn't do any blending. So if you have a texel with the color (255, 0, 0) and then use update with color (0, 255, 0) you don't get the color (255, 255, 0) but you get only the latest one (0, 255, 0) because we replaced the texel.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Texture::Update No Transperency
« Reply #2 on: February 25, 2012, 11:27:42 pm »
Does the original image contain an alpha channel with correct transparency? If so, it should work, and we'll need a complete and minimal example to see what's wrong.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
sf::Texture::Update No Transperency
« Reply #3 on: February 26, 2012, 04:13:12 am »
Quote from: "Laurent"
Does the original image contain an alpha channel with correct transparency? If so, it should work, and we'll need a complete and minimal example to see what's wrong.


No it wouldn't if he is using the textures update function right? The update function only copies new texels to the texture. That's at least what the documentation says. Because that means that the old texels would only be overwritten by the new ones coming in from what ever source he gives in to the function.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Texture::Update No Transperency
« Reply #4 on: February 26, 2012, 09:42:30 am »
If the copied pixels contain alpha, then the target texture will contain it too, so transparency is kept. But it is not applied during the copy, if that's what you meant.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
sf::Texture::Update No Transperency
« Reply #5 on: February 26, 2012, 07:02:31 pm »
Quote from: "Laurent"
If the copied pixels contain alpha, then the target texture will contain it too, so transparency is kept. But it is not applied during the copy, if that's what you meant.


Yeah that's what I meant, and it sounded like he was only using the sf::Texture::Update functions to generate the image? Correct me of course Ptlomej if I am wrong?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Ptlomej

  • Newbie
  • *
  • Posts: 48
    • ICQ Messenger - 353167418
    • View Profile
    • Local
sf::Texture::Update No Transperency
« Reply #6 on: February 26, 2012, 07:25:27 pm »
im do this

a example ;)
Code: [Select]

sf::Texture tTest;
sf::Image iTest1, iTest2;

iTest1.LoadFromFile("example.png"); //Transparent files!
iTest2.LoadFromFile("example2.png");

tTest.Create(1000,1000);
tTest.Update(iTest1,iRand(1000-iTest1.GetWidth(),1000-iTest1.GetHeight()));


ITS NOT ORIGINAL CODE ONLY EXAMPLE WAHT IM DO.

and i generate over 50 Stars for one 1000x1000 image
and then it will overlaps with the black Box from the image :>

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Texture::Update No Transperency
« Reply #7 on: February 26, 2012, 07:38:25 pm »
This is the expected behaviour.

To get the results that you want, you should rather use sf::Image::Copy (with the applyAlpha argument to true), and upload the composed image to the final texture at the end.
Laurent Gomila - SFML developer

 

anything