mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +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
|
@ -199,7 +199,10 @@ extern "C" {
|
||||||
#define GL_NEAREST 0x2600
|
#define GL_NEAREST 0x2600
|
||||||
#define GL_LINEAR 0x2601
|
#define GL_LINEAR 0x2601
|
||||||
#define GL_NEAREST_MIPMAP_LINEAR 0x2602
|
#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
|
// OpenGL State & GLGet
|
||||||
#define GL_MODELVIEW_MATRIX 0x0BA6
|
#define GL_MODELVIEW_MATRIX 0x0BA6
|
||||||
|
|
|
@ -16,6 +16,11 @@ static constexpr float wrap_repeat(float value)
|
||||||
return value - floorf(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
|
FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
||||||
{
|
{
|
||||||
// FIXME: Calculate the correct mipmap level here, need to receive uv derivatives for that
|
// 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);
|
x = wrap_repeat(x);
|
||||||
break;
|
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:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +52,13 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const
|
||||||
y = wrap_repeat(y);
|
y = wrap_repeat(y);
|
||||||
break;
|
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:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue