vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
render_backend.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <utility>
6#include <vector>
7
8#include "resource/resource_handle.h"
9
10namespace Vkm::Engine {
11
12struct RenderView;
13struct TextureAsset;
14class ResourceManager;
15class WindowManager;
17
24 std::string api;
25 std::string device;
26};
27
35class RenderBackend {
36 public:
37 RenderBackend() = default;
38 virtual ~RenderBackend() = default;
39
40 RenderBackend(const RenderBackend& other) = delete;
41 RenderBackend& operator=(const RenderBackend& other) = delete;
42
43 RenderBackend(RenderBackend && other) = delete;
44 RenderBackend& operator=(RenderBackend && other) = delete;
45
46 public:
56 virtual bool init(WindowManager& window) = 0;
57
67 virtual void render(const RenderView& view, const ResourceManager& resources) = 0;
68
80 virtual bool readFrame(const RenderView& view, std::vector<uint8_t>& pixels) {
81 pixels.clear();
82 return false;
83 }
84
93 virtual uint32_t reloadChangedShaders() { return 0; }
94
102 virtual uint32_t maxAnisotropy() const { return 1; }
103
113 virtual bool holdsPixels(
114 const Handle<TextureAsset>& texture,
115 uint64_t version
116 ) const { return false; }
117
123 virtual EditorRenderHooks* editorHooks() { return nullptr; }
124
125 public:
126 BackendInfo info() const { return m_info; }
127
128 protected:
130 void setInfo(BackendInfo info) { m_info = std::move(info); }
131
132 private:
133 BackendInfo m_info;
134};
135
136} // namespace Vkm::Engine
What a backend may offer an authoring tool beyond drawing the frame.
Definition editor_render_hooks.h:60
virtual void render(const RenderView &view, const ResourceManager &resources)=0
Draw one frame into the window's back buffer, for the engine loop to present.
virtual uint32_t maxAnisotropy() const
The highest anisotropic-filtering degree this backend can honour.
Definition render_backend.h:102
virtual bool holdsPixels(const Handle< TextureAsset > &texture, uint64_t version) const
Whether the backend holds its own copy of a texture's pixels.
Definition render_backend.h:113
void setInfo(BackendInfo info)
What info() reports, once init() knows the API and the device.
Definition render_backend.h:130
virtual bool init(WindowManager &window)=0
Bring the backend up against the window.
virtual uint32_t reloadChangedShaders()
Recompile shaders whose source changed on disk - a dev hook.
Definition render_backend.h:93
virtual EditorRenderHooks * editorHooks()
The backend's authoring-only hooks, or null when it offers none.
Definition render_backend.h:123
virtual bool readFrame(const RenderView &view, std::vector< uint8_t > &pixels)
Read back the frame render() last drew, as the window shows it.
Definition render_backend.h:80
Open type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
Owns the application's window, GL context, input, and frame limiting.
Definition window_manager.h:61
Human-readable backend identity, for a status display.
Definition render_backend.h:23
std::string api
e.g. "OpenGL 4.6"
Definition render_backend.h:24
std::string device
e.g. "NVIDIA GeForce RTX 3080"
Definition render_backend.h:25
Opaque, type-safe handle for resources, distinguished by ResourceType.
Definition resource_handle.h:16
The backend-agnostic view of the frame handed to RenderBackend::render.
Definition render_view.h:34
Texture asset combining Resource tracking with engine-level texture parameters.
Definition texture_asset.h:15