GLSAMPLERPARAMETER(3G)
πΈ NAME πΈ
glSamplerParameter β set sampler parameters. This is the glSamplerParameter(3G) manual page, and yes the original header literally has [FIXME: manual] in it, so weβre respectfully keeping that chaotic energy πβ¨
π C SPECIFICATION π
okay bestie, here are the actual C signatures, untouched and iconic:
void glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
void glSamplerParameteri(GLuint sampler, GLenum pname, GLint param);
void glSamplerParameterfv(GLuint sampler, GLenum pname,
const GLfloat * params);
void glSamplerParameteriv(GLuint sampler, GLenum pname,
const GLint * params);
void glSamplerParameterIiv(GLuint sampler, GLenum pname,
const GLint *params);
void glSamplerParameterIuiv(GLuint sampler, GLenum pname,
const GLuint *params);
π«Ά PARAMETERS π«Ά
samplerβ specifies the sampler object whose parameter to modify.pnameβ specifies the symbolic name of a sampler parameter.pnamecan be one of the following:GL_TEXTURE_WRAP_S,GL_TEXTURE_WRAP_T,GL_TEXTURE_WRAP_R,GL_TEXTURE_MIN_FILTER,GL_TEXTURE_MAG_FILTER,GL_TEXTURE_BORDER_COLOR,GL_TEXTURE_MIN_LOD,GL_TEXTURE_MAX_LOD,GL_TEXTURE_LOD_BIAS,GL_TEXTURE_COMPARE_MODE, orGL_TEXTURE_COMPARE_FUNC.paramβ for the scalar commands, specifies the value ofpname.paramsβ for the vector commands (glSamplerParameter*v), specifies a pointer to an array where the value or values ofpnameare stored.
β¨ DESCRIPTION β¨
okay so glSamplerParameter assigns the value or values in params to the sampler parameter specified as pname. The sampler argument specifies the sampler object to be modified, and it must be the name of a sampler object previously returned from a call to glGenSamplers().
bestie, this is not a βpick any random numberβ situation β that sampler name has to come from glGenSamplers() first π
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, no cap. 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 2 n Γ 2 m, there are max β‘ n m + 1 mipmaps. The first mipmap is the original texture, with dimensions 2 n Γ 2 m. Each subsequent mipmap has dimensions 2 k - 1 Γ 2 l - 1, where 2 k Γ 2 l are the dimensions of the previous mipmap, until either k = 0 or l = 0. At that point, subsequent mipmaps have dimension 1 Γ 2 l - 1 or 2 k - 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 lowest resolution mipmap (highest mipmap level). The initial value is 1000.
π GL_TEXTURE_WRAP_S
Sets the wrap parameter for texture coordinate s to either GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, GL_REPEAT, or GL_MIRROR_CLAMP_TO_EDGE. GL_CLAMP_TO_BORDER causes the s coordinate to be clamped to the range -1 2N 1 + 1 2N, where N is the size of the texture in the direction of clamping. GL_CLAMP_TO_EDGE causes s coordinates to be clamped to the range 1 2N 1 - 1 2N, 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. GL_MIRRORED_REPEAT causes the s coordinate to be set to the fractional part of the texture coordinate if the integer part of s is even; if the integer part of s is odd, then the s texture coordinate is set to 1 - frac β‘ s, where frac β‘ s represents the fractional part of s. GL_MIRROR_CLAMP_TO_EDGE causes the s coordinate to be repeated as for GL_MIRRORED_REPEAT for one repetition of the texture, at which point the coordinate to be clamped as in GL_CLAMP_TO_EDGE. 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_TO_EDGE, GL_MIRRORED_REPEAT, GL_REPEAT, or GL_MIRROR_CLAMP_TO_EDGE. 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_TO_EDGE, GL_MIRRORED_REPEAT, GL_REPEAT, or GL_MIRROR_CLAMP_TO_EDGE. See the discussion under GL_TEXTURE_WRAP_S. Initially, GL_TEXTURE_WRAP_R is set to GL_REPEAT.
π GL_TEXTURE_BORDER_COLOR
The data in params specifies four values that define the border values that should be used for border texels. If a texel is sampled from the border of the texture, the values of GL_TEXTURE_BORDER_COLOR are interpreted as an RGBA color to match the textureβs internal format and substituted for the non-existent texel data. If the texture contains depth components, the first component of GL_TEXTURE_BORDER_COLOR is interpreted as a depth value. The initial value is 0.0 , 0.0 , 0.0 , 0.0.
π₯ GL_TEXTURE_COMPARE_MODE
Specifies the texture comparison mode for currently bound textures. That is, a texture whose internal format is GL_DEPTH_COMPONENT_*; see glTexImage2D()) Permissible values are:
GL_COMPARE_REF_TO_TEXTUREβ specifies that the interpolated and clampedrtexture coordinate should be compared to the value in the currently bound texture. See the discussion ofGL_TEXTURE_COMPARE_FUNCfor details of how the comparison is evaluated. The result of the comparison is assigned to the red channel.GL_NONEβ specifies that the red channel should be assigned the appropriate value from the currently bound texture.
π
GL_TEXTURE_COMPARE_FUNC
okay so this one specifies the comparison operator that gets used when GL_TEXTURE_COMPARE_MODE is set to GL_COMPARE_REF_TO_TEXTURE. That's the whole vibe β you're telling it how to compare. π
The permissible values are, and yes, each one comes with its own "Computed result" situation:
GL_LEQUALβ computed result is1.0wherer <= D_t, and0.0wherer > D_t. Iconic little hard flip at the line β¨
result
1.0 |βΎβΎβΎβΎβΎβΎβΎ
|
0.0 |_______
r<=D_t r>D_t
GL_GEQUALβ same energy, flipped: computed result is1.0wherer >= D_t, and0.0wherer < D_t. it's giving mirror image π
result
1.0 | βΎβΎβΎβΎβΎβΎβΎ
|
0.0 |βΎβΎβΎβΎβΎβΎβΎ
r<D_t r>=D_t
GL_LESSβ computed result is1.0on the side wherer < D_t, and0.0on the other side of the line (ngl the table graphic in this rendering gets cut off right there π but the1.0/0.0pair is on the same axes, with the boundary drawn atD_t)
result
1.0 | βΎβΎβΎβΎβΎβΎβΎ
|
0.0 |βΎβΎβΎβΎβΎβΎβΎ
r<D_t β¦
also bestie, quick vibe check on the axes: the horizontal axis is labeled r, and the marker on it is the one referenced in the comparison (D_t), with the < / <= / >= sitting right at that point. The vertical axis tops out at 1.0 and bottoms out at 0.0 β that's it, that's the whole graph. πΈ
okay bestie, we're still in the glow-up chart of comparison functions π
and here's where it gets good β each row is a function, and next to it there's a lil' plot π where the y-axis is result (chillin' between 0.0 and 1.0, no other values, that's it, that's the whole range) and the x-axis is r/Dt β yup, literally the label on the axis is r, then the comparison operator, then Dt. So the graph is telling you the comparison it's doing. Iconic behaviour honestly π
π¦ the rows, one by one
GL_GREATERβ the row plotsresultagainstr/Dt, and the comparison written on the axis isr>Dt. The plot marks1.0and0.0on the result side so you can see the two possible outcomes. That's the whole vibe: doesrbeatDt? π
result
1.0 β€ ββββββββββ
β ββββββββββ
0.0 β€ ββββββββββββββββββββ
βββββββββββββββββββββββ¬ββββββββββ
r > Dt
(yes the actual book draws it out too, we're just keeping it cute β¨)
GL_EQUALβ same setup, same axes, same1.0/0.0result band, except the comparison on the axis isr=Dt. So this one's the "are they literally the same" check, and the graph shows result sitting at1.0right where that's true and0.0everywhere else π«Ά
result
1.0 β€ ββ
β ββ
0.0 β€ ββββββββββββββββββββββββ
βββββββββββββ¬ββββββββββββββ
r = Dt
GL_NOTEQUALβ the "not like the others" main character π same graph skeleton,resulton the y-axis between0.0and1.0,r/Dton the x-axis, and the operator printed on the axis isrβDt. So1.0is the "nope, different" answer and0.0is the "same" answer. Flipped energy. Obsessed πΈ
result
1.0 β€ ββββββββββ ββββββββββ
β ββββββββββ ββββββββββ
0.0 β€ ββββββββββ
βββββββββββββ¬ββββββββββββββββββββ
r β Dt
ngl bestie, the little operator betweenrandDtis the entire content of these graphs β the shape of the curve just shows you whereresultlands at1.0versus0.0for that comparison. Read the operator, that's the β¨teaβ¨
and yeah β the table keeps scrolling, there's more rows below this, so don't close the tab yet π§
β¦and here's where we pick up that comparison table β the tail end of it, bestie, the last two rows:
GL_ALWAYSβresult=1.0GL_NEVERβresult=0.0
where r is the current interpolated texture coordinate, and D t is the texture value sampled from the currently bound texture. result is assigned to R t. π
β¨ NOTES β¨
glSamplerParameteris available only if the GL version is 3.3 or higher. Like, don't come for her if you're on 3.2, she literally isn't there yet. π«Ά- Okay so this part is kind of a big deal: if a sampler object is bound to a texture unit and that unit is used to sample from a texture, the parameters in the sampler are used to sample from the texture, rather than the equivalent parameters in the texture object bound to that unit. The sampler ate, no cap. π
This introduces the possibility of sampling from the same texture object with different sets of sampler state β which may lead to a condition where a texture is incomplete with respect to one sampler object and not with respect to another. π So, like, completeness can be considered a function of a sampler object and a texture object bound to a single texture unit, rather than a property of the texture object itself. She's a shared experience, she's not defined by one unit. periodt.
GL_MIRROR_CLAMP_TO_EDGEis available only if the GL version is 4.4 or greater. newer-girl privilege fr fr π
π ERRORS π
GL_INVALID_VALUEis generated ifsampleris not the name of a sampler object previously returned from a call toglGenSamplers(). bestie, you can't just make up a name and expect her to answer. πGL_INVALID_ENUMis generated ifparamsshould have a defined constant value (based on the value ofpname) and does not. wrong enum, wrong vibe, blocked. π
π ASSOCIATED GETS π
glGetSamplerParameter()
π VERSION SUPPORT π
So here's the whole mood board of which function slays in which OpenGL version. In every single row: 2.0, 2.1, 3.0 and 3.1 get a big fat - (she was not invited), and then 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4 and 4.5 all get the β glow-up. β¨
glSamplerParameterIivβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5glSamplerParameterIuivβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5glSamplerParameterfβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5glSamplerParameterfvβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5glSamplerParameteriβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5glSamplerParameterivβ-in 2.0, 2.1, 3.0, 3.1;βin 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5
(the column header for all of that is, obviously, OpenGL Version β and the row header is Function / Feature Name, because she contains multitudes π¦)
π SEE ALSO π
Go give these icons a read, they're all in the same group chat:
glGenSamplers()glBindSampler()glDeleteSamplers()glIsSampler()glBindTexture()glTexParameter()
π COPYRIGHT π
Copyright Β© 2010-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2010-2014 KhronosGroup
okay that's the whole page, you made it, I'm so proud of you π«Άπ The source line up top is literally just [FIXME: source] (yes, the manpage authors left us on read π) and it's dated 08/09/2021, and it's GLSAMPLERPARAMETER(3G) in case you forgot where you were. go bind some samplers bestie, you've got this π
β¨πΈ
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms