1
\$\begingroup\$

I have such situation in my GDX game: I have a static class that manage my Drawables. It's a Singleton. I want to load all my Textures to it in order not to load them at every turn when I switch between screens (I know this is bad practice but I need this). I pack my resources into a TextureAtlas and load them. But when I pack and load more then some amount of Textures and try to use them some of them become black. Why this is happens? How can I bypass this unfortunate case. The size of my TextureAtlas (four images and one .txt file) is about 4MB.

\$\endgroup\$
  • \$\begingroup\$ I suggest that you learn to use a graphics debugger. The OpenGL debuggers are jokes compared to the D3D debugger, but there's some half-usable options: opengl.org/wiki/Debugging_Tools . Not using a graphics debugger is as silly as not using a code debugger: it's like trying to run a marathon with your shoes tied together. \$\endgroup\$ – Sean Middleditch Sep 6 '16 at 18:38
  • \$\begingroup\$ You know that texture sizes mostly need to be a power of 2 \$\endgroup\$ – Bálint Oct 15 '16 at 6:53
1
\$\begingroup\$

https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

Read this and especially Hardware Limitations part. Each phone/pc has it's max_texture_size and if exceeded - will print a black texture.

\$\endgroup\$
0
\$\begingroup\$

If you have bad texture coordinates this can happen. But it could be your texture atlas itself is wrong or you even try to use the wrong atlas. So check that as well.

\$\endgroup\$
0
\$\begingroup\$

Well. I hope this will help somebody. Some of my textures were black because of their resolution. The resolution of one of them was something about 1200x2400 pixels. If you have similar problem, try to juts decrease resolution of textures.

\$\endgroup\$
  • \$\begingroup\$ Please accept your own answer if that makes sense. \$\endgroup\$ – Engineer Sep 20 '17 at 5:25
0
\$\begingroup\$

I was also getting a black square when trying to draw some of the textures on IOS. It turns out the problem was that I was using MipMap and the image sizes were not a power of 2.

texture.setFilter(Texture.TextureFilter.MipMap, Texture.TextureFilter.Nearest);

See: https://github.com/libgdx/libgdx/issues/1296

OpenGL ES 2.0 support non-power-of-two images, but not for everything. Specifically, it does not require support for repeat or mipmap with non-power-of-two textures. If you require those features, you should use power-of-two images

\$\endgroup\$

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.