diff --git a/CMakeLists.txt b/CMakeLists.txt index a4ac02c..abe7436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,13 +65,15 @@ include_directories( ${CMAKE_SOURCE_DIR}/imgui/backends ) +target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp) + # Link libraries using vcpkg # Link the FreeImage library explicitly -if (WIN32) - target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-windows/lib/FreeImage.lib") -else() - target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-linux/lib/libFreeImage.a") -endif() +#if (WIN32) +# target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-windows/lib/FreeImage.lib") +#else() +# target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-linux/lib/libFreeImage.a") +#endif() # Custom target for shaders add_custom_target(copy_shaders ALL diff --git a/include/load_texture.h b/include/load_texture.h deleted file mode 100644 index 34da45a..0000000 --- a/include/load_texture.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __LOADTEXTURE_H__ -#define __LOADTEXTURE_H__ - -#include "platform_utils.h" - -#include -#include -#include "GL/glew.h" -#include "GL/gl.h" - -GLuint LoadTexture(const std::string& fname); -GLuint LoadSkybox(const std::vector& faces); - -#endif \ No newline at end of file diff --git a/source/load_texture.cpp b/source/load_texture.cpp deleted file mode 100644 index 7acc586..0000000 --- a/source/load_texture.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "load_texture.h" -#include - - -GLuint LoadTexture(const std::string& fname) -{ - GLuint tex_id; - - FREE_IMAGE_FORMAT format = FreeImage_GetFileType(fname.c_str(), 0); - FIBITMAP* tempImg = FreeImage_Load(format, fname.c_str()); - FIBITMAP* img; - - if(format == FIF_EXR) - img = FreeImage_ConvertToRGBF(tempImg); - else - img = FreeImage_ConvertTo32Bits(tempImg); - - FreeImage_Unload(tempImg); - - GLuint w = FreeImage_GetWidth(img); - GLuint h = FreeImage_GetHeight(img); - GLuint scanW = FreeImage_GetPitch(img); - - GLubyte* byteImg = new GLubyte[h * scanW];; - GLfloat* floatImg = new GLfloat[h * scanW];; - if (format == FIF_EXR) - FreeImage_ConvertToRawBits((BYTE*)floatImg, img, scanW, 96, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, TRUE); - else - FreeImage_ConvertToRawBits(byteImg, img, scanW, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, FALSE); - - FreeImage_Unload(img); - - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_2D, tex_id); - if (format == FIF_EXR) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, w, h, 0, GL_RGB, GL_FLOAT, floatImg); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, byteImg); - glGenerateMipmap(GL_TEXTURE_2D); - if (format == FIF_EXR) - { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - else - { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - delete[] byteImg; - delete[] floatImg; - - return tex_id; -} - -GLuint LoadSkybox(const std::vector& faces) -{ - GLuint tex_id; - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_CUBE_MAP, tex_id); - - for (GLuint i = 0; i < faces.size(); i++) - { - FREE_IMAGE_FORMAT format = FreeImage_GetFileType(faces[i].c_str(), 0); - FIBITMAP* tempImg = FreeImage_Load(format, faces[i].c_str()); - FIBITMAP* img = (format == FIF_EXR) ? FreeImage_ConvertToRGBF(tempImg) : FreeImage_ConvertTo32Bits(tempImg); - FreeImage_Unload(tempImg); - - GLuint w = FreeImage_GetWidth(img); - GLuint h = FreeImage_GetHeight(img); - GLuint scanW = FreeImage_GetPitch(img); - - if (format == FIF_EXR) - { - GLfloat* floatImg = new GLfloat[h * scanW]; - FreeImage_ConvertToRawBits((BYTE*)floatImg, img, scanW, 96, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, TRUE); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB32F, w, h, 0, GL_RGB, GL_FLOAT, floatImg); - delete[] floatImg; - } - else - { - GLubyte* byteImg = new GLubyte[h * scanW]; - FreeImage_ConvertToRawBits(byteImg, img, scanW, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, FALSE); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, byteImg); - delete[] byteImg; - } - - FreeImage_Unload(img); - } - - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - - return tex_id; -} diff --git a/source/scene.cpp b/source/scene.cpp index b10dd21..5d565f8 100644 --- a/source/scene.cpp +++ b/source/scene.cpp @@ -23,11 +23,8 @@ #include "scene.h" #include "Uniforms.h" -#include "InitShader.h" //Functions for loading shaders from text files +#include "InitShader.h" #include "DebugCallback.h" -#include "load_texture.h" - -#include namespace {