vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
editor_render_hooks.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6#include "core/reflect.h"
7
8#include "resource/asset/mesh_asset.h"
9#include "resource/asset/material_asset.h"
10#include "system/render/render_backend.h"
11
12struct GLFWwindow;
13struct ImDrawData;
14
15namespace Vkm::Engine {
16
17class ResourceManager;
18
22enum class PreviewBackground : uint8_t {
23 Dark,
24 Grey,
25 Sky,
26
27 Count
28};
29
36 uint64_t key = 0;
37 uint32_t size = 256;
38 MeshHandle mesh;
39 MaterialHandle material;
40 float yawDeg = 35.0f;
41 float pitchDeg = 20.0f;
42 float distance = 3.0f;
43 PreviewBackground background = PreviewBackground::Dark;
44 float lightYawDeg = 0.0f;
45};
46
53using GpuTextureId = uint64_t;
54
64class EditorRenderHooks {
65 public:
66 EditorRenderHooks() = default;
67 virtual ~EditorRenderHooks() = default;
68
69 EditorRenderHooks(const EditorRenderHooks& other) = delete;
70 EditorRenderHooks& operator=(const EditorRenderHooks& other) = delete;
71
72 EditorRenderHooks(EditorRenderHooks && other) = delete;
73 EditorRenderHooks& operator=(EditorRenderHooks && other) = delete;
74
75 public:
83 virtual GpuTextureId renderPreview(
84 const PreviewRequest& request,
85 const ResourceManager& resources
86 ) = 0;
87
95 virtual uint64_t previewLook() const = 0;
96
103 virtual GpuTextureId previewTexture(uint64_t key) const = 0;
104
110 virtual void releasePreview(uint64_t key) = 0;
111
117 virtual void releaseAllPreviews() = 0;
118
128 virtual GpuTextureId textureId(const TextureHandle& handle) const = 0;
129
140 virtual GpuTextureId ensureTexture(const TextureHandle& handle, const ResourceManager& resources) = 0;
141
152 virtual GpuTextureId chromeImage(const std::string& path) = 0;
153
162 virtual void initImGui(GLFWwindow* window) = 0;
163
165 virtual void beginImGuiFrame() = 0;
166
172 virtual void renderImGui(ImDrawData* data) = 0;
173
175 virtual void shutdownImGui() = 0;
176};
177
184inline EditorRenderHooks* editorRenderHooks(RenderBackend* backend) {
185 return backend ? backend->editorHooks() : nullptr;
186}
187
188} // namespace Vkm::Engine
189
190VKM_ENUM_NAMES(::Vkm::Engine::PreviewBackground, "Dark", "Grey", "Sky")
191
What a backend may offer an authoring tool beyond drawing the frame.
Definition editor_render_hooks.h:64
virtual void releaseAllPreviews()=0
Drop every cached preview target.
virtual void initImGui(GLFWwindow *window)=0
Start ImGui's renderer on window, and the platform half that has to know it.
virtual GpuTextureId previewTexture(uint64_t key) const =0
The texture last rendered for key, without rendering one.
virtual GpuTextureId ensureTexture(const TextureHandle &handle, const ResourceManager &resources)=0
Mirror handle onto the GPU if it is not already, and return it.
virtual GpuTextureId textureId(const TextureHandle &handle) const =0
GPU texture id already mirrored for handle, or 0 if none is.
virtual GpuTextureId chromeImage(const std::string &path)=0
Upload an image the engine owns and return its texture id.
virtual void releasePreview(uint64_t key)=0
Drop the cached target held for key.
virtual void shutdownImGui()=0
Stop the renderer and the platform half initImGui() started.
virtual uint64_t previewLook() const =0
A digest of what a preview borrows from the scene: its light and grade.
virtual void renderImGui(ImDrawData *data)=0
Draw ImGui's finished frame into the window.
virtual void beginImGuiFrame()=0
Begin the renderer's half of an ImGui frame, before the platform's and ImGui's own.
virtual GpuTextureId renderPreview(const PreviewRequest &request, const ResourceManager &resources)=0
Draw request offscreen and return the texture to display.
The frame's seam between the engine and the graphics API.
Definition render_backend.h:39
virtual EditorRenderHooks * editorHooks()=0
The backend's authoring-only hooks, or null when it offers none.
Type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
One editor preview: a mesh with a material under the scene's light, from an orbit camera.
Definition editor_render_hooks.h:35
float distance
In mesh bounding radii.
Definition editor_render_hooks.h:42
uint32_t size
Square edge, pixels.
Definition editor_render_hooks.h:37
float lightYawDeg
The light's rotation around Y, degrees.
Definition editor_render_hooks.h:44
uint64_t key
Identifies the cached target.
Definition editor_render_hooks.h:36