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 void abortOnError(const std::string& message);
25
32
39 asw::Vec2<int> getTextSize(const asw::Font& font, const std::string& text);
40
48 template <typename T>
49 T lerp(const T& a, const T& b, float t) {
50 t = std::clamp(t, 0.0F, 1.0F);
51
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:22
Common geometry types.
asw::Vec2< float > getTextureSize(const asw::Texture &tex)
Get texture size.
Definition util.cpp:15
asw::Vec2< int > getTextSize(const asw::Font &font, const std::string &text)
Get text size.
Definition util.cpp:21
void abortOnError(const std::string &message)
Abort program and display error message.
Definition util.cpp:8
T lerp(const T &a, const T &b, float t)
Lerp between two values.
Definition util.h:49
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:34
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:31
Types used throughout the ASW library.