2

I am using an OpenGL texture on an iPad and get horrible artifacts on the device, while the Simulator shows all perfect and smooth. I believe the iPhone would show the same artifacts.

If I look at the headers, I see that once I include OpenGLES/ES2/gl.h, and in another file OpenGLES/ES1/*.h. Could this be a problem?

Or what may be the reason for the artifacts on the device?

Simulator:

screenshot from simulator

Real device:

screenshot from real device

Tommy
  • 99,986
  • 12
  • 185
  • 204
lambruscoAcido
  • 548
  • 4
  • 17
  • 1
    If you didn't import the correct headers, your application simply wouldn't compile and run, so that's out. How do you draw the texture? What kind of artifacts are you seeing (aliasing, etc.)? – Brad Larson Feb 04 '11 at 18:33
  • Could you also post what it should look like (the Simulator version)? That might help with diagnosing what's going on. – Brad Larson Feb 04 '11 at 20:00
  • The texture is drawn using glDrawArrays(GL_TRIANGLE_STRIP, ...) on a perspective view using frustum. In the simulator it shows nice sharp lines (http://i.imgur.com/JiF3z.png), on the device it shows the artifacts: http://i.imgur.com/DP6Y3.png – lambruscoAcido Feb 04 '11 at 20:04
  • That's a really odd drawing artifact. Are these PVRTC-compressed textures? Would you mind updating your question with the code you use to assign and bind the textures? There might be a clue somewhere in there. – Brad Larson Feb 05 '11 at 21:27
  • I use PNG images. I read PVRTC are faster, less memory-consuming, but less pixel-perfect, i.e. sharp. The code is very similar to http://code.google.com/p/cocos2d-iphone/source/browse/trunk/cocos2d/OpenGLSupport/Texture2D.m?r=242. – lambruscoAcido Feb 06 '11 at 16:31

2 Answers2

1

If you're using ES 2.0 then the first guess would be that you have a precision problem. The highp, mediump and lowp GLSL precision specifiers are hints, not absolute commands, as they specify the minimum required precision. It's quite possible that the simulator is giving you more precision than you've explicitly asked for but the device isn't.

If you haven't been scientific about it then try bumping everything to highp as a test, then slowly dial back down and check the results empirically.

Tommy
  • 99,986
  • 12
  • 185
  • 204
1

It could be the PNG optimization XCode applies during compilation (try turning it off); see How can I skip compressing one PNG?

While you can turn off PNG optimization/compression entirely using "Compress PNG Files" in your project settings (it's visible only if the project's Base SDK is set to a device SDK, not a simulator SDK), you don't want to do this! Read the link above for details on why, but the gist of it is that the optimization lets the iPhone skip some math that slows down PNG display.

Xcode will only optimize PNG image files that it knows about. To prevent a specific PNG from being optimized, you change its file type so Xcode no longer knows it's a PNG.

  1. Select the file in the project window.
  2. Choose File->Get Info.
  3. On the General tab, change File Type from image.png to file.
Community
  • 1
  • 1
patrick
  • 111
  • 7