vkmEngine 1.0.0
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
12namespace Vkm::Engine {
13
14class ResourceManager;
15
19enum class PreviewBackground : uint8_t {
20 Dark,
21 Grey,
22 Sky,
23
24 Count
25};
26
33 uint64_t key = 0;
34 uint32_t size = 256;
35 MeshHandle mesh;
36 MaterialHandle material;
37 float yawDeg = 35.0f;
38 float pitchDeg = 20.0f;
39 float distance = 3.0f;
40 PreviewBackground background = PreviewBackground::Dark;
41 float lightYawDeg = 0.0f;
42};
43
50using GpuTextureId = uint64_t;
51
60class EditorRenderHooks {
61 public:
62 EditorRenderHooks() = default;
63 virtual ~EditorRenderHooks() = default;
64
65 EditorRenderHooks(const EditorRenderHooks& other) = delete;
66 EditorRenderHooks& operator=(const EditorRenderHooks& other) = delete;
67
68 EditorRenderHooks(EditorRenderHooks && other) = delete;
69 EditorRenderHooks& operator=(EditorRenderHooks && other) = delete;
70
71 public:
79 virtual GpuTextureId renderPreview(
80 const PreviewRequest& request,
81 const ResourceManager& resources
82 ) = 0;
83
90 virtual GpuTextureId previewTexture(uint64_t key) const = 0;
91
97 virtual void releasePreview(uint64_t key) = 0;
98
104 virtual void releaseAllPreviews() = 0;
105
115 virtual GpuTextureId textureId(const TextureHandle& handle) const = 0;
116
127 virtual GpuTextureId ensureTexture(const TextureHandle& handle, const ResourceManager& resources) = 0;
128
139 virtual GpuTextureId chromeImage(const std::string& path) = 0;
140};
141
148inline EditorRenderHooks* editorRenderHooks(RenderBackend* backend) {
149 return backend ? backend->editorHooks() : nullptr;
150}
151
152} // namespace Vkm::Engine
153
154VKM_ENUM_NAMES(::Vkm::Engine::PreviewBackground, "Dark", "Grey", "Sky")
155
What a backend may offer an authoring tool beyond drawing the frame.
Definition editor_render_hooks.h:60
virtual void releaseAllPreviews()=0
Drop every cached preview target.
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 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:35
virtual EditorRenderHooks * editorHooks()
The backend's authoring-only hooks, or null when it offers none.
Definition render_backend.h:123
Open type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
One editor preview: a mesh with a material under a studio rig, from an orbit camera.
Definition editor_render_hooks.h:32
float distance
In mesh bounding radii.
Definition editor_render_hooks.h:39
uint32_t size
Square edge, pixels.
Definition editor_render_hooks.h:34
float lightYawDeg
Studio rig rotation around Y.
Definition editor_render_hooks.h:41
uint64_t key
Identifies the cached target.
Definition editor_render_hooks.h:33