2026-03-17 12:27:47 +08:00
|
|
|
#include "fixtures/OpenGLTestFixture.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLSampler.h"
|
|
|
|
|
|
|
|
|
|
using namespace XCEngine::RHI;
|
|
|
|
|
|
|
|
|
|
TEST_F(OpenGLTestFixture, Sampler_Initialize_Default) {
|
|
|
|
|
OpenGLSampler sampler;
|
2026-03-17 19:43:20 +08:00
|
|
|
OpenGLSamplerDesc desc;
|
2026-03-17 12:27:47 +08:00
|
|
|
|
|
|
|
|
bool result = sampler.Initialize(desc);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(result);
|
|
|
|
|
EXPECT_NE(sampler.GetID(), 0u);
|
|
|
|
|
|
|
|
|
|
sampler.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(OpenGLTestFixture, Sampler_Initialize_Custom) {
|
|
|
|
|
OpenGLSampler sampler;
|
2026-03-17 19:43:20 +08:00
|
|
|
OpenGLSamplerDesc desc;
|
2026-03-17 12:27:47 +08:00
|
|
|
desc.minFilter = SamplerFilter::LinearMipmapLinear;
|
|
|
|
|
desc.magFilter = SamplerFilter::Linear;
|
|
|
|
|
desc.wrapS = SamplerWrapMode::Repeat;
|
|
|
|
|
desc.wrapT = SamplerWrapMode::Repeat;
|
|
|
|
|
desc.wrapR = SamplerWrapMode::ClampToEdge;
|
|
|
|
|
|
|
|
|
|
bool result = sampler.Initialize(desc);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(result);
|
|
|
|
|
EXPECT_NE(sampler.GetID(), 0u);
|
|
|
|
|
|
|
|
|
|
sampler.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(OpenGLTestFixture, Sampler_Bind_Unbind) {
|
|
|
|
|
OpenGLSampler sampler;
|
2026-03-17 19:43:20 +08:00
|
|
|
OpenGLSamplerDesc desc;
|
2026-03-17 12:27:47 +08:00
|
|
|
sampler.Initialize(desc);
|
|
|
|
|
|
|
|
|
|
sampler.Bind(0);
|
|
|
|
|
GLint boundSampler = 0;
|
|
|
|
|
glGetIntegerv(GL_SAMPLER_BINDING, &boundSampler);
|
|
|
|
|
EXPECT_EQ(boundSampler, static_cast<GLint>(sampler.GetID()));
|
|
|
|
|
|
|
|
|
|
sampler.Unbind(0);
|
|
|
|
|
glGetIntegerv(GL_SAMPLER_BINDING, &boundSampler);
|
|
|
|
|
EXPECT_EQ(boundSampler, 0);
|
|
|
|
|
|
|
|
|
|
sampler.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(OpenGLTestFixture, Sampler_GetID_ReturnsValid) {
|
|
|
|
|
OpenGLSampler sampler;
|
2026-03-17 19:43:20 +08:00
|
|
|
OpenGLSamplerDesc desc;
|
2026-03-17 12:27:47 +08:00
|
|
|
sampler.Initialize(desc);
|
|
|
|
|
|
|
|
|
|
EXPECT_NE(sampler.GetID(), 0u);
|
|
|
|
|
|
|
|
|
|
sampler.Shutdown();
|
|
|
|
|
}
|