Alan
Alan

Reputation: 3017

Where can I find documentation on the OpenGL shader function texture2DRect()?

I'm normally a self-sufficient Googler, but I can't find any documentation on the OpenGL shader function texture2DRect(). Has anyone come across this before?

It's being used in some sample code for writing shaders in openframeworks, so I know it exists, and it works, just can't find any official docs on it. Where can I learn more about this function?

Upvotes: 5

Views: 7624

Answers (2)

Brad Larson
Brad Larson

Reputation: 170309

texture2DRect() is an OpenGL shading language function that I believe is added by the ARB_texture_rectangle extension in order to support rectangular, non-power-of-two textures.

To use it, you'll need to set up a sampler2DRect uniform in your shader, then have texture2DRect() grab a color from that just like you would with texture2D(). In a Mac application that I have using this, I needed to create my OpenGL texture using GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.

Kos had to point this out to me in response to my question here.

Upvotes: 2

Dr. Snoopy
Dr. Snoopy

Reputation: 56347

That function is used to sample a 2D Texture Rectangle (A NPOT texture target), and it's specified in "Additions to version 1.10.59 of the OpenGL Shading Language specification" of the GL_ARB_texture_rectangle extension.:

Add to section 8.7 "Texture Lookup Functions"

Syntax:

    vec4 texture2DRect(sampler2DRect sampler, vec2 coord)
    vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord)
    vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord)

Description:

    "Use the texture coordinate coord to do a texture lookup in the
    rectangle texture currently bound to sampler.  For the projective
    ("Proj") version, the texture coordinate (coord.s, coord.t) is
    divided by the last component of coord.  The third component of
    coord is ignored for the vec4 coord variant.

    No "bias" parameter or "Lod" suffixed functions for rectangle
    textures are supported because mipmaps are not allowed for
    rectangular textures."

Upvotes: 8

Related Questions