Search code examples
javaandroidlibgdx

Texture.setEnforcePotImages(false); cannot resolve mothed error under android studio


I am using libGDX tutorial for the first time under android studio. My IDE is android studio and have setup the initial gradle under Android Studio successfully and tested it on the emulator.

The tutorial says to use Texture.setEnforcePotImages(false); since i am using 800x480 pixels for my canvas. However, i get error "cannot resolve method" and there is no IntelliSense setEnforcePotImages when I click Texture.

why does it says that. I have all my libraries included as per the tutorial.

Hope someone can help.

Thanks Hwq


Solution

  • That method has been removed. Texture.setEnforcePotImages(false) was a method to disable libGDX's protection against issues with image files that did not have a size of power of two (1, 2, 4, 8, 16, 32, 64, 128, 256 and so on). This protection was sometimes enabled because some (older) devices don't support image files that don't have a size of power of two (POT). This was only the case for OpenGL ES version 1.x. For OpenGL ES version 2.x and above this restriction (and libGDX's protection) doesn't apply. As of version 1.0 of libGDX support OpenGL ES v1.x (including this method) has been removed.

    You can use image files which don't have a size of power of two. Note however that some functionality (like texture wrapping) might still require power of two sized image files.

    Also have a look at https://github.com/libgdx/libgdx/wiki/Texture-packer. You'd typically pack multiple images into a single larger file. While your images aren't POT sized, you could (and should) still pack them into a POT sized texture.