Вынес движок рендера в отдельный модуль ввиде статической библиотеки
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC "*.cpp" "*.c" "*.hpp" "*.h")
|
||||
|
||||
add_library(RenderEngineSDK ${SRC})
|
||||
|
||||
target_include_directories(RenderEngineSDK PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/glfw/Include
|
||||
${PROJECT_SOURCE_DIR}/Delegate
|
||||
${PROJECT_SOURCE_DIR}/Core
|
||||
)
|
||||
|
||||
target_link_libraries(RenderEngineSDK PUBLIC
|
||||
FastRTTI
|
||||
glfw
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "RenderEngineBase.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
RenderEngineBase::RenderEngineBase()
|
||||
{
|
||||
if (!glfwInit())
|
||||
throw std::runtime_error("Fail init glfw");
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
|
||||
window_ = glfwCreateWindow(800, 600, "UwU Engine", nullptr, nullptr);
|
||||
if (window_ == nullptr)
|
||||
throw std::runtime_error("Fail create window");
|
||||
}
|
||||
|
||||
RenderEngineBase::~RenderEngineBase()
|
||||
{
|
||||
if (window_ != nullptr)
|
||||
glfwDestroyWindow(window_);
|
||||
|
||||
glfwTerminate();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
class CoreInstance;
|
||||
|
||||
class RenderEngineBase
|
||||
{
|
||||
GLFWwindow* window_ = nullptr;
|
||||
|
||||
public:
|
||||
explicit RenderEngineBase();
|
||||
virtual ~RenderEngineBase();
|
||||
|
||||
virtual void start() = 0;
|
||||
virtual void stop_render() const = 0;
|
||||
|
||||
GLFWwindow* get_window() const { return window_; }
|
||||
};
|
||||
|
||||
#define RENDER_ENGINE_FACTORY_GENERATE(Class) \
|
||||
RenderEngineBase* RenderEngineFactory(CoreInstance& core) {\
|
||||
return new Class(core); \
|
||||
}
|
||||
Reference in New Issue
Block a user