SFML community forums

Help => Graphics => Topic started by: dejavu on February 13, 2016, 07:43:24 pm

Title: [Android] White sprite issue
Post by: dejavu on February 13, 2016, 07:43:24 pm
I'm trying to make simple Android application with SFML, but I have problems with rendering textures. When I was loading images, they appeared white. I have made simpler example which also reproduces white sprite at emulator:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(int argc, char *argv[])
{
        sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");

        sf::Image img;
        img.create(200,100,sf::Color::Red);

        sf::Texture texture;
        if(!texture.loadFromImage(img))
                return 0;

        sf::Sprite sprite(texture);
        sprite.setPosition(200,200);
        sprite.setOrigin(50,50);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event)) {}

                window.clear(sf::Color::Blue);
                window.draw(sprite);// WHY SPRITE IS WHITE?
                window.display();
        }
        return 0;
}

Could you tell me why it's not working correctly? Do I need to add some extra flags while compiling SFML libraries or link extra libraries into final application?
Title: Re: [Android] White sprite issue
Post by: dejavu on February 13, 2016, 07:48:13 pm
Ok, I've found solution.

http://stackoverflow.com/questions/31087643/android-studio-avd-emulator

Solution was to enable "Use host GPU" for emulator :)
Title: Re: [Android] White sprite issue
Post by: Hapax on February 13, 2016, 10:05:24 pm
It's good that you fixed the problem but you should definitely be processing those events  :P