From 7f46566c6408b221432735bf1cae136591970ffe Mon Sep 17 00:00:00 2001 From: Linloir <3145078758@qq.com> Date: Tue, 13 Dec 2022 21:10:38 +0800 Subject: [PATCH] Fix texture loading - Fix corrupted texture by reverse y-axis --- FinalProject/texture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FinalProject/texture.cpp b/FinalProject/texture.cpp index 8bb6fc6..7fbc98e 100644 --- a/FinalProject/texture.cpp +++ b/FinalProject/texture.cpp @@ -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);