SFML community forums

Help => Graphics => Topic started by: darrit on August 13, 2015, 11:35:46 pm

Title: [Android] White Sprites
Post by: darrit on August 13, 2015, 11:35:46 pm
Hello guys,

my problem is that i have white sprites on an android device.
The same issue appears with the SFML android example on this device.

I searched so much for solutions but nothing was useful.

Device: Samsung Galaxy Tab 3 {[( HELLO KITTY - Version )]} ^^
Android Version: 4.xx

I tried the example on many devices (smart phones like S4, S5, Galaxy Nexus and on Asus Tablet).
But only on the Galaxy Tab 3 i get this issue.

SFML Android Example:

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>


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

    sf::Texture texture;
    if(!texture.loadFromFile("image.png"))
        return EXIT_FAILURE;

    sf::Sprite image(texture);
    image.setPosition(0, 0);
    image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);

    sf::Music music;
    if(!music.openFromFile("canary.wav"))
        return EXIT_FAILURE;

    music.play();

    sf::View view = window.getDefaultView();

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

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

            if (event.type == sf::Event::Resized)
            {
                view.setSize(event.size.width, event.size.height);
                view.setCenter(event.size.width/2, event.size.height/2);
                window.setView(view);
            }
        }

        if (sf::Touch::isDown(0))
        {
            sf::Vector2i position = sf::Touch::getPosition(0);
            image.setPosition(position.x, position.y);
        }

        window.clear(sf::Color::White);
        window.draw(image);
        window.display();
    }
}
 
Title: Re: [Android] White Sprites
Post by: Rhimlock on August 14, 2015, 11:03:50 am
Which Tablet is it?
As far as i know the 10" Galaxy Tab 3 has an Intel Atom inside, while the 7" and 8" are ARM.
Title: Re: [Android] White Sprites
Post by: Laurent on August 14, 2015, 11:09:01 am
Quote
{[( HELLO KITTY - Version )]} ^^
That's the problem. This version only allows pink sprites to be displayed.
Title: Re: [Android] White Sprites
Post by: Mario on August 14, 2015, 11:20:17 am
Anything written to logcat while you try to load a texture? Can you render colored quads (like sf::Rectangle)?
Title: Re: [Android] White Sprites
Post by: AlexAUT on August 14, 2015, 12:18:37 pm
I had the same issue with my Amazon Fire HDX7 Tablet, I had to wait for a sf::Event::GainedFocus event, it looks like the context hasn't been created until this event gets triggered (on some devices). Every opengl call before the event may crash the application or does not work, at least on my device.

I fixed it for my tablet with this stupid workaround you should insert it directly after the RenderWindow creation (was a bit angry when i've written the code  ;D) https://github.com/AlexAUT/AwEngine/blob/master/include/aw/application.cpp#L179



AlexAUT
Title: Re: [Android] White Sprites
Post by: Mario on August 14, 2015, 03:09:09 pm
Okay, that's interesting. Do you know whether that's some intentional behavior or possibly some kind of odd race condition?
Title: Re: [Android] White Sprites
Post by: AlexAUT on August 14, 2015, 03:32:10 pm
I wrote some time ago a simple framwork (basic event handling, context creation). And with the NativeAppGlue (which SFML doesn't use iirc) you have to wait for the "createWindow" event too. Because you won't get the context before. But I don't know if SFML waits for the createWindow/init_window event from Android? Hadn't such a close look at the source of the android port sadly.


AlexAUT
Title: Re: [Android] White Sprites
Post by: Hapax on August 14, 2015, 03:34:55 pm
Quote
{[( HELLO KITTY - Version )]} ^^
That's the problem. This version only allows pink sprites to be displayed.
I must admit that even I laughed at this  :-[
Title: Re: [Android] White Sprites
Post by: darrit on August 14, 2015, 05:32:15 pm
Thanks for the answers .
I think to that the Hello Kitty version is the real problem xD.

@ Rhimlock
I compiled the application still for the ARM achitecture maybe this is really the solution to compile it for Intel Atom too.

I will test it.
Title: Re: [Android] White Sprites
Post by: Laurent on August 14, 2015, 06:04:53 pm
As far as I remember, Intel Atom can "emulate" ARM binaries so that you don't have to compile differently for this platform. At least, every ARM binary that I compiled at work runs fine on our Intel Atom device (Asus Memo pad 7'')