Got rid of load_texture due to errors
This commit is contained in:
parent
4078dc9943
commit
ca26a4f068
|
@ -65,13 +65,15 @@ include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/imgui/backends
|
${CMAKE_SOURCE_DIR}/imgui/backends
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp)
|
||||||
|
|
||||||
# Link libraries using vcpkg
|
# Link libraries using vcpkg
|
||||||
# Link the FreeImage library explicitly
|
# Link the FreeImage library explicitly
|
||||||
if (WIN32)
|
#if (WIN32)
|
||||||
target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-windows/lib/FreeImage.lib")
|
# target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-windows/lib/FreeImage.lib")
|
||||||
else()
|
#else()
|
||||||
target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-linux/lib/libFreeImage.a")
|
# target_link_libraries(TerraVisor PRIVATE GLEW::GLEW glfw glm::glm assimp::assimp "${VCPKG_ROOT}/installed/x64-linux/lib/libFreeImage.a")
|
||||||
endif()
|
#endif()
|
||||||
|
|
||||||
# Custom target for shaders
|
# Custom target for shaders
|
||||||
add_custom_target(copy_shaders ALL
|
add_custom_target(copy_shaders ALL
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef __LOADTEXTURE_H__
|
|
||||||
#define __LOADTEXTURE_H__
|
|
||||||
|
|
||||||
#include "platform_utils.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "GL/glew.h"
|
|
||||||
#include "GL/gl.h"
|
|
||||||
|
|
||||||
GLuint LoadTexture(const std::string& fname);
|
|
||||||
GLuint LoadSkybox(const std::vector<std::string>& faces);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,101 +0,0 @@
|
||||||
#include "load_texture.h"
|
|
||||||
#include <FreeImage.h>
|
|
||||||
|
|
||||||
|
|
||||||
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<std::string>& 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;
|
|
||||||
}
|
|
|
@ -23,11 +23,8 @@
|
||||||
|
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
#include "Uniforms.h"
|
#include "Uniforms.h"
|
||||||
#include "InitShader.h" //Functions for loading shaders from text files
|
#include "InitShader.h"
|
||||||
#include "DebugCallback.h"
|
#include "DebugCallback.h"
|
||||||
#include "load_texture.h"
|
|
||||||
|
|
||||||
#include <FreeImage.h>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue