0

Im trying to create a vertical scrolling game that has a level that is 380 X 10000. When I create the Texture to load the image I get this error: Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Texture width and height must be powers of two: 380x10000 I know i can get textures that are 512X512 to load fine. So what do i need to do to get this background image to load?

Assets{
public static Texture levels;
    public static TextureRegion levelsRegion;
}

Load{
    levels = loadTexture("data/levels.png"); <--------- Error occurs here.
        levelsRegion = new TextureRegion(background, 0, 0, 380, 10000); <--- Doesnt get to this point
}
Daahrien
  • 10,190
  • 6
  • 39
  • 71
andrew
  • 31
  • 1
  • 10

2 Answers2

1

WWOOoooo 380x10000?? Are you targeting cellphones?? In case you are using GL 1.1, using GL2.0 will solve your -not power of two- problem. Not quite sure if your device will be able to load that texture!

PS: In case it does, consider splitting your texture anyway. Not all devices are able to load a 10000 pixel wide texture!

aacotroneo
  • 2,170
  • 16
  • 22
  • Yeah im putting it on android. Is 512 x512 the biggest it can go? – andrew Dec 23 '12 at 00:27
  • 1
    It doesn't make sense to load the 10k pixels onto the GPU, if you're not going to display them all, so definitely cut the texture up into chunks. The hard limits on texture sizes are device-specific see http://stackoverflow.com/questions/8573178/limitation-on-texture-size-android-open-gl-es-2-0 – P.T. Dec 23 '12 at 05:31
1

Use

Texture.setEnforcePotImages(false)

Then you can load non-square (non power of two long to be precize) images. Although it's very bad idea to load such a big image. Just split it to smaller parts and use them when you need to display them on screen.

Makalele
  • 7,431
  • 5
  • 54
  • 81
  • +1 but I would give +10 ! this is the solution for me, for 1920x1080 px image –  Nov 05 '13 at 02:24