Skip to content

Commit

Permalink
[#1] Unicorn and ImGUI inegration.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-glushchenko committed Nov 25, 2017
1 parent daf26ca commit dd746a8
Show file tree
Hide file tree
Showing 15 changed files with 1,792 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "third_party/imgui"]
path = third_party/imgui
url = https://github.com/ocornut/imgui.git
[submodule "third_party/Catch2"]
path = third_party/Catch2
url = [email protected]:catchorg/Catch2.git
[submodule "godlike/Unicorn"]
path = godlike/Unicorn
url = [email protected]:Godlike/Unicorn.git
75 changes: 75 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2017 by Godlike
# This code is licensed under the MIT license (MIT)
# (http://opensource.org/licenses/MIT)

cmake_minimum_required(VERSION 3.1)
project(KhanEditor)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/godlike")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party")

option(KHAN_BUILD_DOCUMENTATION "Build documentation" OFF)
option(KHAN_BUILD_TESTS "Build tests" OFF)
set(KHAN_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "Khan root directory.")

#Report status
message(STATUS "${PROJECT_NAME} configuration:")
message(STATUS "-- KHAN_BUILD_TESTS: ${KHAN_BUILD_TESTS}")
message(STATUS "-- KHAN_BUID_DOCUMENTATION: ${KHAN_BUID_DOCUMENTATION}")

#UNICORN
include(UnicornConfig)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/godlike/Unicorn)
include_directories(${UNICORN_RENDER_INCLUDE_DIRS})

#IMGUI
include(ImguiConfig)
include_directories(${IMGUI_INCLUDE_DIR})

#Target
include(KhanConfig)
# Setup output folders if none were specified
if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
endif()

if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
endif()

if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
endif()

include_directories (
${KHAN_INCLUDE_DIR}
${GLFW_INCLUDE_DIR}
)
set(KHAN_HEADERS
Khan/include/Khan.hpp
Khan/include/imgui_impl_glfw_vulkan.h
)
set(KHAN_SOURCES
Khan/source/Khan.cpp
Khan/source/imgui_impl_glfw_vulkan.cpp
Khan/source/Main.cpp
)

add_executable (${PROJECT_NAME}
${KHAN_SOURCES}
${KHAN_HEADERS}
${IMGUI_SOURCES}
)
target_link_libraries(${PROJECT_NAME}
${UNICORN_LIB}
${GLFW_LIB}
${VULKAN_LIBRARY}
)

#Tests
if (KHAN_BUILD_TESTS)
enable_testing()
set(CATCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/Catch2)
add_subdirectory(test)
endif()
Empty file added Khan/include/Khan.hpp
Empty file.
42 changes: 42 additions & 0 deletions Khan/include/imgui_impl_glfw_vulkan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// ImGui GLFW binding with Vulkan + shaders
// FIXME: Changes of ImTextureID aren't supported by this binding! Please, someone add it!

// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown().
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui

struct GLFWwindow;

#define IMGUI_VK_QUEUED_FRAMES 2

struct ImGui_ImplGlfwVulkan_Init_Data
{
VkAllocationCallbacks* allocator;
VkPhysicalDevice gpu;
VkDevice device;
VkRenderPass render_pass;
VkPipelineCache pipeline_cache;
VkDescriptorPool descriptor_pool;
void (*check_vk_result)(VkResult err);
};

IMGUI_API bool ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, ImGui_ImplGlfwVulkan_Init_Data *init_data);
IMGUI_API void ImGui_ImplGlfwVulkan_Shutdown();
IMGUI_API void ImGui_ImplGlfwVulkan_NewFrame();
IMGUI_API void ImGui_ImplGlfwVulkan_Render(VkCommandBuffer command_buffer);

// Use if you want to reset your rendering device without losing ImGui state.
IMGUI_API void ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
IMGUI_API void ImGui_ImplGlfwVulkan_InvalidateDeviceObjects();
IMGUI_API bool ImGui_ImplGlfwVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
IMGUI_API bool ImGui_ImplGlfwVulkan_CreateDeviceObjects();

// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
// Provided here if you want to chain callbacks.
// You can also handle inputs yourself and use those as a reference.
IMGUI_API void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
IMGUI_API void ImGui_ImplGlfwVulkan_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
IMGUI_API void ImGui_ImplGlfwVulkan_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
IMGUI_API void ImGui_ImplGlfwVulkan_CharCallback(GLFWwindow* window, unsigned int c);

Empty file added Khan/source/Khan.cpp
Empty file.
Loading

0 comments on commit dd746a8

Please sign in to comment.