开发者

Persistence of texture parameters

I use glBindTexture() to bind a previously created texture. After the glBindTexture() call I use glTexParameteri() to set MIN and MAG filter. No problem so far.

Are those parameters I set using glTexParameteri() bound to the texture itself or are they lost if I bind another texture. Do i have to set them again?

glGenTexture(1, &tex1);
glGenTexture(1, &tex2);

/* bind tex1 and开发者_StackOverflow中文版 set params */
glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex1);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, ...);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

/* do something */

/* bind tex2 and set params */
glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex2);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, ...);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

/* do something */

/* bind tex1 again */
glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex1);

/* do i have to set the parameters from above again or are they stored with tex1? */


They're kept. The manual page for glBindTexture() says:

While a texture is bound, GL operations on the target to which it is bound affect the bound texture.

Since the first parameter of glTexParameter() is a target, they apply to the bound object just like glTexImage().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜