This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simple OpenGL texture glitches and Pixel Perfect questions.

Greetings,

I have a small issue with OpenGL texturing, which is not related to any GPU in particular. I've reproduced this problem with Radeon GPU and Mali GPU, so it's just a "I don't understand OpenGL" problem. However, I'm putting this in the ARM Mali graphics section, as it seems to be the most adequate section by elimination, and I'd like to know how this problem is called in OpenGL terms.

My problem is that when I use a texture atlas and apply a part of the texture atlas to a quad, it sometimes picks one more pixel from contiguous parts of the texture atlas.

The same quad displayed at different zones of the screen will glitch differently.

The problem tends to disappear when I use GL_NEAREST with GL_TEXTURE_???_FILTER, instead of GL_LINEAR. However, the texture become awfully pixelated then.

Buggy code

Here's an example of the code used :

psychic-octo-waffle/myy.c at master · Miouyouyou/psychic-octo-waffle · GitHub

The code basically generates two cards, divided in one opaque and two transparent parts, at two different parts of the screen (-0.02, 0 and 0.24, 0).

The non-converted atlas can be seen here. It's a set of 13x4 playings cards, 4 suits symbol, 4 turned cards and 4 backgrounds.

So, the normalised dimensions of each card part of the texture atlas are :

  • Width: 0.0625 (1/16)
  • Height: 0.25 (1/4)

I really doubt that these dimensions can generate rounding errors.

When executed, the code produces a window with two turned-around cards on the screen. Each one glitching slightly differently.

Here's the result :

two_cards.pngpixels.pngQuestions

So my questions are :

  • What triggers this problem exactly ?
  • What are the best way to achieve a nice Pixel Perfect texturing with OpenGL ?
  • Is this problem mentioned in the OpenGL ES 2.x specification ?
Parents Reply Children