4#include <SDL3_mixer/SDL_mixer.h>
5#include <SDL3_ttf/SDL_ttf.h>
27 while (SDL_PollEvent(&e)) {
29 case SDL_EVENT_WINDOW_RESIZED: {
36 SDL_Point window_size;
37 SDL_GetRenderOutputSize(r, &window_size.x, &window_size.y);
39 SDL_Point render_size;
40 SDL_GetRenderLogicalPresentation(r, &render_size.x, &render_size.y,
nullptr);
43 =
static_cast<float>(window_size.x) /
static_cast<float>(render_size.x);
46 =
static_cast<float>(window_size.y) /
static_cast<float>(render_size.y);
48 const auto scale = std::min(x_scale, y_scale);
51 static_cast<int>(
static_cast<float>(render_size.x) * scale),
52 static_cast<int>(
static_cast<float>(render_size.y) * scale));
56 case SDL_EVENT_KEY_DOWN: {
63 case SDL_EVENT_KEY_UP: {
70 case SDL_EVENT_MOUSE_BUTTON_DOWN: {
75 case SDL_EVENT_MOUSE_BUTTON_UP: {
80 case SDL_EVENT_MOUSE_MOTION: {
84 SDL_ConvertEventToRenderCoordinates(r, &e);
91 case SDL_EVENT_MOUSE_WHEEL: {
96 case SDL_EVENT_GAMEPAD_AXIS_MOTION: {
101 case SDL_EVENT_GAMEPAD_BUTTON_DOWN: {
106 case SDL_EVENT_GAMEPAD_BUTTON_UP: {
111 case SDL_EVENT_GAMEPAD_ADDED: {
116 case SDL_EVENT_GAMEPAD_REMOVED: {
121 case SDL_EVENT_TEXT_INPUT: {
126 case SDL_EVENT_QUIT: {
138 if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
155 if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
168 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
169 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
170 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
171 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
181 const char* renderer_name =
"none";
183 renderer_name = SDL_GetRendererName(r);
187 "SDL Version: {}.{}.{}", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
Action binding system for the ASW library.
Asset routines for the ASW library.
Core routines including main loop and initialization.
Display and window routines for the ASW library.
Structured logging system.
void clear_all()
Clear all cached assets. This will remove all cached textures, fonts, samples, and music.
void exit()
Exit the application. Sets exiting flag to true, which will cause the main loop to exit on the next u...
void print_info()
Prints information about the core module.
void init_opengl(int width, int height, int scale=1)
Initializes the core module for opengl.
void shutdown()
Cleanup resources used by the core module. Should be called on application exit.
void init(int width, int height, int scale=1)
Initializes the core module.
void update()
Updates core module functionality.
bool is_exiting()
Return exiting status.
void _init_opengl(int width, int height, int scale)
Initialize the display module with OpenGL support. Called by asw::core::init().
void _shutdown()
Shut down the display module. Called by asw::core::shutdown(). Nulls the renderer and window pointers...
asw::Renderer * get_renderer()
Get the SDL renderer.
asw::Window * get_window()
Get the SDL window.
void _init(int width, int height, int scale)
Initialize the display module. Called by asw::core::init().
void info(const std::string &message)
Log an info message.
void _shutdown()
Shut down the sound module. Called automatically by asw::core::shutdown().
bool _init()
Initialize the sound module. Called automatically by asw::core::init().
void abort_on_error(const std::string &message)
Abort program and display error message.
Sound module for the ASW library.
General utility functions.