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
9
namespace
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
:
56
GPUTexture
*
m_gpuTexture
=
nullptr
;
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
}
Flint::Drawable::emit
virtual void emit(RenderQueue &queue) const =0
Emit this drawable's rendering work for the current frame.
Flint::Drawable::m_gpuTexture
GPUTexture * m_gpuTexture
Non-owning reference to the GPU texture asset.
Definition
drawable.h:56
Flint::Drawable::getGPUTexture
GPUTexture * getGPUTexture() const
Get the associated GPU texture.
Definition
drawable.h:51
Flint::Drawable::setGPUTexture
void setGPUTexture(GPUTexture *texture)
Associate a texture with this drawable.
Definition
drawable.h:42
Flint::Drawable
Interface for objects that contribute ordered work to a rendered frame.
Definition
drawable.h:21
Flint::GPUTexture
Owns an SDL GPU texture and its associated sampler.
Definition
gpu-texture.h:20
Flint::RenderQueue
Batches drawables into sorted geometry, primitive, and custom execution passes for GPURenderer.
Definition
render-queue.h:28
Flint::DrawCommand::layer
DrawLayer layer
Definition
drawable.h:73
Flint::DrawCommand::drawable
std::shared_ptr< const Drawable > drawable
Definition
drawable.h:74
Flint::DrawCommand
Associates a submitted drawable with its render layer.
Definition
drawable.h:72
include
flint
graphics
drawable.h
Generated by
1.12.0