light/modules/renderer/public/graphics_context.hpp

51 lines
799 B
C++
Raw Permalink Normal View History

2022-03-08 21:19:19 +03:30
#pragma once
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:
2025-09-18 19:24:27 +03:30
static auto create(GraphicsAPI api) -> 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