mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibGL: Implement "clamp" wrap mode
This commit is contained in:
parent
12785849aa
commit
8902efa52d
2 changed files with 23 additions and 1 deletions
|
@ -16,6 +16,11 @@ static constexpr float wrap_repeat(float value)
|
|||
return value - floorf(value);
|
||||
}
|
||||
|
||||
static constexpr float wrap_clamp(float value)
|
||||
{
|
||||
return clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
||||
{
|
||||
// FIXME: Calculate the correct mipmap level here, need to receive uv derivatives for that
|
||||
|
@ -31,6 +36,13 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
|||
x = wrap_repeat(x);
|
||||
break;
|
||||
|
||||
// FIXME: These clamp modes actually have slightly different behaviour
|
||||
case GL_CLAMP:
|
||||
case GL_CLAMP_TO_BORDER:
|
||||
case GL_CLAMP_TO_EDGE:
|
||||
x = wrap_clamp(x);
|
||||
break;
|
||||
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -40,6 +52,13 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
|||
y = wrap_repeat(y);
|
||||
break;
|
||||
|
||||
// FIXME: These clamp modes actually have slightly different behaviour
|
||||
case GL_CLAMP:
|
||||
case GL_CLAMP_TO_BORDER:
|
||||
case GL_CLAMP_TO_EDGE:
|
||||
y = wrap_clamp(y);
|
||||
break;
|
||||
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue