-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganization: GLM Integration, SDL2 on macOS Build Fix, and Structural Enhancements #11
base: main
Are you sure you want to change the base?
Conversation
@@ -7,6 +7,9 @@ | |||
# 设置最小 cmake 版本 | |||
cmake_minimum_required(VERSION 3.27 FATAL_ERROR) | |||
|
|||
set(CMAKE_CXX_STANDARD 20) | |||
set(CMAKE_CXX_STANDARD_REQUIRED True) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个在 CMakePresets.json 里面设置过了,可以删掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
但是删掉之后,就会在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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我发现了,是因为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
@@ -39,15 +42,15 @@ set(FONT_FILE_PATH "${wqy_font_SOURCE_DIR}/wqy-zenhei.ttc") | |||
include(ProcessorCount) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXECUTABLE_OUTPUT_PATH 这个值同样在 CMakePresets.json 中,如果构建目录不在 build 下可能有问题,建议使用 CMakePresets.json 下的值
.gitignore
Outdated
@@ -14,4 +14,4 @@ tools/opensbi/build | |||
.idea | |||
3rd | |||
Doxyfile | |||
src/include/config.h | |||
include/config.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥要把 include 放在 src 外面呢?
我的理解是 src 下包括源码+头文件,include 与 src 同级的话感觉会与 tools/cmake 等辅助文件搞混
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到🫡
CMakeLists.txt
Outdated
# 日志文件大小 | ||
set(LOG_FILE_MAX_SIZE 1024*1024*4) | ||
# 日志文件数量 | ||
set(LOG_FILE_MAX_COUNT 8) | ||
# 生成配置头文件 | ||
configure_file( | ||
"${PROJECT_SOURCE_DIR}/cmake/config.h.in" | ||
"${PROJECT_SOURCE_DIR}/src/include/config.h" | ||
"${PROJECT_SOURCE_DIR}/include/config.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还是 include 目录的问题,后面不再专门说了~
cmake/3rd.cmake
Outdated
"SDL_WERROR OFF" | ||
) | ||
find_package(SDL2 REQUIRED) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
239 行还有一个 find_package(SDL2 REQUIRED),是不是重复了?
) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
${DEFAULT_LINK_LIB} | ||
${DEFAULT_LINK_LIB} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmakelist 的对齐你是用的什么?我是 clion 默认的对齐方案,这样比较省事,如果你有好用的工具可以推荐下
src/model.cpp
Outdated
@@ -15,6 +15,7 @@ | |||
*/ | |||
|
|||
#include "model.hpp" | |||
#include <glm/gtc/matrix_transform.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
头文件顺序可以交给 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释可以顺手写个中文的,当然有些术语用中文很别扭的话除外
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到🫡
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我想起来为啥当时用了 eigen 没用 glm 了。。
eigen 面向对象的能力比较好,能与 c++ 无缝接轨,glm 就不太能优雅封装,在代码里耦合太多了。
这个问题我们先搁置,等我们 c++ 版本稳定后考虑用 rust 重写
test/CMakeLists.txt
Outdated
endif() | ||
|
||
|
||
# add_subdirectory(unit_test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种预定义可以 放在 CMakePresets.json 里面
Signed-off-by: ZhuohaoHe <[email protected]>
Signed-off-by: ZhuohaoHe <[email protected]>
Signed-off-by: ZhuohaoHe <[email protected]>
@@ -40,7 +40,7 @@ class Model { | |||
/// 法向量 | |||
using Normal = Vector3f; | |||
/// 贴图 | |||
using TextureCoord = Vector2f; | |||
using TextureCoord = glm::vec2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们不是有 Vector2f 嘛,直接用呗
Description
This pull request reorganizes the project structure and and includes several important refactors. The changes include:
Eigen
library withGLM
for vector and matrix operations.scene.cpp
file as as its corresponding header file doesn't exist.Test Platform
TODO
assimp
lib.