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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - vlanore

Pages: [1]
1
Graphics / [solved] [2.1] Can't get PNG transparency to work
« on: March 01, 2014, 09:57:11 pm »
Hello,
I'm new to SFML and I'm trying to draw sprites with transparency (mostly to draw things on top of other things).
From the tutorials and forum topics I've browsed, I understand that PNG texture transparency should work without doing anything special.

Here is what I've done (slightly modified base tuto):
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::Texture myTexture;
    myTexture.loadFromFile("./textures.png");
    sf::Sprite mySprite;
    mySprite.setTexture(myTexture);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear(sf::Color::Blue);
        window.draw(mySprite);
        window.display();
    }
    return 0;
}

And when I run it, at the places where my texture is transparent I see a white rectangle instead of the blue background. I'd like the background (or anything drawn before) to be displayed through the transparent parts of the image. I have tried various PNG images with no success.

Did I do something wrong or miss anything? Is this a bug/config problem on my end?

I'm running the git version of SFML compiled by hand on debian on a virtual machine (3d acceleration working,  no direct rendering) and with an ATI radeon 6950.

Any help is welcome :)

EDIT: my problem was solved (see my last post below) and was VirtualBox-related.

Pages: [1]
anything