CMake stuff, add Unix/Win32 ifs, add GLFW source

This commit is contained in:
4VRDriver
2020-09-05 18:26:00 +02:00
parent e16eb06984
commit 79717cfc57
7 changed files with 19 additions and 5 deletions

View File

@@ -4,7 +4,6 @@ project(Fall-Fever)
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(glfw3 3.3 REQUIRED)
find_package(OpenGL REQUIRED)
# Specify the C++ standard

7
PreLoad.cmake Normal file
View File

@@ -0,0 +1,7 @@
if(UNIX)
set(CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
endif(UNIX)
if(WIN32)
set(CMAKE_GENERATOR "MinGW Makefiles" CACHE INTERNAL "" FORCE)
endif(WIN32)

6
lib/CMakeLists.txt vendored
View File

@@ -1,4 +1,10 @@
# Only build GLFW library
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stb)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glm)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/assimp)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw-3.3.2)

View File

@@ -5,4 +5,6 @@ add_library(
target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(glad dl)
if(UNIX)
target_link_libraries(glad dl)
endif(UNIX)

View File

@@ -13,9 +13,9 @@ add_executable(Fall-Fever
target_link_libraries(
Fall-Fever PRIVATE
glfw
glad
stb
glfw
${OPENGL_LIBRARIES}
assimp
)

View File

@@ -94,7 +94,7 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene) {
}
// Material
if(mesh->mMaterialIndex >= 0) {
if(mesh->mMaterialIndex > 0) {
aiMaterial *material = scene->mMaterials[mesh->mMaterialIndex];
std::vector<Texture*> diffuseMaps = loadMaterialTextures(material, aiTextureType_DIFFUSE, texture_diffuse);
textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());

View File

@@ -9,7 +9,7 @@ Texture::Texture(const char* texturePath, uint8_t textureType) {
this->textureType = textureType;
stbi_set_flip_vertically_on_load(1);
auto *textureBuffer = stbi_load(texturePath, &textureWidth, &textureHeight, &bitsPerPixel, 4);
auto *textureBuffer = stbi_load(texturePath, &textureWidth, &textureHeight, &bitsPerPixel, STBI_rgb_alpha);
// Push texture to grahics card;
glGenTextures(1, &textureId);