Skip to content

Commit b32d4ff

Browse files
committed
Add load model
1 parent ffd2cdc commit b32d4ff

File tree

20 files changed

+34355
-29
lines changed

20 files changed

+34355
-29
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ find_package(Vulkan REQUIRED)
2626
find_package(glfw3 CONFIG REQUIRED)
2727
find_package(glm CONFIG REQUIRED)
2828
find_package(Stb REQUIRED)
29+
find_package(tinyobjloader CONFIG REQUIRED)
2930

3031
# Add executable program targets
3132
add_executable(${PROJECT_NAME} src/main.cpp)
@@ -34,6 +35,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan )
3435
target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm )
3536
target_link_libraries(${PROJECT_NAME} PRIVATE glfw )
3637
target_include_directories(${PROJECT_NAME} PRIVATE ${Stb_INCLUDE_DIR})
38+
target_link_libraries(${PROJECT_NAME} PRIVATE tinyobjloader::tinyobjloader)
3739
#################################################################################
3840

3941
#################################################################################

docs/codes/0400_texture/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ class HelloTriangleApplication {
12291229
}
12301230
void createTextureImage() {
12311231
int texWidth, texHeight, texChannels;
1232-
stbi_uc* pixels = stbi_load("texture/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
1232+
stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
12331233
if (!pixels) {
12341234
throw std::runtime_error("failed to load texture image!");
12351235
}

docs/codes/0400_texture/main.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ index 2e9de97..7feb5bb 100644
217217
+ }
218218
+ void createTextureImage() {
219219
+ int texWidth, texHeight, texChannels;
220-
+ stbi_uc* pixels = stbi_load("texture/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
220+
+ stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
221221
+ if (!pixels) {
222222
+ throw std::runtime_error("failed to load texture image!");
223223
+ }

docs/codes/0401_sampler/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ class HelloTriangleApplication {
12261226
}
12271227
void createTextureImage() {
12281228
int texWidth, texHeight, texChannels;
1229-
stbi_uc* pixels = stbi_load("texture/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
1229+
stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
12301230
if (!pixels) {
12311231
throw std::runtime_error("failed to load texture image!");
12321232
}

docs/codes/0402_combined/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ class HelloTriangleApplication {
12521252
}
12531253
void createTextureImage() {
12541254
int texWidth, texHeight, texChannels;
1255-
stbi_uc* pixels = stbi_load("texture/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
1255+
stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
12561256
if (!pixels) {
12571257
throw std::runtime_error("failed to load texture image!");
12581258
}

docs/codes/0500_depthbuffer/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ class HelloTriangleApplication {
13151315
}
13161316
void createTextureImage() {
13171317
int texWidth, texHeight, texChannels;
1318-
stbi_uc* pixels = stbi_load("texture/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
1318+
stbi_uc* pixels = stbi_load("textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
13191319
if (!pixels) {
13201320
throw std::runtime_error("failed to load texture image!");
13211321
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
3+
#################################################################################
4+
#### Set up the vcpkg toolchain, which must be done before the project() function.
5+
# You can also set it up by default through the CMakePresets.json file
6+
# requires the VCPKG_ROOT environment variable
7+
# The TO_CMAKE_PATH here is used to convert back slashes to forward slashes
8+
file(TO_CMAKE_PATH "$ENV{VCPKG_ROOT}" VCPKG_CMAKE_PATH)
9+
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_CMAKE_PATH}/scripts/buildsystems/vcpkg.cmake")
10+
#################################################################################
11+
12+
project(HelloVulkan LANGUAGES CXX)
13+
14+
set(CMAKE_CXX_STANDARD 20)
15+
16+
#################################################################################
17+
#### Search for Vulkan package.
18+
# CMake provides FindVulkan support, but requires the VULKAN_SDK environment variable
19+
# Setting by default during Vulkan SDK installation, such as E: \ Vulkan \ 1.4.309.0
20+
find_package(Vulkan REQUIRED)
21+
#################################################################################
22+
23+
#################################################################################
24+
#### add_executable
25+
# Import third-party libraries through vcpkg
26+
find_package(glfw3 CONFIG REQUIRED)
27+
find_package(glm CONFIG REQUIRED)
28+
find_package(Stb REQUIRED)
29+
find_package(tinyobjloader CONFIG REQUIRED)
30+
31+
# Add executable program targets
32+
add_executable(${PROJECT_NAME} src/main.cpp)
33+
34+
target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan )
35+
target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm )
36+
target_link_libraries(${PROJECT_NAME} PRIVATE glfw )
37+
target_include_directories(${PROJECT_NAME} PRIVATE ${Stb_INCLUDE_DIR})
38+
target_link_libraries(${PROJECT_NAME} PRIVATE tinyobjloader::tinyobjloader)
39+
#################################################################################
40+
41+
#################################################################################
42+
#### shaders
43+
add_subdirectory(shaders)
44+
#################################################################################

0 commit comments

Comments
 (0)