graphics-lab-1
graphics-lab-1
This project is based on example code provided in Lab 1 of DI41008 - Graphics module and used by WaterCoFire for self-learning purpose.
本项目是基于 DI41008 - Graphics(计算机图形学)课程的 Lab 1 所提供的示例代码的项目,被 WaterCoFire 用于自学目的。
The CMake configuration of the original project only supported building and running the project in a Visual Studio environment on Windows 11. WaterCoFire has updated the CMake configuration to ensure compatibility with both macOS (Apple Silicon) and Windows 11 systems using the MinGW toolchain (e.g., in IDEs like CLion or terminal environments). Furthermore, since all Lab tasks have been completed based on the document, this project is worthy of sharing.
原项目的 CMake 文件配置仅适用于 Windows 11 下的 Visual Studio 环境。WaterCoFire 在此基础上修改了 CMake 文件配置,使其能够在 macOS(Apple Silicon)及 Windows 11 系统中通过 MinGW 工具链成功构建和运行(例如在 CLion 等 IDE 或终端环境中)。加之由于所有 Lab 任务均已经依照文档完成,该项目具备分享价值。
DIICSU holds copyright on certain code in this project. Use responsibly.
本项目中的部分代码为 DIICSU 版权所有,请正确使用。
Similarly, since the Lab document is also protected by copyright, WaterCoFire cannot directly share them here. If you are a faculty/student of DIICSU, or other authorised person, please contact WaterCoFire for having access to relevant materials.
同理,由于 Lab 文档同样受到版权保护,WaterCoFire 无法在此直接提供分享。如果您是 DIICSU 的教职工/学生,或其他经过授权的人员,请与 WaterCoFire 联系以获取相关资料。
Some noteworthy points in CMake file:
本项目的 CMake 文件中值得注意的几点:
Linking GLFW on Windows 11 (should work for Windows 10 as well)
在 Windows 11 上链接 GLFW(应该对 Windows 10 同样适用)
1 | set(GLFW_DIR "YOUR_LOCATION_TO/glfw-3.4.bin.WIN64") # Change this path |
For GLFW on Windows, download at https://www.glfw.org/download.html (Windows pre-compiled libraries). Change the path accordingly. If not using MinGW as toolchain, change to the correct lib directory.
对于 Windows 平台的 GLFW,请在 https://www.glfw.org/download.html 下载(即 Windows 预编译库)。然后根据实际情况修改路径。若您未使用 MinGW 作为工具链,请切换至正确的 lib 目录。
Linking GLFW on macOS (Apple Silicon)
在 macOS(Apple Silicon)上链接 GLFW
1 | include_directories(/opt/homebrew/include) |
GLFW can be installed on Mac via Homebrew, so it is assumed here. If it is downloaded online, follow the method described before.
GLFW 可通过 Homebrew 安装在 Mac 上,因此此处采用了这种链接方法假设。若您是在线下载的它,请参照前文所述方法操作。
Extra libraries for macOS
macOS 上的额外库文件
Somehow when linking glfw3 library instead of glfw on Mac, a bunch of “undefined symbols” errors can occur. This can be solved by linking some extra libraries:
在 Mac 上,当链接 glfw3 库而非 glfw 库时,不知为何可能会出现大量 “undefined symbols”(未定义符号)错误。此问题可通过链接以下额外库来被解决:
1 | target_link_libraries(YOUR_CONFIGURATION_NAME |
Copying shader code files
复制着色器代码文件
Seperate shader code files like .vert and .frag must be in build directory to ensure the program runs properly. This is done like this:
独立的着色器代码文件(如 .vert 和 .frag)必须位于 build(构建)目录中,以确保程序正常运行。在本项目中的具体操作如下:
1 | file(COPY |
Accessing
访问
This project has been open-sourced on GitHub.
本项目已在 GitHub 上开源。
🔗 graphics-lab-1 on GitHubFound an issue, bug, or want to make a suggestion?
发现问题、bug,或希望提出建议?
Please report in the “Issues” section of this GitHub project:
请您在本 GitHub 项目的 “Issues” 区内提出:
- Click “New issue”.
点击 “New issue”。 - Write a title and description as required.
按要求撰写标题(title)和描述(description)。 - Click “Create”. You can also press Ctrl + Enter on Windows PC or ⌘ ⏎ on Mac.
点击 “Create”。您也可以在 Windows 电脑上按下 Ctrl + Enter 或在 Mac 上按下 ⌘ ⏎。
Unless otherwise stated, all posts from WaterCoFire are licensed under:
WaterCoFire 的所有内容分享除特别声明外,均采用本许可协议:
CC BY-NC-SA 4.0
Reprint with credit to this source, thanks!
转载请注明本来源,谢谢喵!
