light/modules/renderer/public/graphics_context.hpp

58 lines
861 B
C++
Raw Normal View History

2022-03-08 21:19:19 +03:30
#pragma once
struct GLFWwindow;
2025-07-11 00:05:48 +03:30
namespace lt {
2022-03-08 21:19:19 +03:30
class SharedContext;
class WindowResizedEvent;
enum class GraphicsAPI
{
Default = 0,
OpenGL,
DirectX,
2025-07-05 16:07:51 +03:30
Vulkan,
Metal
2022-03-08 21:19:19 +03:30
};
2025-07-05 16:07:51 +03:30
class GraphicsContext
2022-03-08 21:19:19 +03:30
{
public:
static auto create(
GraphicsAPI api,
GLFWwindow *window_handle
) -> Scope<GraphicsContext>;
2025-07-05 16:07:51 +03:30
GraphicsContext(const GraphicsContext &) = delete;
2022-03-08 21:19:19 +03:30
2025-07-05 16:07:51 +03:30
GraphicsContext &operator=(const GraphicsContext &) = delete;
2022-03-08 21:19:19 +03:30
virtual ~GraphicsContext();
virtual void log_debug_data() = 0;
2022-03-08 21:19:19 +03:30
2025-07-06 14:02:50 +03:30
static GraphicsAPI get_graphics_api()
2025-07-05 16:07:51 +03:30
{
return s_context->m_graphics_api;
}
2022-03-08 21:19:19 +03:30
2025-07-06 14:02:50 +03:30
static Ref<SharedContext> get_shared_context()
2025-07-05 16:07:51 +03:30
{
return s_context->m_shared_context;
}
2022-03-08 21:19:19 +03:30
protected:
GraphicsContext() = default;
2025-07-05 16:07:51 +03:30
GraphicsAPI m_graphics_api;
Ref<SharedContext> m_shared_context = nullptr;
private:
static GraphicsContext *s_context;
2022-03-08 21:19:19 +03:30
};
2025-07-11 00:05:48 +03:30
} // namespace lt