74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
|
|
#include "fixtures/OpenGLTestFixture.h"
|
||
|
|
#include "XCEngine/RHI/OpenGL/OpenGLTexture.h"
|
||
|
|
|
||
|
|
using namespace XCEngine::RHI;
|
||
|
|
|
||
|
|
TEST_F(OpenGLTestFixture, Texture_Initialize_2DTexture) {
|
||
|
|
OpenGLTexture texture;
|
||
|
|
|
||
|
|
bool result = texture.Initialize2D(64, 64, 4, nullptr, false);
|
||
|
|
|
||
|
|
ASSERT_TRUE(result);
|
||
|
|
EXPECT_NE(texture.GetID(), 0u);
|
||
|
|
EXPECT_EQ(texture.GetWidth(), 64);
|
||
|
|
EXPECT_EQ(texture.GetHeight(), 64);
|
||
|
|
EXPECT_EQ(texture.GetType(), OpenGLTextureType::Texture2D);
|
||
|
|
|
||
|
|
texture.Shutdown();
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST_F(OpenGLTestFixture, Texture_Initialize_CubeMap) {
|
||
|
|
OpenGLTexture texture;
|
||
|
|
|
||
|
|
bool result = texture.InitializeCubeMap(64, 1, OpenGLFormat::RGBA8, nullptr);
|
||
|
|
|
||
|
|
ASSERT_TRUE(result);
|
||
|
|
EXPECT_NE(texture.GetID(), 0u);
|
||
|
|
EXPECT_EQ(texture.GetWidth(), 64);
|
||
|
|
EXPECT_EQ(texture.GetHeight(), 64);
|
||
|
|
EXPECT_EQ(texture.GetType(), OpenGLTextureType::TextureCube);
|
||
|
|
|
||
|
|
texture.Shutdown();
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST_F(OpenGLTestFixture, Texture_Bind_Unbind) {
|
||
|
|
OpenGLTexture texture;
|
||
|
|
texture.Initialize2D(64, 64, 4, nullptr, false);
|
||
|
|
|
||
|
|
texture.Bind(0);
|
||
|
|
GLint boundTexture = 0;
|
||
|
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture);
|
||
|
|
EXPECT_EQ(boundTexture, static_cast<GLint>(texture.GetID()));
|
||
|
|
|
||
|
|
texture.Unbind();
|
||
|
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture);
|
||
|
|
EXPECT_EQ(boundTexture, 0);
|
||
|
|
|
||
|
|
texture.Shutdown();
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST_F(OpenGLTestFixture, Texture_GenerateMipmap) {
|
||
|
|
OpenGLTexture texture;
|
||
|
|
texture.Initialize2D(64, 64, 4, nullptr, false);
|
||
|
|
|
||
|
|
texture.GenerateMipmap();
|
||
|
|
|
||
|
|
GLenum error = glGetError();
|
||
|
|
EXPECT_EQ(error, GL_NO_ERROR);
|
||
|
|
|
||
|
|
texture.Shutdown();
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST_F(OpenGLTestFixture, Texture_SetFiltering_SetWrapping) {
|
||
|
|
OpenGLTexture texture;
|
||
|
|
texture.Initialize2D(64, 64, 4, nullptr, false);
|
||
|
|
|
||
|
|
texture.SetFiltering(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||
|
|
texture.SetWrapping(GL_REPEAT, GL_REPEAT, GL_REPEAT);
|
||
|
|
|
||
|
|
GLenum error = glGetError();
|
||
|
|
EXPECT_EQ(error, GL_NO_ERROR);
|
||
|
|
|
||
|
|
texture.Shutdown();
|
||
|
|
}
|