GLTEXPARAMETER(3G)
πΈ GLTEXPARAMETER(3G) πΈ
hiii bestie π«Ά welcome to the 3G manual page for the glTexParameter* girlies β all four of them β and honestly? they're lowkey the main-character energy of texture setup. no cap, they're just out here assigning values to texture parameters like it's nothing β¨ let's get into it.
β¨ NAME β¨
glTexParameterf, glTexParameteri, glTexParameterfv, glTexParameteriv β set texture parameters π
π C SPECIFICATION π
void glTexParameterf( GLenum target,
GLenum pname,
GLfloat param )
void glTexParameteri( GLenum target,
GLenum pname,
GLint param )
π PARAMETERS π
targetβ the target texture, and it must be eitherGL_TEXTURE_1D,GL_TEXTURE_2D, orGL_TEXTURE_3D. she does not do "other", okurrr πpnameβ the symbolic name of a single-valued texture parameter.pnamecan be one of the following:GL_TEXTURE_MIN_FILTER,GL_TEXTURE_MAG_FILTER,GL_TEXTURE_MIN_LOD,GL_TEXTURE_MAX_LOD,GL_TEXTURE_BASE_LEVEL,GL_TEXTURE_MAX_LEVEL,GL_TEXTURE_WRAP_S,GL_TEXTURE_WRAP_T,GL_TEXTURE_WRAP_R, orGL_TEXTURE_PRIORITY.paramβ the value ofpname. that's her. that's the whole thing she brings to the function π
π C SPECIFICATION (vector edition) π
void glTexParameterfv( GLenum target,
GLenum pname,
const GLfloat *params )
void glTexParameteriv( GLenum target,
GLenum pname,
const GLint *params )
π PARAMETERS (vector edition) π
targetβ the target texture, which must be eitherGL_TEXTURE_1D,GL_TEXTURE_2DorGL_TEXTURE_3D.pnameβ the symbolic name of a texture parameter.pnamecan be one of the following:GL_TEXTURE_MIN_FILTER,GL_TEXTURE_MAG_FILTER,GL_TEXTURE_MIN_LOD,GL_TEXTURE_MAX_LOD,GL_TEXTURE_BASE_LEVEL,GL_TEXTURE_MAX_LEVEL,GL_TEXTURE_WRAP_S,GL_TEXTURE_WRAP_T,GL_TEXTURE_WRAP_R,GL_TEXTURE_BORDER_COLOR, orGL_TEXTURE_PRIORITY. (yes bestie, the vector version getsGL_TEXTURE_BORDER_COLORand the single-value one doesn't β iykyk π)paramsβ a pointer to an array where the value or values ofpnameare stored.
π¦ DESCRIPTION π¦
okay so first, the vibe check on texture mapping: it's a technique that applies an image onto an object's surface as if the image were a decal or cellophane shrink-wrap. literally like wrapping your lunch but make it graphics π the image is created in texture space, with an (s, t) coordinate system. a texture is a one- or two-dimensional image and a set of parameters that determine how samples are derived from the image.
glTexParameter assigns the value or values in params to the texture parameter specified as pname. target defines the target texture, either GL_TEXTURE_1D, GL_TEXTURE_2D, or GL_TEXTURE_3D. the following symbols are accepted in pname:
π₯ 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. the other four use mipmaps β¨
a mipmap is an ordered set of arrays representing the same image at progressively lower resolutions. if the texture has dimensions 2nΓ2m, there are max(n,m)+1 mipmaps. the first mipmap is the original texture, with dimensions 2nΓ2m. each subsequent mipmap has dimensions 2kβ1Γ2lβ1, where 2kΓ2l are the dimensions of the previous mipmap, until either k=0 or l=0. at that point, subsequent mipmaps have dimension 1Γ2lβ1 or 2kβ1Γ1 until the final mipmap, which has dimension 1Γ1. to define the mipmaps, call glTexImage1D, glTexImage2D, glTexImage3D, glCopyTexImage1D, or glCopyTexImage2D with the level argument indicating the order of the mipmaps. level 0 is the original texture; level max(n,m) is the final 1Γ1 mipmap π«Ά
params supplies a function for minifying the texture as one of the following:
GL_NEARESTβ returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.GL_LINEARβ returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. these can include border texture elements, depending on the values ofGL_TEXTURE_WRAP_SandGL_TEXTURE_WRAP_T, and on the exact mapping.GL_NEAREST_MIPMAP_NEARESTβ chooses the mipmap that most closely matches the size of the pixel being textured and uses theGL_NEARESTcriterion (the texture element nearest to the center of the pixel) to produce a texture value.GL_LINEAR_MIPMAP_NEARESTβ chooses the mipmap that most closely matches the size of the pixel being textured and uses theGL_LINEARcriterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value.GL_NEAREST_MIPMAP_LINEARβ chooses the two mipmaps that most closely match the size of the pixel being textured and uses theGL_NEARESTcriterion (the texture element nearest to the center of the pixel) to produce a texture value from each mipmap. the final texture value is a weighted average of those two values.GL_LINEAR_MIPMAP_LINEARβ chooses the two mipmaps that most closely match the size of the pixel being textured and uses theGL_LINEARcriterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value from each mipmap. the final texture value is a weighted average of those two values.
as more texture elements are sampled in the minification process, fewer aliasing artifacts will be apparent πΈ while the GL_NEAREST and GL_LINEAR minification functions can be faster than the other four, they sample only one or four texture elements to determine the texture value of the pixel being rendered and can produce moire patterns or ragged transitions. the initial value of GL_TEXTURE_MIN_FILTER is GL_NEAREST_MIPMAP_LINEAR π
π GL_TEXTURE_MAG_FILTER π
the texture magnification function is used when the pixel being textured maps to an area less than or equal to one texture element. it sets the texture magnification function to either GL_NEAREST or GL_LINEAR (see below). GL_NEAREST is generally faster than GL_LINEAR, but it can produce textured images with sharper edges because the transition between texture elements is not as smooth. the initial value of GL_TEXTURE_MAG_FILTER is GL_LINEAR β¨
GL_NEARESTβ returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.GL_LINEARβ returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. these can include border texture elements, depending on the values ofGL_TEXTURE_WRAP_SandGL_TEXTURE_WRAP_T, and on the exact mapping.
π GL_TEXTURE_MIN_LOD π
sets the minimum level-of-detail parameter. this floating-point value limits the selection of highest resolution mipmap (lowest mipmap level). the initial value is -1000.
π GL_TEXTURE_MAX_LOD π
sets the maximum level-of-detail parameter. this floating-point value limits the selection of the lowest resolution mipmap (highest mipmap level). the initial value is 1000.
π§ GL_TEXTURE_BASE_LEVEL π§
specifies the index of the lowest defined mipmap level. this is an integer value. the initial value is 0.
π§ GL_TEXTURE_MAX_LEVEL π§
sets the index of the highest defined mipmap level. this is an integer value. the initial value is 1000.
π GL_TEXTURE_WRAP_S π
sets the wrap parameter for texture coordinate s to either GL_CLAMP, GL_CLAMP_TO_EDGE, or GL_REPEAT. GL_CLAMP causes s coordinates to be clamped to the range [0,1] and is useful for preventing wrapping artifacts when mapping a single image onto an object. GL_CLAMP_TO_EDGE causes s coordinates to be clamped to the range β£__,1β__β¦, where N is the size of the texture in the direction of clamping. GL_REPEAT causes the integer part of the s coordinate to be ignored; the GL 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 π
π GL_TEXTURE_WRAP_T π
sets the wrap parameter for texture coordinate t to either GL_CLAMP, GL_CLAMP_TO_EDGE, or GL_REPEAT. see the discussion under GL_TEXTURE_WRAP_S. initially, GL_TEXTURE_WRAP_T is set to GL_REPEAT.
π GL_TEXTURE_WRAP_R π
sets the wrap parameter for texture coordinate r to either GL_CLAMP, GL_CLAMP_TO_EDGE, or GL_REPEAT. see the discussion under GL_TEXTURE_WRAP_S. initially, GL_TEXTURE_WRAP_R is set to GL_REPEAT.
π¨ GL_TEXTURE_BORDER_COLOR π¨
sets a border color. params contains four values that comprise the RGBA color of the texture border. integer color components are interpreted linearly such that the most positive integer maps to 1.0, and the most negative integer maps to -1.0. the values are clamped to the range [0,1] when they are specified. initially, the border color is (0, 0, 0, 0) π
π GL_TEXTURE_PRIORITY π
specifies the texture residence priority of the currently bound texture. permissible values are in the range [0, 1]. see glPrioritizeTextures and glBindTexture for more information π«Ά
okay that's the parameter tea so far β there's more coming in the next part, so don't go anywhere bestie π
π NOTES π
Okay so first lil availability check, bestie: GL_TEXTURE_3D, GL_TEXTURE_MIN_LOD, GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL are only available if the GL version is 1.2 or greater. That's the vibe check for those five, periodt.
Now picture this mipmap situation, because it's giving chaos potential π. Suppose a program has enabled texturing (by calling glEnable with argument GL_TEXTURE_1D, GL_TEXTURE_2D, or GL_TEXTURE_3D) and has set GL_TEXTURE_MIN_FILTER to one of the functions that requires a mipmap. Then if either:
- the dimensions of the texture images currently defined (with previous calls to
glTexImage1D,glTexImage2D,glTexImage3D,glCopyTexImage1D, orglCopyTexImage2D) do not follow the proper sequence for mipmaps (described above), - or there are fewer texture images defined than are needed,
- or the set of texture images have differing numbers of texture components,
then it is as if texture mapping were disabled. Like, the whole thing just acts off. No cap. π
Linear filtering accesses the four nearest texture elements only in 2D textures. In 1D textures, linear filtering accesses the two nearest texture elements. Cute and specific, we love that for us β¨.
When the GL_ARB_multitexture extension is supported, glTexParameter specifies the texture parameters for the active texture unit, specified by calling glActiveTextureARB. That's the active-unit tea β.
π¨ ERRORS π¨
These are the "bestie, something went wrong" moments:
GL_INVALID_ENUMgets generated iftargetorpnameis not one of the accepted defined values. πGL_INVALID_ENUMgets generated ifparamsshould have a defined constant value (based on the value ofpname) and does not. Ma'am, pick a valid constant please π .GL_INVALID_OPERATIONgets generated ifglTexParameteris executed between the execution ofglBeginand the corresponding execution ofglEnd. So not in the middle of that, okay? π
π ASSOCIATED GETS π
The little functions that peek back at you:
glGetTexParameterglGetTexLevelParameter
π SEE ALSO π
Go give these besties a read when you need the full lore:
glActiveTextureARB(3G)glBindTexture(3G)glCopyPixels(3G)glCopyTexImage1D(3G)glCopyTexImage2D(3G)glCopyTexSubImage1D(3G)glCopyTexSubImage2D(3G)glCopyTexSubImage3D(3G)glDrawPixels(3G)glPixelStore(3G)glPixelTransfer(3G)glPrioritizeTextures(3G)glTexEnv(3G)glTexGen(3G)glTexImage1D(3G)glTexImage2D(3G)glTexImage3D(3G)glTexSubImage1D(3G)glTexSubImage2D(3G)glTexSubImage3D(3G)
That's the page, babe π«Ά β the footer has the source/version and date receipts, so peep down there for the official stamp, mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms