Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
drawable.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4
5#include "flint/graphics/gpu/gpu-texture.h"
6
7#include <memory>
8
9namespace Flint {
10 class RenderQueue;
11 class GPURenderer;
12
21 class Drawable {
22 public:
23 virtual ~Drawable() = default;
24
34 virtual void emit(RenderQueue &queue) const = 0;
35
42 void setGPUTexture(GPUTexture *texture) {
43 m_gpuTexture = texture;
44 }
45
51 [[nodiscard]] GPUTexture *getGPUTexture() const {
52 return m_gpuTexture;
53 }
54
55 protected:
57 };
58
64 enum class DrawLayer {
65 Background = 0,
66 Midground = 1,
67 Foreground = 2,
68 UI = 3
69 };
70
72 struct DrawCommand {
73 DrawLayer layer;
74 std::shared_ptr<const Drawable> drawable;
75 };
76}
virtual void emit(RenderQueue &queue) const =0
Emit this drawable's rendering work for the current frame.
GPUTexture * m_gpuTexture
Non-owning reference to the GPU texture asset.
Definition drawable.h:56
GPUTexture * getGPUTexture() const
Get the associated GPU texture.
Definition drawable.h:51
void setGPUTexture(GPUTexture *texture)
Associate a texture with this drawable.
Definition drawable.h:42
Interface for objects that contribute ordered work to a rendered frame.
Definition drawable.h:21
Owns an SDL GPU texture and its associated sampler.
Definition gpu-texture.h:20
Batches drawables into sorted geometry, primitive, and custom execution passes for GPURenderer.
DrawLayer layer
Definition drawable.h:73
std::shared_ptr< const Drawable > drawable
Definition drawable.h:74
Associates a submitted drawable with its render layer.
Definition drawable.h:72