3

This is for a 2D game with OpenGL:

Is it with using OpenGL possible to display a texture absolutely unfiltered, not streched or blurred?

So that when I have a BMP and convert it into an OpenGL texture, and then retrieve that texture and convert it back, I have no modifications or quality / data loss?

Derailed
  • 41
  • 1

2 Answers2

7

Sure, just disable filtering, that's made by setting the GL_MIN_FILTER and the GL_MAG_FILTER to GL_NEAREST. Also make sure that you draw the texture in a appropiate size so that texels are the same size as pixels.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
3

As Matias said previously - one thing is to set GL_MIN_FILTER and GL_MAG_FITLER to GL_NEAREST (via glTexParameter*).

But for pixel-perfect rendering, there's another important thing- you don't want your texture to be rescaled to power-of-two. The easiest way is to specify the texture via the binding target GL_TEXTURE_RECTANGLE instead of GL_TEXTURE_2D. On such bound texture, the texture coordinates are not in range (0..1,0..1) as usually, but (0..w, 0..h) instead. You can have per-texel indexing easily this way.

Kos
  • 70,399
  • 25
  • 169
  • 233