mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGL: Implement "clamp" wrap mode
This commit is contained in:
parent
12785849aa
commit
8902efa52d
Notes:
sideshowbarker
2024-07-18 07:05:02 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/8902efa52d8 Pull-request: https://github.com/SerenityOS/serenity/pull/9350
2 changed files with 23 additions and 1 deletions
|
@ -199,7 +199,10 @@ extern "C" {
|
|||
#define GL_NEAREST 0x2600
|
||||
#define GL_LINEAR 0x2601
|
||||
#define GL_NEAREST_MIPMAP_LINEAR 0x2602
|
||||
#define GL_REPEAT 0x2603
|
||||
#define GL_CLAMP 0x2900
|
||||
#define GL_REPEAT 0x2901
|
||||
#define GL_CLAMP_TO_BORDER 0x812D
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
|
||||
// OpenGL State & GLGet
|
||||
#define GL_MODELVIEW_MATRIX 0x0BA6
|
||||
|
|
|
@ -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…
Reference in a new issue