Reorganization: GLM Integration, SDL2 on macOS Build Fix, and Structural Enhancements#11
Reorganization: GLM Integration, SDL2 on macOS Build Fix, and Structural Enhancements#11ZzzhHe wants to merge 9 commits intoSimple-XX:mainfrom
Conversation
|
|
||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
|
There was a problem hiding this comment.
这两个在 CMakePresets.json 里面设置过了,可以删掉
There was a problem hiding this comment.
但是删掉之后,就会在std::span的地方报错
In file included from /Users/hezhohao/Programming/GitRepo/SimpleRenderer/src/color.cpp:22:
/Users/hezhohao/Programming/GitRepo/SimpleRenderer/src/include/log_system.h:75:25: warning: unused parameter 'args' [-Wunused-parameter]
75 | void debug(TARGS &&...args) {
| ^
/Users/hezhohao/Programming/GitRepo/SimpleRenderer/src/color.cpp:33:24: error: no member named 'span' in namespace 'std'
33 | auto data_ptr = std::span(reinterpret_cast<uint8_t *>(&data), 4);
| ~~~~~^
/Users/hezhohao/Programming/GitRepo/SimpleRenderer/src/color.cpp:101:23: error: no member named 'span' in namespace 'std'
101 | auto ret_ptr = std::span(reinterpret_cast<uint8_t *>(&ret), 4);
| ~~~~~^
1 warning and 2 errors generated.
make[2]: *** [src/CMakeFiles/SimpleRenderer.dir/color.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/SimpleRenderer.dir/all] Error 2
make: *** [all] Error 2
参考这个链接
There was a problem hiding this comment.
我发现了,是因为CMakePresets.json这个文件我没设置好,导致在跑命令cmake --list-presets 的时候没有输出列表,然后就没办法用这个preset,我简单调整了一下preset的代码,现在可以正常使用preset跑了。
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
&
set(LOG_FILE_PATH "${PROJECT_SOURCE_DIR}/build/logs/SimpleRendererLog.log")
这两个地方都可以按照原本的代码直接跑,我下个commit会删掉我的更改
CMakeLists.txt
Outdated
| ProcessorCount(NPROC) | ||
| # 日志文件路径 | ||
| set(LOG_FILE_PATH "${EXECUTABLE_OUTPUT_PATH}/logs/SimpleRendererLog.log") | ||
| set(LOG_FILE_PATH "${PROJECT_SOURCE_DIR}/build/logs/SimpleRendererLog.log") |
There was a problem hiding this comment.
EXECUTABLE_OUTPUT_PATH 这个值同样在 CMakePresets.json 中,如果构建目录不在 build 下可能有问题,建议使用 CMakePresets.json 下的值
.gitignore
Outdated
| 3rd | ||
| Doxyfile | ||
| src/include/config.h | ||
| include/config.h |
There was a problem hiding this comment.
为啥要把 include 放在 src 外面呢?
我的理解是 src 下包括源码+头文件,include 与 src 同级的话感觉会与 tools/cmake 等辅助文件搞混
CMakeLists.txt
Outdated
| configure_file( | ||
| "${PROJECT_SOURCE_DIR}/cmake/config.h.in" | ||
| "${PROJECT_SOURCE_DIR}/src/include/config.h" | ||
| "${PROJECT_SOURCE_DIR}/include/config.h" |
cmake/3rd.cmake
Outdated
| "SDL_WERROR OFF" | ||
| ) | ||
| find_package(SDL2 REQUIRED) | ||
|
|
There was a problem hiding this comment.
239 行还有一个 find_package(SDL2 REQUIRED),是不是重复了?
|
|
||
| target_link_libraries(${PROJECT_NAME} PRIVATE | ||
| ${DEFAULT_LINK_LIB} | ||
| ${DEFAULT_LINK_LIB} |
There was a problem hiding this comment.
cmakelist 的对齐你是用的什么?我是 clion 默认的对齐方案,这样比较省事,如果你有好用的工具可以推荐下
src/model.cpp
Outdated
| */ | ||
|
|
||
| #include "model.hpp" | ||
| #include <glm/gtc/matrix_transform.hpp> |
There was a problem hiding this comment.
头文件顺序可以交给 clang-format 处理,vscode 里面一键格式化
src/model.cpp
Outdated
|
|
||
| auto res4 = Vector4f(coord_.x(), coord_.y(), coord_.z(), 1); | ||
| auto ret4 = Vector4f(tran * res4); | ||
| // Convert the 3D coordinate to a 4D vector by adding a 1.0 w-component |
| normal_ = (v0.normal_ + v1.normal_ + v2.normal_).normalized(); | ||
| if (glm::normalize(v0.normal_) != glm::vec3(0.0f) && glm::normalize(v1.normal_) != glm::vec3(0.0f) && | ||
| glm::normalize(v2.normal_) != glm::vec3(0.0f)) { | ||
| normal_ = glm::normalize((v0.normal_ + v1.normal_ + v2.normal_)); |
There was a problem hiding this comment.
我想起来为啥当时用了 eigen 没用 glm 了。。
eigen 面向对象的能力比较好,能与 c++ 无缝接轨,glm 就不太能优雅封装,在代码里耦合太多了。
这个问题我们先搁置,等我们 c++ 版本稳定后考虑用 rust 重写
test/CMakeLists.txt
Outdated
| endif() | ||
|
|
||
|
|
||
| # add_subdirectory(unit_test) |
Signed-off-by: ZhuohaoHe <zhuohao.he@outlook.com>
Signed-off-by: ZhuohaoHe <zhuohao.he@outlook.com>
Signed-off-by: ZhuohaoHe <zhuohao.he@outlook.com>
| using Normal = Vector3f; | ||
| /// 贴图 | ||
| using TextureCoord = Vector2f; | ||
| using TextureCoord = glm::vec2; |

Description
This pull request reorganizes the project structure and and includes several important refactors. The changes include:
Eigenlibrary withGLMfor vector and matrix operations.scene.cppfile as as its corresponding header file doesn't exist.Test Platform
TODO
assimplib.