Skip to content

Commit

Permalink
Merge pull request #1 from Trit0/switching-vulkan-3d
Browse files Browse the repository at this point in the history
Tutorial changes Vulkan.
  • Loading branch information
Trit0 authored Dec 14, 2023
2 parents b658fb4 + 948eb69 commit f6a337a
Show file tree
Hide file tree
Showing 105 changed files with 57,906 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/build
/build
/cmake-build-debug**
/include
CMakeUserPresets.json
**/*.spv
2 changes: 1 addition & 1 deletion .idea/GEngine.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/Test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions .idea/editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.26)
project(TEngine)

set(CMAKE_TOOLCHAIN_FILE include/conan_toolchain.cmake)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 23)

set(SHADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shaders)

file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB SHADER_FILES ${SHADERS_DIR}/*.frag ${SHADERS_DIR}/*.vert)

find_package(GLFW3 REQUIRED)
find_package(GLM REQUIRED)
find_package(Vulkan REQUIRED)
find_package(tinyobjloader REQUIRED)

find_package(Vulkan COMPONENTS glslc)
find_program(glslc_executable NAMES glslc HINTS Vulkan::glslc)

function(compile_shader target)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "ENV;FORMAT" "SOURCES")
foreach(source ${arg_SOURCES})
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND
${glslc_executable}
${source}
-o ${source}.${arg_FORMAT}
)
target_sources(${target} PRIVATE ${source}.${arg_FORMAT})
endforeach()
endfunction()

message("Building with CMake version: ${CMAKE_VERSION}")

add_executable(${PROJECT_NAME} ${SOURCES})

compile_shader(${PROJECT_NAME}
FORMAT spv
SOURCES
${SHADER_FILES}
)

target_link_libraries(${PROJECT_NAME} glfw glm::glm Vulkan::Vulkan tinyobjloader::tinyobjloader)
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src ${glfw3_INCLUDE_DIRS} ${glm_INCLUDE_DIRS} ${tinyobjloader_INCLUDE_DIRS})
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# TEngine
# TEngine

```bash
conan install . --output-folder=include --build=missing
cmake ./cmake-build-debug -DCMAKE_TOOLCHAIN_FILE=include/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
```

`cmake --preset conan-release`
Binary file removed Thumbs.db
Binary file not shown.
8 changes: 8 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
shader=(`find . -type f -name \*.vert -o -name \*.frag`)
index=0

for i in "${shader[@]}"; do
echo "Compiling $i.spv"
glslc "$i" -o "$i.spv"
index=$((index+1))
done
15 changes: 15 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[requires]
glfw/3.3.8
glm/cci.20230113
tinyobjloader/2.0.0-rc10

[tool_requires]
cmake/3.27.7

[imports]
include, *.h -> ./include
include, *.hpp -> ./include

[generators]
CMakeDeps
CMakeToolchain
46 changes: 46 additions & 0 deletions models/colored_cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Blender v2.90.1 OBJ File: ''
# www.blender.org
mtllib untitled.mtl
o Cube
v 1.000000 -1.000000 1.000000 1.0 0.0 0.0
v 1.000000 1.000000 1.000000 0.0 0.0 1.0
v 1.000000 -1.000000 -1.000000 0.0 1.0 0.0
v 1.000000 1.000000 -1.000000 1.0 0.5 0.0
v -1.000000 -1.000000 1.000000 1.0 0.0 0.0
v -1.000000 1.000000 1.000000 1.0 0.0 1.0
v -1.000000 -1.000000 -1.000000 0.0 1.0 0.0
v -1.000000 1.000000 -1.000000 1.0 0.5 0.0
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
usemtl Material
s off
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6
46 changes: 46 additions & 0 deletions models/cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Blender v2.90.1 OBJ File: ''
# www.blender.org
mtllib untitled.mtl
o Cube
v 1.000000 -1.000000 1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 -1.000000
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
usemtl Material
s off
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6
Loading

0 comments on commit f6a337a

Please sign in to comment.