Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
OpenglGHI.h
Go to the documentation of this file.
1#pragma once
2
3#include "RenderCore/GHI.h"
4
6
7#include <Common/config.h>
8
9#include <thread>
10#include <memory>
11
12namespace ph::editor::ghi
13{
14
15class OpenglContext;
16
17class OpenglGHI final : public GHI
18{
19public:
20 OpenglGHI(OpenglContext& ctx, GLFWwindow* glfwWindow, bool hasDebugContext);
21 ~OpenglGHI() override;
22
23 void load() override;
24 void unload() override;
25 void setViewport(uint32 xPx, uint32 yPx, uint32 widthPx, uint32 heightPx) override;
26 void clearBuffer(EClearTarget targets) override;
27 void setClearColor(const math::Vector4F& color) override;
28 void draw(Mesh& mesh, EMeshDrawMode drawMode) override;
29 void swapBuffers() override;
30
32 TextureHandle handle,
33 TSpanView<std::byte> pixelData,
34 EPixelFormat pixelFormat,
35 EPixelComponent pixelComponent) override;
36
38 TextureHandle handle,
39 const math::Vector2UI& regionOriginPx,
40 const math::Vector2UI& regionSizePx,
41 TSpanView<std::byte> pixelData,
42 EPixelFormat pixelFormat,
43 EPixelComponent pixelComponent) override;
44
46
48 uint32 attachmentIdx,
49 TextureHandle textureHandle,
50 FramebufferHandle framebufferHandle) override;
51
52 std::shared_ptr<Shader> createShader(
53 std::string name,
54 EShadingStage shadingStage,
55 std::string shaderSource) override;
56
57 std::shared_ptr<ShaderProgram> createShaderProgram(
58 std::string name,
59 const ShaderSetInfo& shaders) override;
60
61 std::shared_ptr<VertexStorage> createVertexStorage(
62 const VertexGroupFormatInfo& format,
63 std::size_t numVertices,
64 EStorageUsage usage) override;
65
66 std::shared_ptr<IndexStorage> createIndexStorage(
67 EStorageElement indexType,
68 std::size_t numIndices,
69 EStorageUsage usage) override;
70
71 std::shared_ptr<Mesh> createMesh(
72 const MeshVertexLayoutInfo& layout,
73 TSpanView<std::shared_ptr<VertexStorage>> vertexStorages,
74 const std::shared_ptr<IndexStorage>& indexStorage) override;
75
77
78private:
79 void beginRawCommand() override;
80 void endRawCommand() override;
81
82private:
83 OpenglContext& m_ctx;
84 GLFWwindow* m_glfwWindow;
85 bool m_hasDebugContext;
86 bool m_isLoaded;
87#if PH_DEBUG
88 std::thread::id m_loadThreadId;
89#endif
90 std::unique_ptr<DeviceCapabilityInfo> m_deviceCapability;
91};
92
93}// end namespace ph::editor::ghi
Definition ghi_infos.h:88
Graphics API abstraction.
Definition GHI.h:35
Definition Mesh.h:42
Definition OpenglContext.h:14
Definition OpenglGHI.h:18
std::shared_ptr< ShaderProgram > createShaderProgram(std::string name, const ShaderSetInfo &shaders) override
Definition OpenglGHI.cpp:390
std::shared_ptr< IndexStorage > createIndexStorage(EStorageElement indexType, std::size_t numIndices, EStorageUsage usage) override
Definition OpenglGHI.cpp:421
OpenglGHI(OpenglContext &ctx, GLFWwindow *glfwWindow, bool hasDebugContext)
Definition OpenglGHI.cpp:152
std::shared_ptr< Mesh > createMesh(const MeshVertexLayoutInfo &layout, TSpanView< std::shared_ptr< VertexStorage > > vertexStorages, const std::shared_ptr< IndexStorage > &indexStorage) override
Definition OpenglGHI.cpp:432
bool tryUploadPixelData(TextureHandle handle, TSpanView< std::byte > pixelData, EPixelFormat pixelFormat, EPixelComponent pixelComponent) override
Try to upload pixel data to a texture.
Definition OpenglGHI.cpp:305
void setViewport(uint32 xPx, uint32 yPx, uint32 widthPx, uint32 heightPx) override
Set how NDC corresponds to pixels on the display.
Definition OpenglGHI.cpp:229
void clearBuffer(EClearTarget targets) override
Definition OpenglGHI.cpp:238
void setClearColor(const math::Vector4F &color) override
Definition OpenglGHI.cpp:262
DeviceCapabilityInfo getDeviceCapabilities() override
Definition OpenglGHI.cpp:443
void unload() override
Unload and clean up the GHI. Must be called on the same thread as load(). See load() for more informa...
Definition OpenglGHI.cpp:217
void load() override
Load and initiate the GHI. load() and unload() must be called on the same thread. All remaining metho...
Definition OpenglGHI.cpp:171
TextureNativeHandle tryGetTextureNativeHandle(TextureHandle handle) override
Definition OpenglGHI.cpp:339
void attachTextureToFramebuffer(uint32 attachmentIdx, TextureHandle textureHandle, FramebufferHandle framebufferHandle) override
Definition OpenglGHI.cpp:350
std::shared_ptr< Shader > createShader(std::string name, EShadingStage shadingStage, std::string shaderSource) override
Definition OpenglGHI.cpp:379
~OpenglGHI() override
Definition OpenglGHI.cpp:166
void draw(Mesh &mesh, EMeshDrawMode drawMode) override
Definition OpenglGHI.cpp:271
void swapBuffers() override
Definition OpenglGHI.cpp:300
std::shared_ptr< VertexStorage > createVertexStorage(const VertexGroupFormatInfo &format, std::size_t numVertices, EStorageUsage usage) override
Definition OpenglGHI.cpp:410
bool tryUploadPixelDataTo2DRegion(TextureHandle handle, const math::Vector2UI &regionOriginPx, const math::Vector2UI &regionSizePx, TSpanView< std::byte > pixelData, EPixelFormat pixelFormat, EPixelComponent pixelComponent) override
Definition OpenglGHI.cpp:321
Definition ghi_infos.h:46
Definition PlatformDisplay.h:13
EPixelFormat
Definition ghi_enums.h:31
std::variant< std::monostate, uint64 > TextureNativeHandle
Definition ghi_fwd.h:52
EStorageElement
Definition ghi_enums.h:70
EClearTarget
Definition EClearTarget.h:11
EShadingStage
Definition ghi_enums.h:104
EStorageUsage
Definition ghi_enums.h:86
EMeshDrawMode
Definition ghi_enums.h:93
EPixelComponent
Definition ghi_enums.h:42