SFML community forums

Help => Graphics => Topic started by: Suicidal on October 26, 2012, 04:36:59 pm

Title: sf::Image Problem [Solved]
Post by: Suicidal on October 26, 2012, 04:36:59 pm
When i use sf::Image instead of another bitmap loader textures drawn in blue and becomes transparent. Any solutions?

Thanks.

[attachment deleted by admin]
Title: Re: sf::Image Problem
Post by: Laurent on October 26, 2012, 04:55:37 pm
You probably use it as ARGB whereas sf::Image uses RGBA.
Title: Re: sf::Image Problem
Post by: Suicidal on October 26, 2012, 05:47:47 pm
You probably use it as ARGB whereas sf::Image uses RGBA.

I'm not experinced in computer graphics. Is there a color profile for gimp for this conversion? Should I convert pixels one by one?

Thanks for your help.
Title: Re: sf::Image Problem
Post by: Laurent on October 26, 2012, 06:32:31 pm
You don't have to change the image itself, just how you pass it to the OpenGL texture (if that's what you use).

Could you please give more details about your program, show some code?
Title: Re: sf::Image Problem
Post by: Suicidal on October 26, 2012, 06:34:05 pm
                gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texture.getSize().x, texture.getSize().y,
                        GL_BGRA_EXT, GL_UNSIGNED_BYTE, texture.getPixelsPtr());

Changing GL_BGRA_EXT to GL_RGBA fixed color problem but its still transparent.

Thanks.
Title: Re: sf::Image Problem
Post by: Laurent on October 26, 2012, 06:46:22 pm
I don't think it is transparent, it rather looks like a depth-buffer problem.
Title: Re: sf::Image Problem
Post by: Suicidal on October 26, 2012, 11:18:20 pm
Here is my main loop

while(mainWindow.isOpen())
{
        glEnable(GL_DEPTH_TEST);
        glDepthMask(GL_TRUE);
        glEnable(GL_CULL_FACE);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);

        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();

        gluPerspective(60.0f, 0.f, 0.1f, 10.0f);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        draw();

        mainWindow.display();
}
 
Title: Re: sf::Image Problem [Solved] OpenGL z-buffer Problem [Active]
Post by: masskiller on October 27, 2012, 04:58:00 am
I'm no OpenGL expert myself, but enabling over and over in the main loop doesn't seem like a good idea.
Same with the declaration of a perspective, you only need it once unless you want to change it. Also sometimes calling glMatrixmode and glLoadIdentity in the loop may make it so that your program doesn't display anything even when it's working (though for some things it's required, other times it messes up your openGL drawing).

Try taking all that shouldn't be looping out of the loop to see if it works. It would also be good to know what the draw function does...