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

Author Topic: sf::Image Problem [Solved]  (Read 2446 times)

0 Members and 1 Guest are viewing this topic.

Suicidal

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Image Problem [Solved]
« 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]
« Last Edit: October 27, 2012, 05:24:26 pm by Suicidal »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image Problem
« Reply #1 on: October 26, 2012, 04:55:37 pm »
You probably use it as ARGB whereas sf::Image uses RGBA.
Laurent Gomila - SFML developer

Suicidal

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Image Problem
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image Problem
« Reply #3 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?
Laurent Gomila - SFML developer

Suicidal

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Image Problem
« Reply #4 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.
« Last Edit: October 26, 2012, 06:36:14 pm by Suicidal »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image Problem
« Reply #5 on: October 26, 2012, 06:46:22 pm »
I don't think it is transparent, it rather looks like a depth-buffer problem.
Laurent Gomila - SFML developer

Suicidal

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::Image Problem
« Reply #6 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();
}
 

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: sf::Image Problem [Solved] OpenGL z-buffer Problem [Active]
« Reply #7 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...
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

 

anything