Search code examples
opengltextures

Do rectangle textures really require the GL_ARB_TEXTURE_RECTANGLE extension in OpenGL 4.3?


I'm looking for the best (as in "most natural" or "most efficient") way to render simple images pixel-by-pixel using modern OpenGL.

Since I do not want mip-mapping, I turned to rectangle textures as the - as I presumed - natural choice for this task.

I was surprised however that glCompileShader() refuses to accept my call to texture2DRect() in the fragment shader unless I enable the extension GL_ARB_TEXTURE_RECTANGLE.

I wasn't expecting that, as I'm using modern OpenGL (I'm specifying #version 430) and the OpenGL reference sheet at https://www.khronos.org/files/opengl44-quick-reference-card.pdf does not mention the need for an extension.

To add to the confusion, the shader compiler accepts my uniform declaration uniform sampler2DRect sampler; without even a warning.

Is this a bug in my OpenGL driver? (I'm running version 340.52 of the NVidia driver on Windows 8.1, on a GeForce GTX 760).


Solution

  • Just use the GLSL built in function texelFetch to address texture image pixels by the absolute integer coordinates.