Search code examples
openglopengl-eslibgdxtextures

Clarification needed for opengl texture size requirements


I'm developing a game (with libGDX, for Windows, Linux and Android, based on OpenGL 2). I know that there are some technical restrictions/requirements when it comes to texture sizes in OpenGL. But I've heard conflicting statements about these so I need some clarification:

  • Maximum texture size: I guess it's device dependent and somewhat about 2048x2048 should be save on halfway modern devices. Correct? Does this apply to the texture atlas or the whole texture object?
  • Power-of-two: OpenGL 2 supports textures with a edge length that is not a power of two. But I've heard that it might be safer to use such old-fashinod sized textures. Correct?
  • Bitmap size: Does the size of the bitmap (e.g. player_sprite.png) that is loaded into the game have anything to do with this maximum texture size or this power-of-two thing?

Solution

  • Maximum texture size: I guess it's device dependent and somewhat about 2048x2048 should be save on halfway modern devices. Correct? Does this apply to the texture atlas or the whole texture object?"

    The GLES2 spec dictates that max texture size must be 64x64 or better. The vast majority of Android and all iOS GLES2 devices are 2048x2048 or better. If you are able to drop down to 1024x1024 then you would be safe on pretty much all Android devices. For the desktop targets, 2048x2048 would be fine I think.

    Power-of-two: OpenGL 2 supports textures with a edge length that is not a power of two. But I've heard that it might be safer to use such old-fashinod sized textures. Correct?

    The thing to watch out for with non-power-of-two textures is that mipmapping and texture wrapping can be restricted. For that reason, I use power-of-two textures pretty much all the time. Using texture atlases is a good way to improve performance and reduce texture wastage as many awkwardly shaped textures can be combined into a single large power-of-two texture.

    Bitmap size: Does the size of the bitmap (e.g. player_sprite.png) that is loaded into the game have anything to do with this maximum texture size or this power-of-two thing?

    Not sure I understand the question. If you're going to be rendering the texture, then the png will presumably be loaded by the engine and put into an OpenGL texture, at which point it is subject to the rules relating to OpenGL max texture size and power-of-two.