Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
engine_structs.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "imports.h"
4 #include <freetype/freetype.h>
5 #include <freetype/ftstroke.h>
6 
7 
8 // Core struct (engine stuff) - 0.0.1
9 
10 
11 
12 typedef struct Texture {
13  unsigned int id = 0;
14  int width = 0;
15  int height = 0;
16 
17 
18  Texture() = default;
20 
21 // Windows API conflict
22 namespace ember {
23 
24  struct Rectangle {
25  int x;
26  int y;
27  int width;
28  int height;
29  };
30 
31 }; // namespace ember
32 
33 
34 struct Color {
35  unsigned char r;
36  unsigned char g;
37  unsigned char b;
38  unsigned char a;
39 
40  glm::vec4 GetNormalizedColor() const;
41 
42  bool operator==(const Color& other) const;
43 };
44 
45 
46 struct Glyph {
47  float x0, y0, x1, y1;
48  int w, h;
50  int advance;
51 };
52 
53 
54 struct Font {
55  std::map<char, Glyph> glyphs{};
57  int font_size;
58  float kerning = 0.0f;
60  float scale;
61 
62  bool IsValid() const;
63 
64  Font() = default;
65 
66 };
67 
68 std::tuple<int,int> CalcTextSize(const std::string& text, const Font& font, float font_size = 0.0f);
struct Texture Texture
std::tuple< int, int > CalcTextSize(const std::string &text, const Font &font, float font_size=0.0f)
Definition: engine_structs.cpp:23
struct Texture Texture2D
Definition: engine_structs.h:22
Definition: engine_structs.h:34
glm::vec4 GetNormalizedColor() const
Definition: engine_structs.cpp:8
unsigned char a
Definition: engine_structs.h:38
unsigned char b
Definition: engine_structs.h:37
unsigned char r
Definition: engine_structs.h:35
unsigned char g
Definition: engine_structs.h:36
bool operator==(const Color &other) const
Definition: engine_structs.cpp:19
Definition: engine_structs.h:54
int descent
Definition: engine_structs.h:59
float scale
Definition: engine_structs.h:60
float kerning
Definition: engine_structs.h:58
int line_gap
Definition: engine_structs.h:59
std::map< char, Glyph > glyphs
Definition: engine_structs.h:55
Font()=default
Texture texture
Definition: engine_structs.h:56
int font_size
Definition: engine_structs.h:57
bool IsValid() const
Definition: engine_structs.cpp:4
int ascent
Definition: engine_structs.h:59
Definition: engine_structs.h:46
float x0
Definition: engine_structs.h:47
float y0
Definition: engine_structs.h:47
float y1
Definition: engine_structs.h:47
int x_offset
Definition: engine_structs.h:49
int y_offset
Definition: engine_structs.h:49
int h
Definition: engine_structs.h:48
float x1
Definition: engine_structs.h:47
int w
Definition: engine_structs.h:48
int advance
Definition: engine_structs.h:50
Definition: engine_structs.h:12
int width
Definition: engine_structs.h:14
Texture()=default
int height
Definition: engine_structs.h:15
Definition: engine_structs.h:24
int height
Definition: engine_structs.h:28
int width
Definition: engine_structs.h:27
int y
Definition: engine_structs.h:26
int x
Definition: engine_structs.h:25