From 90737bb654217b0bdcfd98eb28b9ca65263e899e Mon Sep 17 00:00:00 2001 From: David Siegel Date: Tue, 16 May 2023 20:24:05 +0200 Subject: [PATCH] Fix 8.3. Tesselation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CMake: Handle *.tcs and *.tes shader files - avoid directory name “resources”, since it triggers weird behaviour of glfwInit() on mac os (see remarks at https://www.glfw.org/docs/3.3/group__init.html#ga317aac130a235ab08c6db0834907d85e) - shader loader: print exception messages --- CMakeLists.txt | 10 +++++++--- includes/learnopengl/shader_t.h | 5 +++-- .../heightmaps/iceland_heightmap.png | Bin .../{resources => }/heightmaps/river2_heightmap.png | Bin .../{resources => }/heightmaps/river_heightmap.png | Bin .../2021/3.tessellation/terrain_cpu_src/main.cpp | 4 ++-- .../heightmaps/iceland_heightmap.png | Bin .../{resources => }/heightmaps/river2_heightmap.png | Bin .../{resources => }/heightmaps/river_heightmap.png | Bin .../2021/3.tessellation/terrain_gpu_dist/main.cpp | 2 +- 10 files changed, 13 insertions(+), 8 deletions(-) rename src/8.guest/2021/3.tessellation/terrain_cpu_src/{resources => }/heightmaps/iceland_heightmap.png (100%) rename src/8.guest/2021/3.tessellation/terrain_cpu_src/{resources => }/heightmaps/river2_heightmap.png (100%) rename src/8.guest/2021/3.tessellation/terrain_cpu_src/{resources => }/heightmaps/river_heightmap.png (100%) rename src/8.guest/2021/3.tessellation/terrain_gpu_dist/{resources => }/heightmaps/iceland_heightmap.png (100%) rename src/8.guest/2021/3.tessellation/terrain_gpu_dist/{resources => }/heightmaps/river2_heightmap.png (100%) rename src/8.guest/2021/3.tessellation/terrain_gpu_dist/{resources => }/heightmaps/river_heightmap.png (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 060384460..0def16b67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,8 +179,8 @@ set(GUEST_ARTICLES 8.guest/2021/1.scene/1.scene_graph 8.guest/2021/1.scene/2.frustum_culling 8.guest/2021/2.csm - #8.guest/2021/3.tessellation/terrain_gpu_dist - #8.guest/2021/3.tessellation/terrain_cpu_src + 8.guest/2021/3.tessellation/terrain_gpu_dist + 8.guest/2021/3.tessellation/terrain_cpu_src 8.guest/2021/4.dsa 8.guest/2022/5.computeshader_helloworld 8.guest/2022/6.physically_based_bloom @@ -208,6 +208,8 @@ function(create_project_from_sources chapter demo) "src/${chapter}/${demo}/*.cpp" "src/${chapter}/${demo}/*.vs" "src/${chapter}/${demo}/*.fs" + "src/${chapter}/${demo}/*.tcs" + "src/${chapter}/${demo}/*.tes" "src/${chapter}/${demo}/*.gs" "src/${chapter}/${demo}/*.cs" ) @@ -239,8 +241,10 @@ function(create_project_from_sources chapter demo) "src/${chapter}/${demo}/*.vs" # "src/${chapter}/${demo}/*.frag" "src/${chapter}/${demo}/*.fs" + "src/${chapter}/${demo}/*.tcs" + "src/${chapter}/${demo}/*.tes" "src/${chapter}/${demo}/*.gs" - "src/${chapter}/${demo}/*.cs" + "src/${chapter}/${demo}/*.cs" ) # copy dlls file(GLOB DLLS "dlls/*.dll") diff --git a/includes/learnopengl/shader_t.h b/includes/learnopengl/shader_t.h index 1994e6a80..f269543a2 100644 --- a/includes/learnopengl/shader_t.h +++ b/includes/learnopengl/shader_t.h @@ -76,7 +76,8 @@ class Shader } catch (std::ifstream::failure& e) { - std::cout << "ERROR::SHADER::FILE_NOT_SUCCESSFULLY_READ" << std::endl; + std::cout << "ERROR::SHADER::FILE_NOT_SUCCESSFULLY_READ: " + << e.what() << std::endl; } const char* vShaderCode = vertexCode.c_str(); const char * fShaderCode = fragmentCode.c_str(); @@ -232,4 +233,4 @@ class Shader } } }; -#endif \ No newline at end of file +#endif diff --git a/src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/iceland_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/iceland_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/iceland_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/iceland_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/river2_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/river2_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/river2_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/river2_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/river_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/river_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_cpu_src/resources/heightmaps/river_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_cpu_src/heightmaps/river_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_cpu_src/main.cpp b/src/8.guest/2021/3.tessellation/terrain_cpu_src/main.cpp index f7f592b21..c5bff96ad 100644 --- a/src/8.guest/2021/3.tessellation/terrain_cpu_src/main.cpp +++ b/src/8.guest/2021/3.tessellation/terrain_cpu_src/main.cpp @@ -90,7 +90,7 @@ int main() // The FileSystem::getPath(...) is part of the GitHub repository so we can find files on any IDE/platform; replace it with your own image path. stbi_set_flip_vertically_on_load(true); int width, height, nrChannels; - unsigned char *data = stbi_load("resources/heightmaps/iceland_heightmap.png", &width, &height, &nrChannels, 0); + unsigned char *data = stbi_load("heightmaps/iceland_heightmap.png", &width, &height, &nrChannels, 0); if (data) { std::cout << "Loaded heightmap of size " << height << " x " << width << std::endl; @@ -293,4 +293,4 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos) void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { camera.ProcessMouseScroll(yoffset); -} \ No newline at end of file +} diff --git a/src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/iceland_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/iceland_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/iceland_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/iceland_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/river2_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/river2_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/river2_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/river2_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/river_heightmap.png b/src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/river_heightmap.png similarity index 100% rename from src/8.guest/2021/3.tessellation/terrain_gpu_dist/resources/heightmaps/river_heightmap.png rename to src/8.guest/2021/3.tessellation/terrain_gpu_dist/heightmaps/river_heightmap.png diff --git a/src/8.guest/2021/3.tessellation/terrain_gpu_dist/main.cpp b/src/8.guest/2021/3.tessellation/terrain_gpu_dist/main.cpp index e2c0d7290..859e1757f 100644 --- a/src/8.guest/2021/3.tessellation/terrain_gpu_dist/main.cpp +++ b/src/8.guest/2021/3.tessellation/terrain_gpu_dist/main.cpp @@ -103,7 +103,7 @@ int main() // load image, create texture and generate mipmaps int width, height, nrChannels; // The FileSystem::getPath(...) is part of the GitHub repository so we can find files on any IDE/platform; replace it with your own image path. - unsigned char *data = stbi_load("resources/heightmaps/iceland_heightmap.png", &width, &height, &nrChannels, 0); + unsigned char *data = stbi_load("heightmaps/iceland_heightmap.png", &width, &height, &nrChannels, 0); if (data) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);