1
\$\begingroup\$

Ok, So I have a game I have been working on for a few months now and I am now stumped beyond belief. My friend who has spent days working on this background gave it to me and I put it in my game. On the phone the background draws fine, on the PC the background draws fine but my tablet refuses to draw the background and I have no idea why. The game was pretty much built for tablet and I really need an answer because I want to release this to google play soon to make it worth while for the friends who put the effort into this game. Do any of you have any idea why this isn't working? The file for the background is pretty big is that the reason (2500x2500)?

Here is the code to the drawing method

    //Render Function When in Play Mode
private void renderPlayMode(){

    //Draw background
    background.render(mainBatch);

    foreground.render(mainBatch);

}

The background.render and the foreground.render are the two functions that cause the game to go black on the tablet. I really need an answer, please!

EDIT

Ok, so the code above is the code that screws up the tablet and makes the screen black. Because the foreground.render is the last thing that is drawn it makes the entire screen black and if I comment out that line the background.render just makes the entire background black and no drawing.

\$\endgroup\$
  • \$\begingroup\$ Could you post a minimal example? \$\endgroup\$ – Anko Jun 17 '14 at 19:35
  • \$\begingroup\$ Sorry, don't know what you mean? What do you mean by minimal example? \$\endgroup\$ – G3tinmybelly Jun 17 '14 at 19:36
  • \$\begingroup\$ I mean that all the game object rendering in the code seems irrelevant to the problem. What's the minimal code necessary to recreate the bug? \$\endgroup\$ – Anko Jun 17 '14 at 19:37
  • 1
    \$\begingroup\$ I figured out the issue it was the file size that was too large 2500 by 2500 does not work for tablets it looks like. So I minimize the size to 2000 by 2000. But now a new problem arises but that's a different story \$\endgroup\$ – G3tinmybelly Jun 17 '14 at 20:13
  • 1
    \$\begingroup\$ Good you found it! You could add that as an answer in itself. It might help people who come along wondering the same later. (It's totally OK to answer your own question.) If you were getting any particular error, that might help future searchers too. \$\endgroup\$ – Anko Jun 17 '14 at 20:17
2
\$\begingroup\$

I had a similar issue on Android with LibGDX a few month ago. Not sure if it is related though, but that's obviously something one should be aware of.

A common issue :

On low cost devices or old devices, when the size of the original texture file was superior to 2048*2048px, the texture won't load. And on the worst devices i have seen, 1024*1024px textures was the limit.

This limit depends on your hardware, and (if i'm correct) on the openGL version.

You can get the max texture size for your device with this piece of code :

IntBuffer buf = BufferUtils.newIntBuffer(16);
Gdx.gl.glGetIntegerv(Gdx.gl.GL_MAX_TEXTURE_SIZE, buf);
int maxSize = buf.get();
Gdx.app.log("GL", "Max openGL texture size : " + String.valueOf(maxSize));

By running this code, i know that my PC can load 16K (16384*16384px) textures, my Samsung GS4 can load 4K (4096*4096px) textures, and my LG Optimus Black from 2011, can only load 2K (2048*2048px) textures.

Solutions :

  1. Only use 1024*1024px texture that are probably supported by any device running the android system. (Bad solution)

    or

  2. Distribute your graphics assets in differents resolution categories (ld, md, hd, uhd for example), if you want to be able to target low cost devices while rendering perfect hd graphics on the high-end ones. (Best solution, that needs some work)

    or

  3. Using 2048*2048px may be a good compromise, that allows you to render perfectly on GS4, GS5, Z2 ... etc (but on not the Nexus 10, that could benefit from 2560*1600px textures), while being able to also load textures on most devices. But expect complaints from users. (Lazy solution)

\$\endgroup\$
  • \$\begingroup\$ This is extremely helpful to know! Thanks this is great! \$\endgroup\$ – G3tinmybelly Jun 17 '14 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.