Skip to content

Commit 8f7e7ac

Browse files
MrScriptXDan Liebault
andauthored
#82 : exception thrown on mesh update queue (#83)
* introduce gameobject id * return mesh id on loadmesh * fast forward * directional lighting (#76) * add normals to vertex * vertex normal computed * implement viewing normal map shader * assets are moved so has to not copy them * light shader * add scene descriptorset * shader for light source * send multiple light types * cleanup (#77) * fix styling * fix normalmap example * no light use in examplecube * remove unused functions & moved to private internal functions * remove unused functions & move to private helper fonctions * fix code smells * split camera ubo and sceneubo * clang format * point light (#79) * add normals to vertex * vertex normal computed * implement viewing normal map shader * assets are moved so has to not copy them * light shader * specular light * remove compiled shader files * add binding of light * add scene descriptorset * remove unused code * add allocate descriptor set for ligthing with specific layout * bind new descriptor set for lighting * light transform is passed to shader * light array handle by scene is send to shader * pass number of lights to shader * fix normals * shader for light source * send multiple light types * fix cube geometry * refactoring & renaming * spotlight compute * fix merge issues * fix json * bump to v143 * update sdk to v143 * ImGui (#81) * ImGui implement * lock & unlock mouse * refactor mouse lock * remove empty file * update project * refactoring * create a console * remove old file * move file back to their respective folder & copy header to build folder * update dependency * better logging in console * Object Viewer * parent class for UI * console interface * update c++ standard * Update linter * Update gcc-build * fix shaders * update glfw3 & fix mouse rotation/clipping * watcher * update project files * some refactoring * update watcher to track positions * enhance UI & example code * update unix dependencies * fix bug on watcher * update shader compiler * instance refactor * compile shader * new log * update workflow * refactoring : splitting m_graphics & grouping objects for frame * remove old files * #82 : mesh set in deletion queue remove from update queue --------- Co-authored-by: Dan Liebault <[email protected]>
1 parent 1b71e68 commit 8f7e7ac

File tree

133 files changed

+55186
-745
lines changed

Some content is hidden

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

133 files changed

+55186
-745
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ AllowShortFunctionsOnASingleLine: None
1818

1919
MacroBlockBegin: "R3DENGINE_ .+"
2020

21-
Standard: c++17
21+
Standard: c++20

.github/workflows/gcc-build.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ jobs:
1111
- uses: lukka/[email protected]
1212
- name: Download Dependencies
1313
run: |
14-
sudo apt-get install -y build-essential pkg-config gcc-10 g++-10 xorg-dev libglu1-mesa-dev libopenal-dev libvulkan-dev wget libwayland-dev libxrandr-dev libassimp-dev ninja-build
14+
sudo apt update
15+
sudo apt install -y build-essential pkg-config gcc g++ xorg-dev libglu1-mesa-dev libopenal-dev libvulkan-dev wget libwayland-dev libxrandr-dev libassimp-dev ninja-build
1516
mkdir VULKAN_SDK
16-
BRANCH=$(curl https://sdk.lunarg.com/sdk/download/1.2.170.0/linux/SDK-1.2.170.0-CONFIG.json | jq '.repos["Vulkan-Headers"].branch' --raw-output)
17+
BRANCH=$(curl https://sdk.lunarg.com/sdk/download/1.3.243.0/linux/config.json | jq '.repos["Vulkan-Headers"].branch' --raw-output)
1718
echo BRANCH=$BRANCH >&2
1819
mkdir VULKAN_SDK/_build
1920
pushd VULKAN_SDK/_build >&2
@@ -41,9 +42,9 @@ jobs:
4142
4243
- name: Build
4344
env:
44-
CC: gcc-10
45-
CXX: g++-10
46-
LD_LIBRARY_PATH: /usr/bin/g++-10/lib
45+
CC: gcc-13
46+
CXX: g++-13
47+
LD_LIBRARY_PATH: /usr/bin/g++-13/lib
4748
VULKAN_SDK: /home/runner/work/R3D_Engine/R3D_Engine/VULKAN_SDK
4849
run: |
4950
cmake --version

.github/workflows/linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
- name: Checkout this commit
1111
uses: actions/checkout@v2
1212
- name: Run clang-format style check for C/C++ programs.
13-
uses: jidicula/clang-format-action@v3.4.0
13+
uses: jidicula/clang-format-action@v4.6.2
1414
with:
15-
clang-format-version: '11'
15+
clang-format-version: '14'
1616
check-path: 'Engine'
1717
fallback-style: 'GNU'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ build/
3434

3535
# Visual Studio 2015 cache/options directory
3636
.vs/
37+
.vscode/
3738
# Uncomment if you have tasks that create the project's static files in wwwroot
3839
#wwwroot/
3940

@@ -269,3 +270,5 @@ paket-files/
269270
# Python Tools for Visual Studio (PTVS)
270271
__pycache__/
271272
*.pyc
273+
274+
*.ini

CMakeLists.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)
33
# set the project name
44
project(R3DEngine)
55

6-
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD 20)
77
set(CMAKE_CXX_STANDARD_REQUIRED True)
88

99
IF(DEFINED ENV{VULKAN_SDK})
@@ -12,12 +12,12 @@ ELSE()
1212
MESSAGE(STATUS "VULKAN PATH NOT FOUND")
1313
ENDIF()
1414

15-
file(GLOB_RECURSE ENGINE_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "Engine/*.cpp")
15+
file(GLOB_RECURSE ENGINE_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "Engine/*.cpp" "dependencies/imgui-1.87/*.cpp")
1616

1717
add_library(R3DEngine STATIC ${ENGINE_SOURCES})
1818

1919
IF(UNIX)
20-
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.4/lib/unix/libglfw3.a")
20+
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.7/lib/unix/libglfw3.a")
2121
target_link_libraries(R3DEngine PUBLIC "$ENV{VULKAN_SDK}/lib/libvulkan.so.1")
2222
target_link_libraries(R3DEngine PUBLIC "$ENV{VULKAN_SDK}/lib/libvulkan.so")
2323

@@ -30,18 +30,19 @@ ENDIF()
3030

3131
IF(WIN32)
3232
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/assimp-5.0.1/lib/Debug/assimp-vc142-mtd.lib")
33-
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.4/lib/win/glfw3.lib")
33+
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.7/lib/win/glfw3.lib")
3434
target_link_libraries(R3DEngine PUBLIC "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib")
3535
ENDIF()
3636

3737
target_include_directories(R3DEngine PUBLIC "${PROJECT_BINARY_DIR}")
38-
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/Engine/Includes")
38+
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/Engine")
3939
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/assimp-5.0.1/include")
4040
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/assimp-5.0.1/include")
4141
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glew-2.1.0/include")
42-
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.4/include")
42+
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glfw-3.3.7/include")
4343
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glm")
4444
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/stb_image")
45+
target_include_directories(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/imgui-1.87")
4546
target_include_directories(R3DEngine PUBLIC $ENV{VULKAN_SDK}/Include)
4647

4748
target_link_libraries(R3DEngine PUBLIC "${PROJECT_SOURCE_DIR}/dependencies/glew-2.1.0/lib/Release/glew32.lib")

Engine/Engine.cpp

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
#include "Includes/Engine.h"
1+
#include "Engine.h"
22

33
Engine::Engine(uint32_t width, uint32_t height) : m_last_time(std::chrono::high_resolution_clock::now())
44
{
55
mp_main_camera = std::make_shared<Camera>();
66
mp_controller = std::make_shared<Controller>(mp_main_camera);
7+
8+
// setup default UI
9+
ConsoleUI* console = &ConsoleUI::Get();
10+
std::function<void()> console_hide = [console]() { console->SetActive(!console->IsActive()); };
11+
BindKeyToFunc(GLFW_KEY_GRAVE_ACCENT, console_hide, ActionType::R3D_PRESS);
12+
13+
m_UIs.push_back(console);
14+
15+
Watcher* watcher = &Watcher::Get();
16+
std::function<void()> watcher_hide = [watcher]() { watcher->SetActive(!watcher->IsActive()); };
17+
BindKeyToFunc(GLFW_KEY_F1, watcher_hide, ActionType::R3D_PRESS);
18+
19+
m_UIs.push_back(watcher);
20+
21+
// load config
722
mp_config = std::make_shared<Config>();
823
mp_config->width = width;
924
mp_config->height = height;
1025

26+
// start the interface
1127
mp_window = std::make_unique<Window>(mp_config, *mp_controller.get());
12-
1328
mp_renderer = std::make_shared<Renderer>(mp_window->getHandle(), mp_config->width, mp_config->height);
1429
}
1530

@@ -155,6 +170,23 @@ void Engine::SetColorMode(const ColorMode color_map)
155170
mp_renderer->SetColorMode(color_map);
156171
}
157172

173+
void Engine::RenderUI(UI& ui)
174+
{
175+
m_UIs.push_back(&ui);
176+
}
177+
178+
void Engine::RemoveUI(UI& ui)
179+
{
180+
for (auto it = m_UIs.begin(); it != m_UIs.end(); it++)
181+
{
182+
if (*it == &ui)
183+
{
184+
m_UIs.erase(it);
185+
break;
186+
}
187+
}
188+
}
189+
158190
const bool& Engine::shouldClose()
159191
{
160192
return glfwWindowShouldClose(&mp_window->getHandle());
@@ -175,7 +207,7 @@ void Engine::update()
175207
if (frame == -1)
176208
return;
177209

178-
if (mp_scene->isUpdate(frame) || mp_renderer->NeedUpdate(frame))
210+
if (mp_scene->IsUpdate(frame) || mp_renderer->NeedUpdate(frame))
179211
{
180212
mp_renderer->WaitForSwapchainImageFence();
181213

@@ -193,10 +225,21 @@ void Engine::update()
193225
mp_scene->UpdateUBO(mp_main_camera, mp_renderer, frame);
194226
mp_scene->UpdateSceneUBO(mp_renderer);
195227

228+
// Update UI
229+
ImGui_ImplVulkan_NewFrame();
230+
ImGui_ImplGlfw_NewFrame();
231+
ImGui::NewFrame();
232+
233+
for (size_t i = 0; i < m_UIs.size(); i++)
234+
m_UIs[i]->Update(mp_config->width, mp_config->height);
235+
236+
ImGui::Render();
237+
196238
// std::this_thread::sleep_for(std::chrono::nanoseconds(500));//delete when not streaming
197239
}
198240

199241
void Engine::draw()
200242
{
243+
mp_renderer->UpdateUI();
201244
mp_renderer->draw();
202245
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
#include "graphics/Geometry.h"
1111

12+
#include "ui/ConsoleUI.h"
13+
#include "ui/Watcher.h"
14+
1215
class Engine
1316
{
1417
public:
@@ -43,6 +46,9 @@ class Engine
4346
void SetFillMode();
4447
void SetColorMode(const ColorMode color_map);
4548

49+
void RenderUI(UI& ui);
50+
void RemoveUI(UI& ui);
51+
4652
const bool& shouldClose();
4753

4854
private:
@@ -55,6 +61,9 @@ class Engine
5561
std::shared_ptr<Config> mp_config;
5662

5763
std::chrono::time_point<std::chrono::high_resolution_clock> m_last_time;
64+
65+
// UI
66+
std::vector<UI*> m_UIs;
5867
};
5968

6069
#endif // !R3DENGINE_INCLUDES_ENGINE_H_

0 commit comments

Comments
 (0)