Fix texture loading

- Fix corrupted texture by reverse y-axis
This commit is contained in:
Linloir 2022-12-13 21:10:38 +08:00
parent 2511dedf8c
commit 7f46566c64
No known key found for this signature in database
GPG Key ID: 58EEB209A0F2C366

View File

@ -25,6 +25,9 @@ Texture::Texture(TextureType type, std::string path) {
OPENGL_FUNCTIONS->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
OPENGL_FUNCTIONS->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Set stbi to reverse the y-axis
stbi_set_flip_vertically_on_load(true);
// Load image, create texture and generate mipmaps
int width, height, nrChannels;
unsigned char* data = stbi_load(path.c_str(), &width, &height, &nrChannels, 0);