Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the scope of glTexParameter's in OpenGL?

Does glTexParamter act on all textures globally or only the texture that is currently bound.

For example, if I call this at the texture load:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

And this on another texture load:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

When I bind the first texture will it just use the last value I set (GL_CLAMP) or will it use the values originally set when the texture was bound?

like image 827
Justin Meiners Avatar asked Sep 04 '10 20:09

Justin Meiners


People also ask

What does glTexParameteri do?

The glTexParameter function assigns the value or values in params to the texture parameter specified as pname. The target parameter defines the target texture, either GL_TEXTURE_1D or GL_TEXTURE_2D. As more texture elements are sampled in the minification process, fewer aliasing artifacts will be apparent.

What is GL_ texture_ MIN_ FILTER?

Meaning. GL_TEXTURE_MIN_FILTER. The texture minifying function is used whenever the pixel being textured maps to an area greater than one texture element. There are six defined minifying functions. Two of them use the nearest one or nearest four texture elements to compute the texture value.

What does GL_ REPEAT do?

GL_REPEAT causes the integer part of the s coordinate to be ignored; OpenGL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to GL_CLAMP. Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT.


1 Answers

From the OpenGL FAQ:


21.070 How do texture objects work?

Texture objects store texture maps and their associated texture parameter state. They allow switching between textures with a single call to glBindTexture().

(...)

The following functions affect and store state in texture objects: glTexImage*(), glTexSubImage*(), glCopyTexImage*(), glCopyTexSubImage*(), glTexParameter*(), and glPrioritizeTextures(). Since the GLU routines for building mipmap pyramids ultimately call glTexImage*(), they also affect texture object state.Noticeably absent from this list are glTexEnv*() and glTexGen*(); they do not store state in texture objects.


Ergo, glTexParameter* affects only the bound texture.

like image 176
Kornel Kisielewicz Avatar answered Sep 24 '22 19:09

Kornel Kisielewicz