SFML community forums

Help => Graphics => Topic started by: JeZ-l-Lee on March 02, 2009, 03:00:03 pm

Title: .SetBlendMode(sf::Blend::None); has no effect...
Post by: JeZ-l-Lee on March 02, 2009, 03:00:03 pm
Hi,

Trying to turn OFF blending for a Sprite.

MySprite.SetBlendMode(sf::Blend::None); has no effect...

Using current SFML from SVN

Any help would be appreciated...
Title: .SetBlendMode(sf::Blend::None); has no effect...
Post by: Laurent on March 02, 2009, 04:40:25 pm
Can you please give more details?
Title: .SetBlendMode(sf::Blend::None); has no effect...
Post by: JeZ-l-Lee on March 02, 2009, 05:08:07 pm
Quote from: "Laurent"
Can you please give more details?


Hi,

Yes here is some more detail:
(OS is Windows Vista 32bit SP1)


(http://silentheroproductions.com/images/BLENDING_issue.gif)

Code: [Select]
//----------------------------------------------------------------------------------------------------------
bool Tiles::LoadAndInitializeTiles(void)
{
int posX;
int posY;
int tileWidth = 32;
int tileHeight = 32;
sf::IntRect rect;
sf::Color transparentColor;
sf::Color colorToSetNoTransparency(126, 0, 0, 255);

SelectedTile.Resize(32, 32);
SelectedTile.SetColor( sf::Color(0, 0, 0, 128) );

TilesSheet = new sf::Image;
if (!TilesSheet->LoadFromFile("data/graphics/in_game/SMBEnginE.png"))
return EXIT_FAILURE;

posX = 0;
posY = 0;

transparentColor = TilesSheet->GetPixel(posX, posY);

rect.Top = posY + 1;
rect.Bottom = posY + 1 + tileHeight;
rect.Left = posX + 1;
rect.Right = posX + 1 + tileWidth;

if (!TilesArray[0].TilesImage.LoadFromFile("data/graphics/in_game/32x32.png"))
return EXIT_FAILURE;

TilesArray[0].TilesImage.Copy(*TilesSheet, 0, 0, rect);

if (transparentColor != colorToSetNoTransparency)
TilesArray[0].TilesImage.CreateMaskFromColor(transparentColor, 0);

TilesArray[0].TilesSprite.SetImage(TilesArray[0].TilesImage);

TilesArray[0].TilesSprite.SetBlendMode(sf::Blend::None);

TilesArray[0].TilesSprite.SetCenter(TilesArray[0].TilesSprite.GetSize() / 2.f);

delete TilesSheet;
return EXIT_SUCCESS;
}
//----------------------------------------------------------------------------------------------------------
Title: .SetBlendMode(sf::Blend::None); has no effect...
Post by: Laurent on March 02, 2009, 05:21:27 pm
I think you misunderstand what the blend mode is ;)

Here it's working perfectly, otherwise your transparent white would be transparent. If you're talking about disabling the pixel bilinear filter, you should rather try calling SetSmooth(false) on your image.
Title: .SetBlendMode(sf::Blend::None); has no effect...
Post by: JeZ-l-Lee on March 02, 2009, 05:25:36 pm
Quote from: "Laurent"
I think you misunderstand what the blend mode is ;)

Here it's working perfectly, otherwise your transparent white would be transparent. If you're talking about disabling the pixel bilinear filter, you should rather try calling SetSmooth(false) on your image.



YES, it works now by calling the other function!!!!

Thanks man, was trying to get this to work for 3 hours....