Capycore Engine
0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
sdl_text_strategy.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <SDL3/SDL.h>
4
#include <SDL3_ttf/SDL_ttf.h>
5
#include <
engine/core/rendering/strategies/irendering_strategy.h
>
6
#include <
engine/public/component.h
>
7
#include <
engine/public/components/ui/text.h
>
8
#include <
engine/public/ui/ui_object.h
>
9
10
#include <map>
11
#include <memory>
12
#include <string>
13
22
class
SdlTextStrategy
final :
public
IRenderingStrategy
{
23
private
:
24
SDL_Renderer& sdl_renderer_;
25
26
std::unique_ptr<SDL_Texture, void (*)(SDL_Texture*)> texture_{
27
nullptr
, SDL_DestroyTexture};
28
29
float
last_font_width_ = 0.0f;
30
float
last_font_height_ = 0.0f;
31
32
static
std::reference_wrapper<TTF_Font> get_font(
const
std::string& name,
33
const
std::string& path,
34
int
size);
35
void
draw_cached(
Text
& text,
const
UIObject
& ui_object,
36
const
Transform
& transform,
float
scale_x,
float
scale_y);
37
void
draw_fresh(
Text
& text,
const
UIObject
& ui_object,
38
const
Transform
& transform,
float
scale_x,
float
scale_y);
39
40
public
:
41
SdlTextStrategy
(SDL_Renderer& sdl_renderer);
42
~SdlTextStrategy
()
override
=
default
;
43
void
draw
(
Component
& component,
Camera
& camera)
override
;
44
};
Camera
Camera GameObject class Inherits from GameObject class and represents a camera in the scene....
Definition
camera.h:18
Component
Base class for all components that can be attached to GameObjects.
Definition
component.h:24
IRenderingStrategy
Interface for rendering strategies used by renderable components.
Definition
irendering_strategy.h:13
SdlTextStrategy
SDL implementation of the text rendering strategy.
Definition
sdl_text_strategy.h:22
SdlTextStrategy::~SdlTextStrategy
~SdlTextStrategy() override=default
SdlTextStrategy::SdlTextStrategy
SdlTextStrategy(SDL_Renderer &sdl_renderer)
SdlTextStrategy::draw
void draw(Component &component, Camera &camera) override
Text
UI Text Component.
Definition
text.h:32
Transform
Represents the position, rotation, and scale of a GameObject in 3D space. The Transform class encapsu...
Definition
transform.h:22
UIObject
Base class for all UI objects.
Definition
ui_object.h:16
component.h
irendering_strategy.h
text.h
ui_object.h
include
engine
core
rendering
strategies
sdl
sdl_text_strategy.h
Generated by
1.9.8