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

前提是你 提交于 2019-12-07 10:04:10

问题


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?


回答1:


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."



回答2:


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.



来源:https://stackoverflow.com/questions/6736531/where-can-i-find-documentation-on-the-opengl-shader-function-texture2drect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!