我在哪里可以找到关于OpenGL着色器函数texture2DRect()的文档?

时间:2011-07-18 17:03:43

标签: opengl glsl

我通常是一个自给自足的Google员工,但我找不到有关OpenGL着色器函数texture2DRect()的任何文档。有没有人遇到过这个?

它被用在一些示例代码中,用于在openframeworks中编写着色器,所以我知道它存在,并且它有效,只是找不到任何官方文档。我在哪里可以了解更多有关此功能的信息?

2 个答案:

答案 0 :(得分:8)

该函数用于对2D纹理矩形(NPOT纹理目标)进行采样,并在GL_ARB_texture_rectangle extension的“OpenGL着色语言规范的1.10.59版本的附加内容”中指定。:

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

答案 1 :(得分:2)

texture2DRect()是一个OpenGL着色语言函数,我相信它是由ARB_texture_rectangle扩展添加的,以支持矩形,非幂2的纹理。

要使用它,您需要在着色器中设置sampler2DRect制服,然后让texture2DRect()从中获取颜色,就像使用texture2D()一样。在我使用它的Mac应用程序中,我需要使用GL_TEXTURE_RECTANGLE_EXT而不是GL_TEXTURE_2D来创建我的OpenGL纹理。

科斯不得不在回答我的问题here时向我指出这一点。