imgui wip
This commit is contained in:
@@ -18,17 +18,18 @@ find_package(Vulkan REQUIRED)
|
||||
|
||||
# Imgui
|
||||
file(GLOB imgui_sources dependency/imgui/*.h dependency/imgui/*.cpp)
|
||||
file(GLOB imgui_backend
|
||||
dependency/imgui/backends/imgui_impl_vulkan.h
|
||||
dependency/imgui/backends/imgui_impl_vulkan.cpp
|
||||
file(GLOB imgui_backend_sdl
|
||||
dependency/imgui/backends/imgui_impl_sdl3.h
|
||||
dependency/imgui/backends/imgui_impl_sdl3.cpp)
|
||||
file(GLOB imgui_backend_vulkan
|
||||
dependency/imgui/backends/imgui_impl_vulkan.h
|
||||
dependency/imgui/backends/imgui_impl_vulkan.cpp)
|
||||
|
||||
# Engine
|
||||
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
||||
add_executable(PuzGameEngine ${sources_engine} ${imgui_sources} ${imgui_backend})
|
||||
add_executable(PuzGameEngine ${sources_engine} ${imgui_sources} ${imgui_backend_sdl})
|
||||
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
|
||||
target_include_directories(PuzGameEngine PUBLIC dependency/imgui dependency/Vulkan-Headers/include)
|
||||
target_include_directories(PuzGameEngine PUBLIC dependency/imgui)
|
||||
#file(COPY ${data} DESTINATION resources)
|
||||
|
||||
#target_compile_options(PuzGameEngine PUBLIC xyz)
|
||||
@@ -37,9 +38,9 @@ target_include_directories(PuzGameEngine PUBLIC dependency/imgui dependency/Vulk
|
||||
# Game
|
||||
file(GLOB_RECURSE sources_game game/*.cpp game/*.h)
|
||||
file(GLOB source_singleheader dependency/tinygltf/stb_image.h dependency/tinygltf/stb_image_write.h dependency/tinygltf/json.hpp dependency/tinygltf/tiny_gltf.h)
|
||||
add_library(PuzGame SHARED ${sources_game} ${source_singleheader} ${imgui_sources})
|
||||
add_library(PuzGame SHARED ${sources_game} ${source_singleheader} ${imgui_sources} ${imgui_backend_vulkan})
|
||||
set_property(TARGET PuzGame PROPERTY CXX_STANDARD 17)
|
||||
target_include_directories(PuzGame PUBLIC dependency/imgui)
|
||||
target_include_directories(PuzGame PUBLIC dependency/imgui dependency/Vulkan-Headers/include)
|
||||
|
||||
# SDL
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/SDL" EXCLUDE_FROM_ALL)
|
||||
@@ -50,6 +51,6 @@ SET(BGFX_BUILD_EXAMPLES OFF)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/bgfx.cmake")
|
||||
|
||||
# Link
|
||||
target_link_libraries(PuzGame bx bimg bgfx)
|
||||
target_link_libraries(PuzGameEngine bx SDL3::SDL3 Vulkan::Vulkan)
|
||||
target_link_libraries(PuzGame bx bimg bgfx Vulkan::Vulkan)
|
||||
target_link_libraries(PuzGameEngine bx SDL3::SDL3)
|
||||
set_target_properties(PuzGame PROPERTIES OUTPUT_NAME "PuzGame2")
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#include "SDL3/SDL_mouse.h"
|
||||
#include "Shared.h"
|
||||
#include "Window.h"
|
||||
#include "bx/timer.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
#include <cstdio>
|
||||
#include <imgui.h>
|
||||
|
||||
void EngineWindow::Startup(SharedWindowData& shared)
|
||||
{
|
||||
@@ -13,7 +14,7 @@ void EngineWindow::Startup(SharedWindowData& shared)
|
||||
printf("Failed to init SDL!\n");
|
||||
return;
|
||||
}
|
||||
Window = SDL_CreateWindow("SDL", shared.WindowWidth, shared.WindowHeight, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
|
||||
Window = SDL_CreateWindow("SDL", shared.WindowWidth, shared.WindowHeight, SDL_WINDOW_RESIZABLE);
|
||||
if (Window == nullptr)
|
||||
{
|
||||
printf("Failed to init SDL Window!\n");
|
||||
@@ -29,6 +30,19 @@ void EngineWindow::Startup(SharedWindowData& shared)
|
||||
return;
|
||||
}
|
||||
SDL_SetWindowRelativeMouseMode(Window, true);
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
auto* imguiCtx = ImGui::CreateContext();
|
||||
if (imguiCtx == nullptr)
|
||||
{
|
||||
printf("Failed to set up imgui context!\n");
|
||||
return;
|
||||
}
|
||||
if (!ImGui_ImplSDL3_InitForVulkan(Window))
|
||||
{
|
||||
printf("Failed to set up imgui implementation!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void EngineWindow::Update(SharedWindowData& shared)
|
||||
@@ -37,6 +51,7 @@ void EngineWindow::Update(SharedWindowData& shared)
|
||||
SDL_Event evt;
|
||||
while (SDL_PollEvent(&evt))
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&evt);
|
||||
switch (evt.type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include <cstdio>
|
||||
#include <thread>
|
||||
|
||||
#include <backends/imgui_impl_vulkan.h>
|
||||
#include <imgui.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Game
|
||||
@@ -224,6 +227,12 @@ namespace Game
|
||||
|
||||
Materials[0] = Material::LoadFromShader("vert", "frag", Textures[0].Handle, Textures[0].SamplerHandle);
|
||||
|
||||
ImGui_ImplVulkan_InitInfo imguiVkInit;
|
||||
|
||||
// TODO
|
||||
// ImGui_ImplVulkan_Init(&imguiVkInit);
|
||||
// ImGui_ImplVulkan_CreateFontsTexture();
|
||||
|
||||
if (!GetInstance().IsInitialized)
|
||||
{
|
||||
GetInstance().Time.StartTime = bx::getHPCounter();
|
||||
|
||||
Reference in New Issue
Block a user