GLCONVOLUTIONPARAMETER(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’– GLCONVOLUTIONPARAMETER πŸ’– (3G, bestie, the OpenGL manual)

Okay so real talk: glConvolutionParameterf, glConvolutionParameteri, glConvolutionParameterfv, and glConvolutionParameteriv all do the same one (1) job, which is setting convolution parameters. Four functions, one destiny. It's giving "we made four of them so you don't have to cast anything". Slay. ✨


✨ C SPECIFICATION ✨

void glConvolutionParameterf( GLenum target,
                              GLenum pname,
                              GLfloat params )
void glConvolutionParameteri( GLenum target,
                              GLenum pname,
                              GLint params )

πŸŽ€ PARAMETERS πŸŽ€

  • target β€” which convolution thingy we're poking. Gotta be one of GL_CONVOLUTION_1D, GL_CONVOLUTION_2D, or GL_SEPARABLE_2D. No substitutes, no vibes-based guessing. πŸ’…
  • pname β€” the parameter you're setting. For these two float/int girlies it must be GL_CONVOLUTION_BORDER_MODE. That's the whole list, that's the tea. πŸ“
  • params β€” the actual value. Must be one of GL_REDUCE, GL_CONSTANT_BORDER, GL_REPLICATE_BORDER. Pick one, don't be chaotic. πŸ¦‹

✨ C SPECIFICATION ✨ (the pointer era)

void glConvolutionParameterfv( GLenum target,
                               GLenum pname,
                               const GLfloat *params )
void glConvolutionParameteriv( GLenum target,
                               GLenum pname,
                               const GLint *params )

πŸŽ€ PARAMETERS πŸŽ€

  • target β€” same deal as before, the convolution thingy getting affected. Must be one of GL_CONVOLUTION_1D, GL_CONVOLUTION_2D, or GL_SEPARABLE_2D. πŸ‘‘
  • pname β€” now you've got options, main character. Must be one of GL_CONVOLUTION_BORDER_MODE, GL_CONVOLUTION_BORDER_COLOR, GL_CONVOLUTION_FILTER_SCALE, or GL_CONVOLUTION_FILTER_BIAS. Four choices, four moods. πŸ’œ
  • params β€” the value, and what it needs to be depends entirely on pname, so pay attention bestie. If pname is GL_CONVOLUTION_BORDER_MODE, then params must be one of GL_REDUCE, GL_CONSTANT_BORDER, or GL_REPLICATE_BORDER. Otherwise, it must be a vector of four values (for red, green, blue, and alpha, respectively) to be used for scaling (when pname is GL_CONVOLUTION_FILTER_SCALE), or biasing (when pname is GL_CONVOLUTION_FILTER_BIAS) a convolution filter kernel or setting the constant border color (when pname is `GL_CONVOLUTION_BORDER_COLOR.
ngl that last sentence ends with an unclosed paren and I am not fixing it, that's how it's written, we respect the source material here. 😭

πŸ’« DESCRIPTION πŸ’«

glConvolutionParameter sets the value of a convolution parameter. That's it, that's the function, no plot twist. 🌸

target picks which convolution filter is catching these hands: GL_CONVOLUTION_1D, GL_CONVOLUTION_2D, or GL_SEPARABLE_2D for the 1D, 2D, or separable 2D filter respectively. Lowkey straightforward. ✨

pname picks which parameter is getting changed. GL_CONVOLUTION_FILTER_SCALE and GL_CONVOLUTION_FILTER_BIAS affect the definition of the convolution filter kernel β€” go read glConvolutionFilter1D, glConvolutionFilter2D, and glSeparableFilter2D for the details, I'm not retyping all that. In these cases, params is an array of four values to be applied to red, green, blue, and alpha values, respectively. The initial value for GL_CONVOLUTION_FILTER_SCALE is (1, 1, 1, 1), and the initial value for GL_CONVOLUTION_FILTER_BIAS is (0, 0, 0, 0). Cute defaults, no notes. πŸŽ€

A pname value of GL_CONVOLUTION_BORDER_MODE controls the convolution border mode. The accepted modes are, and I need you to focus for this part:

  • GL_REDUCE β€” the image resulting from convolution is smaller than the source image. If the filter width is Wf and height is Hf, and the source image width is Ws and height is Hs, then the convolved image width will be Wsβˆ’Wf+1 and height will be Hsβˆ’Hf+1. (If this reduction would generate an image with zero or negative width and/or height, the output is simply null, with no error generated.) The coordinates of the image resulting from convolution are zero through Wsβˆ’Wf in width and zero through Hsβˆ’Hf in height.
  • GL_CONSTANT_BORDER β€” the image resulting from convolution is the same size as the source image, and processed as if the source image were surrounded by pixels with their color specified by the GL_CONVOLUTION_BORDER_COLOR. Fancy border, immaculate vibes. 🌈
  • GL_REPLICATE_BORDER β€” the image resulting from convolution is the same size as the source image, and processed as if the outermost pixel on the border of the source image were replicated. It said "copy paste" and meant it. πŸ¦‹

πŸ“ NOTES πŸ“

glConvolutionParameter is present only if GL_ARB_imaging is returned when glGetString is called with an argument of GL_EXTENSIONS. So like… check first, bestie. Don't just assume it's there. πŸ™ˆ

In cases where errors can result from the specification of invalid image dimensions, it is the dimensions after convolution that are tested, not the dimensions of the source image. For example, glTexImage1D requires power-of-two image size. When GL_REDUCE border mode is in effect, the source image must be larger than the final power-of-two size by one less than the size of the 1D filter kernel. Math is math, I don't make the rules. πŸ’€


🚨 ERRORS 🚨

  • GL_INVALID_ENUM is generated if target is not one of the allowable values. Rude of you, honestly. 😀
  • GL_INVALID_ENUM is generated if pname is not one of the allowable values.
  • GL_INVALID_ENUM is generated if pname is GL_CONVOLUTION_BORDER_MODE and params is not one of GL_REDUCE, GL_CONSTANT_BORDER, or GL_REPLICATE_BORDER.
  • GL_INVALID_OPERATION is generated if glConvolutionParameter is executed between the execution of glBegin and the corresponding execution of glEnd. Do not do that. It's illegal, it's messy, it's not the moment. πŸ’…

πŸ” ASSOCIATED GETS πŸ”

  • glGetConvolutionParameter

🫢 SEE ALSO 🫢

  • glConvolutionFilter1D(3G)
  • glConvolutionFilter2D(3G)
  • glSeparableFilter2D(3G)
  • glGetConvolutionParameter(3G)

And that's the whole page, bestie β€” this was the GLCONVOLUTIONPARAMETER(3G) entry from the OpenGL 3G manual set. Go forth, set your convolution parameters responsibly, and remember: the parens stay unbalanced because that's canon. βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from