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

Author Topic: [Android] White Sprites  (Read 3169 times)

0 Members and 1 Guest are viewing this topic.

darrit

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
[Android] White Sprites
« 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();
    }
}
 

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [Android] White Sprites
« Reply #1 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [Android] White Sprites
« Reply #2 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.
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: [Android] White Sprites
« Reply #3 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)?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: [Android] White Sprites
« Reply #4 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

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: [Android] White Sprites
« Reply #5 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?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: [Android] White Sprites
« Reply #6 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

Hapax

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

darrit

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: [Android] White Sprites
« Reply #8 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [Android] White Sprites
« Reply #9 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'')
Laurent Gomila - SFML developer