Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
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>
9
10#include <map>
11#include <memory>
12#include <string>
13
22class 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 GameObject class Inherits from GameObject class and represents a camera in the scene....
Definition camera.h:18
Base class for all components that can be attached to GameObjects.
Definition component.h:24
Interface for rendering strategies used by renderable components.
Definition irendering_strategy.h:13
SDL implementation of the text rendering strategy.
Definition sdl_text_strategy.h:22
~SdlTextStrategy() override=default
SdlTextStrategy(SDL_Renderer &sdl_renderer)
void draw(Component &component, Camera &camera) override
UI Text Component.
Definition text.h:32
Represents the position, rotation, and scale of a GameObject in 3D space. The Transform class encapsu...
Definition transform.h:22
Base class for all UI objects.
Definition ui_object.h:16