diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index 5b63250616..93609a8b27 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -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 diff --git a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp index e88babfae6..f2d1aeeb1f 100644 --- a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp +++ b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp @@ -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(); }