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

Author Topic: [Android] White sprite issue  (Read 1636 times)

0 Members and 1 Guest are viewing this topic.

dejavu

  • Newbie
  • *
  • Posts: 4
    • View Profile
[Android] White sprite issue
« 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?

dejavu

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: [Android] White sprite issue
« Reply #1 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 :)

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: [Android] White sprite issue
« Reply #2 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*