forked from parallel101/hw01
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(hellocmake LANGUAGES CXX) | ||
|
||
add_subdirectory(stbiw) | ||
|
||
add_executable(main main.cpp) | ||
target_link_libraries(main PUBLIC stbiw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# hw01 | ||
|
||
第01讲的回家作业 | ||
|
||
# 要求 | ||
|
||
在 main.cpp 中为了导出一个美好的图像,使用了 `stb_image_write.h` 这个头文件。 | ||
|
||
在 CMakeLists.txt 中也引用了 stbiw 这个库,然而这个库还没有被定义。 | ||
你的任务就是定义 stbiw 这个库,他的内容应该包含 stbi_write_png 的实现。 | ||
|
||
最好以子模块 + 库的形式,实在搞不定的话同一个目录下 include 也可以。但是分数会低。 | ||
|
||
# 参考 | ||
|
||
stb_image_write.h 下载地址: https://github.com/nothings/stb/blob/master/stb_image_write.h | ||
|
||
你需要一个 .cpp 文件定义了 STB_IMAGE_WRITE_IMPLEMENTATION 这个宏,才能决定让 stbi 系列函数在这里实现。 | ||
|
||
像这样: | ||
```cmake | ||
target_compile_definitions(stbiw PUBLIC -DSTB_IMAGE_WRITE_IMPLEMENTATION) | ||
``` | ||
是不行的,因为如果两个 .cpp 文件都 include 了 stb_image_write.h,那么同一个函数会被定义两遍! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "stb_image_write.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
message(FATAL_ERROR "请修改 stbiw/CMakeLists.txt!要求生成一个名为 stbiw 的库") |