Light | Dark

clamp

Name

clamp — constrain a value to lie between two further values

Declaration

genType clamp( genType x,
genType minVal,
genType maxVal);
genType clamp( genType x,
float minVal,
float maxVal);
genIType clamp( genIType x,
genIType minVal,
genIType maxVal);
genIType clamp( genIType x,
int minVal,
int maxVal);
genUType clamp( genUType x,
genUType minVal,
genUType maxVal);
genUType clamp( genUType x,
uint minVal,
uint maxVal);

Parameters

x

Specify the value to constrain.

minVal

Specify the lower end of the range into which to constrain x.

maxVal

Specify the upper end of the range into which to constrain x.

Description

clamp returns the value of x constrained to the range minVal to maxVal. The returned value is computed as min(max(x, minVal), maxVal). The result is undefined if minValmaxVal.

Version Support

OpenGL ES Shading Language Version
Function Name 1.00 3.00 3.10
clamp (genType)
clamp (genIType) -
clamp (genUType) -

See Also

min, max

Think you can improve this page? Edit this page on GitHub.