mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
LibGL: Implement "mirrored repeat" wrap mode
This commit is contained in:
parent
8902efa52d
commit
e0fef60241
Notes:
sideshowbarker
2024-07-18 07:04:59 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/e0fef602413 Pull-request: https://github.com/SerenityOS/serenity/pull/9350
@ -201,6 +201,7 @@ extern "C" {
|
||||
#define GL_NEAREST_MIPMAP_LINEAR 0x2602
|
||||
#define GL_CLAMP 0x2900
|
||||
#define GL_REPEAT 0x2901
|
||||
#define GL_MIRRORED_REPEAT 0x8370
|
||||
#define GL_CLAMP_TO_BORDER 0x812D
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
|
||||
|
@ -16,6 +16,14 @@ static constexpr float wrap_repeat(float value)
|
||||
return value - floorf(value);
|
||||
}
|
||||
|
||||
static constexpr float wrap_mirrored_repeat(float value)
|
||||
{
|
||||
float integer = floorf(value);
|
||||
float frac = value - integer;
|
||||
bool iseven = fmodf(integer, 2.0f) == 0.0f;
|
||||
return iseven ? frac : 1 - frac;
|
||||
}
|
||||
|
||||
static constexpr float wrap_clamp(float value)
|
||||
{
|
||||
return clamp(value, 0.0f, 1.0f);
|
||||
@ -43,6 +51,10 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
||||
x = wrap_clamp(x);
|
||||
break;
|
||||
|
||||
case GL_MIRRORED_REPEAT:
|
||||
x = wrap_mirrored_repeat(x);
|
||||
break;
|
||||
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
@ -59,6 +71,10 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
||||
y = wrap_clamp(y);
|
||||
break;
|
||||
|
||||
case GL_MIRRORED_REPEAT:
|
||||
y = wrap_mirrored_repeat(y);
|
||||
break;
|
||||
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user