Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webgpu for ImGui and event manager #6

Merged
merged 2 commits into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
[submodule "external/stb"]
path = external/stb
url = https://github.com/nothings/stb.git
[submodule "external/predef"]
path = external/predef
url = https://github.com/boostorg/predef.git
[submodule "external/entt"]
path = external/entt
url = https://github.com/skypjack/entt.git
Expand All @@ -28,3 +25,6 @@
[submodule "external/sentry-native"]
path = external/sentry-native
url = https://github.com/getsentry/sentry-native.git
[submodule "external/magic-enum"]
path = external/magic-enum
url = https://github.com/Neargye/magic_enum.git
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,45 @@ set(CMAKE_CXX_STANDARD 17)
option(TEMPEH_ENABLE_TEST "Test" OFF)

add_subdirectory("external")

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use the highest warning level for Visual Studio.
set(CMAKE_CXX_WARNING_LEVEL 4)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# Disable C++ exceptions.
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Disable RTTI.
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use -Wall for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
# Use -Wextra for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
# Use -Werror for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
# Disable C++ exceptions.
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

add_subdirectory("engine")
add_subdirectory("editor")
add_subdirectory("test")
24 changes: 8 additions & 16 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
set(TEMPEH_ENGINE_EDITOR_HEADERS
"src/window/window.hpp"

"src/core/application.hpp"

"src/renderer/render_context.hpp"

"src/event/event.hpp"

"src/renderer/gui.hpp"
"src/renderer/gui_imgui_renderer.hpp"
"src/renderer/gui_renderer.hpp"
"src/renderer/editor_camera.hpp"
"src/window/keycode_glfw.hpp"
"src/renderer/gui_imgui_renderer.cpp")

set(TEMPEH_ENGINE_EDITOR_SOURCES
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp"
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp"

"src/main.cpp"
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp"
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp"
"src/core/application.cpp"

"src/renderer/render_context.cpp"

"src/window/window_glfw.cpp"
"src/window/input_manager.cpp"

"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp"
"${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp")

add_executable("tempeh_engine_editor"
${TEMPEH_ENGINE_EDITOR_SOURCES}
${TEMPEH_ENGINE_EDITOR_HEADERS})
${TEMPEH_ENGINE_EDITOR_HEADERS}
"src/gui/panel.hpp"
"src/gui/panels/scene_panel.hpp"
"src/gui/panels/scene_panel.cpp"
"src/gui/window_menubar_panel.cpp"
"src/gui/window_menubar_panel.hpp")

target_compile_definitions("tempeh_engine_editor"
PUBLIC SENTRY_DSN="https://8e07fe63b9c94200a0926d0d28b54ad2@o1113293.ingest.sentry.io/6143604")

target_include_directories("tempeh_engine_editor"
#PUBLIC "../common"
PUBLIC "${CMAKE_SOURCE_DIR}/external/dawn/src/utils"
PUBLIC "${CMAKE_SOURCE_DIR}/external/dawn/src"
andraantariksa marked this conversation as resolved.
Show resolved Hide resolved
PUBLIC "$ENV{MONO_INCLUDE_DIR}"
PUBLIC ${TEMPEH_COMMON_INCLUDE})

target_link_libraries("tempeh_engine_editor"
# Private, because anyone ain't gonna touch the editor
PRIVATE "glfw"
PRIVATE "boost_predef"
PRIVATE "tempeh_common"
PRIVATE "tempeh_core"
PRIVATE "tempeh_log"
Expand Down
14 changes: 8 additions & 6 deletions editor/src/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include <memory>
//#include <sentry.h>
#include <tempeh/logger.hpp>
#include "../window/window_glfw.hpp"
#include <tempeh/window/window_glfw.hpp>

namespace TempehEditor::Core {
Application::Application():
input_manager(std::make_shared<Window::InputManager>()),
window(std::make_shared<Window::WindowGLFW>(input_manager)),

Application::Application() :
input_manager(std::make_shared<Tempeh::Event::InputManager>()),
window(std::make_shared<Tempeh::Window::WindowGLFW>(input_manager)),
render_context(std::make_shared<Renderer::RenderContext>(window))
{
//sentry_options_t* options = sentry_options_new();
Expand All @@ -27,8 +27,10 @@ namespace TempehEditor::Core {
{
while (!window->is_need_to_close())
{
input_manager->clear();
window->process_input(*input_manager);
render_context->frame_start(window);

render_context->frame_start(window, *input_manager);
render_context->render();
}
return APPLICATION_RETURN_SUCCESS;
Expand Down
7 changes: 4 additions & 3 deletions editor/src/core/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#define APPLICATION_RETURN_SUCCESS 0

#include <memory>
#include "../window/window.hpp"
#include <tempeh/window/window.hpp>
#include <tempeh/event/input_manager.hpp>
#include "../renderer/render_context.hpp"
#include "../renderer/gui.hpp"

Expand All @@ -14,8 +15,8 @@ namespace TempehEditor::Core
class Application
{
private:
std::shared_ptr<TempehEditor::Window::InputManager> input_manager;
std::shared_ptr<Window::Window> window;
std::shared_ptr<Tempeh::Event::InputManager> input_manager;
std::shared_ptr<Tempeh::Window::Window> window;
std::shared_ptr<Renderer::RenderContext> render_context;
std::shared_ptr<Renderer::GUI::GUIImGuiRenderer> gui;

Expand Down
64 changes: 0 additions & 64 deletions editor/src/event/event.hpp

This file was deleted.

12 changes: 12 additions & 0 deletions editor/src/gui/panel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _TEMPEH_EDITOR_GUI_PANEL_HPP
#define _TEMPEH_EDITOR_GUI_PANEL_HPP

#include <tempeh/common/typedefs.hpp>

INTERFACE class Panel
{
public:
virtual void draw() = 0;
};

#endif
24 changes: 24 additions & 0 deletions editor/src/gui/panels/scene_panel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "../panel.hpp"

#include <imgui.h>

#include "scene_panel.hpp"

namespace TempehEditor::GUI::Panels
{

void ScenePanel::draw()
{
ImGui::Begin("#Scene Panel");
//ImVec2 pos = ImGui::GetCursorScreenPos();
//ImGui::GetWindowDrawList()->AddImage(
// (void*)window.getRenderTexture(),
// ImVec2(ImGui::GetCursorScreenPos()),
// ImVec2(ImGui::GetCursorScreenPos().x + window.getWidth() / 2,
// ImGui::GetCursorScreenPos().y + window.getHeight() / 2),
// ImVec2(0, 1),
// ImVec2(1, 0));
ImGui::End();
}

}
19 changes: 19 additions & 0 deletions editor/src/gui/panels/scene_panel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _TEMPEH_EDITOR_GUI_PANELS_SCENE_HPP
#define _TEMPEH_EDITOR_GUI_PANELS_SCENE_HPP

#include "../panel.hpp"

#include <imgui.h>

namespace TempehEditor::GUI::Panels
{

class ScenePanel : public Panel
{
private:
void draw() override;
};

}

#endif
37 changes: 37 additions & 0 deletions editor/src/gui/window_menubar_panel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "panel.hpp"
#include "window_menubar_panel.hpp"

#include <imgui.h>

namespace TempehEditor::GUI::Panels
{

void WindowMenubarPanel::draw()
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Close", "Blabla")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit"))
{
if (ImGui::MenuItem("Blabla", "Blabla")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("View"))
{
if (ImGui::MenuItem("Blabla", "Blabla")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Help"))
{
if (ImGui::MenuItem("Blabla", "Blabla")) {}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}

}
19 changes: 19 additions & 0 deletions editor/src/gui/window_menubar_panel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _TEMPEH_EDITOR_GUI_PANELS_SCENE_HPP
#define _TEMPEH_EDITOR_GUI_PANELS_SCENE_HPP

#include "panel.hpp"

#include <imgui.h>

namespace TempehEditor::GUI::Panels
{

class WindowMenubarPanel : public Panel
{
public:
void draw() override;
};

}

#endif
Loading