Skip to content

Commit e20a127

Browse files
authored
Initial commit
0 parents  commit e20a127

73 files changed

Lines changed: 198633 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Generated from CLion C/C++ Code Style settings
2+
BasedOnStyle: LLVM
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: None
6+
AlignOperands: Align
7+
AllowAllArgumentsOnNextLine: false
8+
AllowAllConstructorInitializersOnNextLine: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: Always
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: All
13+
AllowShortIfStatementsOnASingleLine: Always
14+
AllowShortLambdasOnASingleLine: All
15+
AllowShortLoopsOnASingleLine: true
16+
AlwaysBreakAfterReturnType: None
17+
AlwaysBreakTemplateDeclarations: Yes
18+
BreakBeforeBraces: Custom
19+
BraceWrapping:
20+
AfterCaseLabel: false
21+
AfterClass: true
22+
AfterControlStatement: MultiLine
23+
AfterEnum: true
24+
AfterFunction: true
25+
AfterNamespace: true
26+
AfterStruct: true
27+
AfterUnion: true
28+
BeforeCatch: true
29+
BeforeElse: true
30+
IndentBraces: false
31+
SplitEmptyFunction: false
32+
SplitEmptyRecord: true
33+
BreakBeforeBinaryOperators: None
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializers: BeforeColon
36+
BreakInheritanceList: BeforeColon
37+
ColumnLimit: 0
38+
CompactNamespaces: false
39+
ContinuationIndentWidth: 8
40+
IndentCaseLabels: true
41+
IndentPPDirectives: None
42+
IndentWidth: 4
43+
KeepEmptyLinesAtTheStartOfBlocks: true
44+
MaxEmptyLinesToKeep: 2
45+
NamespaceIndentation: All
46+
ObjCSpaceAfterProperty: false
47+
ObjCSpaceBeforeProtocolList: true
48+
PointerAlignment: Left
49+
ReflowComments: false
50+
SpaceAfterCStyleCast: true
51+
SpaceAfterLogicalNot: false
52+
SpaceAfterTemplateKeyword: false
53+
SpaceBeforeAssignmentOperators: true
54+
SpaceBeforeCpp11BracedList: false
55+
SpaceBeforeCtorInitializerColon: true
56+
SpaceBeforeInheritanceColon: true
57+
SpaceBeforeParens: ControlStatements
58+
SpaceBeforeRangeBasedForLoopColon: false
59+
SpaceInEmptyParentheses: false
60+
SpacesBeforeTrailingComments: 0
61+
SpacesInAngles: false
62+
SpacesInCStyleCastParentheses: false
63+
SpacesInContainerLiterals: false
64+
SpacesInParentheses: false
65+
SpacesInSquareBrackets: false
66+
TabWidth: 4
67+
UseTab: ForContinuationAndIndentation

.github/workflows/check.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Check labs
2+
on: [push]
3+
jobs:
4+
build-and-check:
5+
name: Check labs
6+
runs-on: windows-latest
7+
steps:
8+
- name: Checkout the repo
9+
uses: actions/checkout@v4
10+
with:
11+
submodules: true
12+
- name: Build labs
13+
run: |
14+
mkdir build
15+
cd build
16+
cmake -DCMAKE_BUILD_TYPE=Release ..
17+
cmake --build . --config Release
18+
- name: Run rasterization lab
19+
run: |
20+
.\build\Release\Rasterization.exe --model_path models\cube.obj --result_path rasterization_cube.png
21+
.\build\Release\Rasterization.exe --model_path models\z_test.obj --result_path rasterization_z_test.png
22+
.\build\Release\Rasterization.exe --model_path models\CornellBox-Original.obj --result_path rasterization_CornellBox-Original.png
23+
- name: Upload rasterization images
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: Rasterization images
27+
path: rasterization_*.png
28+
- name: Run raytracing lab
29+
run: |
30+
.\build\Release\Raytracing.exe --model_path models\CornellBox-Original.obj --result_path raytracing_CornellBox-Original_1rpp_d1.png --camera_position 0.0,1.0,2.0 --accumulation_num 1 --raytracing_depth 1
31+
.\build\Release\Raytracing.exe --model_path models\CornellBox-Original.obj --result_path raytracing_CornellBox-Original_1rpp_d3.png --camera_position 0.0,1.0,2.0 --accumulation_num 1 --raytracing_depth 3
32+
.\build\Release\Raytracing.exe --model_path models\CornellBox-Original.obj --result_path raytracing_CornellBox-Original_16rpp_d3.png --camera_position 0.0,1.0,2.0 --accumulation_num 16 --raytracing_depth 3
33+
- name: Upload raytracing images
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: Raytracing images
37+
path: raytracing_*.png
38+
- name: Prepare a DX12 distro
39+
run: |
40+
cp build/Release/DirectX12.exe DirectX12.exe
41+
- name: Upload DirectX 12 distro
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: DirectX12 distro
45+
path: |
46+
DirectX12.exe
47+
shaders/
48+
models/

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
# Premake
35+
Premake5.exe
36+
37+
# Visual studio solution
38+
.vs/
39+
*.sln
40+
*.vcxproj
41+
*.vcxproj.user
42+
*.vcxproj.filters
43+
*.pdb
44+
*.idb
45+
*.ilk
46+
*.log
47+
*.tlog/
48+
49+
# Images
50+
*.png
51+
52+
# VS code
53+
.vscode/
54+
55+
# Artifacts
56+
bin/
57+
obj/
58+
build/
59+
60+
# CLion
61+
.idea/
62+
cmake-build-debug/
63+
cmake-build-release/

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "libs/cxxopts"]
2+
path = libs/cxxopts
3+
url = https://github.com/jarro2783/cxxopts
4+
[submodule "libs/linalg"]
5+
path = libs/linalg
6+
url = https://github.com/sgorsten/linalg.git
7+
[submodule "libs/stb"]
8+
path = libs/stb
9+
url = https://github.com/nothings/stb.git
10+
[submodule "libs/tinyobjloader"]
11+
path = libs/tinyobjloader
12+
url = https://github.com/tinyobjloader/tinyobjloader

CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5+
6+
project("Computer graphics in Game development")
7+
8+
set(INCLUDE
9+
libs/stb
10+
libs/tinyobjloader
11+
libs/linalg
12+
libs/cxxopts/include
13+
libs/D3DX12
14+
src)
15+
16+
set(SOURCE
17+
src/settings.cpp
18+
src/renderer/renderer.cpp
19+
src/world/camera.cpp
20+
src/world/model.cpp
21+
src/utils/resource_utils.cpp)
22+
23+
if(MSVC)
24+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
25+
endif()
26+
27+
add_executable(Rasterization src/main.cpp src/renderer/rasterizer/rasterizer_renderer.cpp ${SOURCE})
28+
target_compile_definitions(Rasterization PUBLIC RASTERIZATION)
29+
target_include_directories(Rasterization PRIVATE ${INCLUDE})
30+
set_property(TARGET Rasterization PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
31+
32+
find_package(OpenMP REQUIRED)
33+
add_executable(Raytracing src/main.cpp src/renderer/raytracer/raytracer_renderer.cpp ${SOURCE})
34+
target_compile_definitions(Raytracing PUBLIC RAYTRACING)
35+
target_include_directories(Raytracing PRIVATE ${INCLUDE})
36+
target_link_libraries(Raytracing PRIVATE OpenMP::OpenMP_CXX)
37+
set_property(TARGET Raytracing PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
38+
39+
add_executable(DirectX12 WIN32 src/win_main.cpp src/renderer/dx12/dx12_renderer.cpp src/utils/window.cpp ${SOURCE})
40+
target_compile_definitions(DirectX12 PUBLIC DX12 WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS _UNICODE UNICODE)
41+
target_include_directories(DirectX12 PRIVATE ${INCLUDE})
42+
target_link_libraries(DirectX12 d3d12.lib dxgi.lib d3dcompiler.lib dxguid.lib)
43+
set_property(TARGET DirectX12 PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Computer graphics in Game development course
2+
3+
This repo contains a template for Computer graphics in Game development labs
4+
5+
## Pre-requirements
6+
7+
- Version control: [Git](https://git-scm.com/)
8+
- Build automation: [CMake](https://cmake.org/download/)
9+
- C++ compiler: MSVC on Windows, Clang on MacOS, GCC on Linux (C++17 compatible)
10+
- [OpenMP library](https://www.openmp.org/)
11+
- Source code editor: [Visual Studio Code](https://code.visualstudio.com/Download)
12+
13+
For DirectX12 you need a Windows machine or VM with installed software and [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/).
14+
For graphics debugging you may to install [Microsoft PIX](https://devblogs.microsoft.com/pix/download/).
15+
16+
## How to build the solution
17+
18+
Use `git clone --recursive` to clone the repo with submodules or run `git submodule update --init --recursive` after the first clone.
19+
20+
Go to the project folder and run the next command:
21+
22+
```sh
23+
mkdir Build
24+
cd Build
25+
cmake ..
26+
```
27+
28+
## Third-party tools and data
29+
30+
- [STB](https://github.com/nothings/stb) by Sean Barrett (Public Domain)
31+
- [Linalg.h](https://github.com/sgorsten/linalg) by Sterling Orsten (The Unlicense)
32+
- [Tinyobjloader](https://github.com/syoyo/tinyobjloader) by Syoyo Fujita (MIT License)
33+
- [Cxxopts](https://github.com/jarro2783/cxxopts) by jarro2783 (MIT License)
34+
- [Cornell Box models](https://casual-effects.com/g3d/data10/index.html#) by Morgan McGuire (CC BY 3.0 License)
35+
- [Cube model](https://casual-effects.com/g3d/data10/index.html#) by Morgan McGuire (CC BY 3.0 License)
36+
- [Teapot model](https://casual-effects.com/g3d/data10/common/model/teapot/teapot.zip) by Martin Newell (CC0 License)
37+
- [Dabrovic Sponza model](https://casual-effects.com/g3d/data10/index.html#) by Marko Dabrovic (CC BY-NC License)

libs/cxxopts

Submodule cxxopts added at 58daccc

0 commit comments

Comments
 (0)