ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
8
9#ifndef ASW_UTIL_H
10#define ASW_UTIL_H
11
12#include <algorithm>
13#include <string>
14
15#include "./geometry.h"
16#include "./types.h"
17
18namespace asw::util {
19
24[[noreturn]]
25void abort_on_error(const std::string& message);
26
33
40asw::Vec2<int> get_text_size(const asw::Font& font, const std::string& text);
41
49template <typename T> T lerp(const T& a, const T& b, float t)
50{
51 t = std::clamp(t, 0.0F, 1.0F);
52 return a + (b - a) * t;
53}
54
55} // namespace asw::util
56
57#endif // ASW_UTIL_H
A 2D vector in space.
Definition geometry.h:21
Common geometry types.
asw::Vec2< float > get_texture_size(const asw::Texture &tex)
Get texture size.
Definition util.cpp:15
T lerp(const T &a, const T &b, float t)
Lerp between two values.
Definition util.h:49
asw::Vec2< int > get_text_size(const asw::Font &font, const std::string &text)
Get text size.
Definition util.cpp:22
void abort_on_error(const std::string &message)
Abort program and display error message.
Definition util.cpp:8
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:41
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:38
Types used throughout the ASW library.