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.


Messages - klfwip

Pages: [1]
1
Graphics / Re: png Transparency problem in sfml2
« on: August 27, 2012, 10:49:26 am »
pdinklag, I did not know that leaving the alpha channel to defaults when clearing was the norm, I will do that in the future though. Unfortunately it seems to have no effect on the problem.

eXpl0it3r, I ran your code and the output was 8 in linux. In windows it just said "undefined reference to 'glGetIntegerv@8' " which I will try to figure out later. I have not used windows for development much, so there is probably just something missing.

I just ran the exact same code, with the same png in windows 7, and everything works fine. I also tried it on a computer with an Nvidia card in linux and it works. My main computer has a fairly new AMD card, which generally means you are going to have a plethora of driver issues, but I still hope I can find a way to get this working. I will keep playing with drivers and SFML builds to see if I can get this working properly.

2
Graphics / png Transparency problem in sfml2
« on: August 27, 2012, 09:12:37 am »
I have been enjoying SFML2 since switching over recently, but I cannot get transparency to work at all. Searching the forums and google has not turned up anything yet on why my attempts are not working. I have been trying to get this working for hours so if you can give me any suggestions on what to try next I would really appreciate it.

To summarize the problem: I am trying to load a png (attached), created in gimp which has a transparent background. In any photo viewer the checkered pattern shows up indicating that the background is being saved transparently correctly. I have tried playing around with each possible RenderTarget blend mode when drawing and this does not seem to help, and regardless from what I have read sfml automatically uses the alpha channels in png files. Ideally I want the transparent part of the sprite to not block the images behind it, as it is there is a black rectangle around every sprite. The simplest demonstration I can make of this is as follows:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow app(sf::VideoMode(960,540,32),"SFML alpha test");
    sf::Event event;
    sf::Texture texture;
    sf::Sprite sprite1;
    sf::Sprite sprite2;

    texture.loadFromFile("alpha2.png");
    sprite1.setTexture(texture);
    sprite2.setTexture(texture);

    sprite2.setPosition(50,50);

    while(app.isOpen())
    {
        while (app.pollEvent(event))
        {
            if (event.type==sf::Event::Closed)
                    app.close();
        }

        app.clear(sf::Color(128,128,128,128)); //set background to grey
        app.draw(sprite1);
        app.draw(sprite2);
        app.display();
    }
    return 0;
}
 


If it makes any difference, I am using g++ and Code::Blocks from the Ubuntu repositories, and sfml 2 was compiled from the snapshot  named "LaurentGomila-SFML-18f1b62"; the most recent version of SFML at the time of posting.

[attachment deleted by admin]

Pages: [1]
anything