Started working on figuring out how to properly support full screen and

high DPI
This commit is contained in:
abdelrahman committed 2022-09-25 23:31:53 +01:00
1 parent dbc8c88b89
commit ffaa6e5ae7
8 files changed
+53 -22

No files matched your search

+14 -4
View File
@@ -5,6 +5,7 @@
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_hints.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "SDL_pixels.h"
@@ -12,6 +13,7 @@
#include "SDL_surface.h"
#include "SDL_timer.h"
#include "SDL_ttf.h"
#include "SDL_video.h"
#include "Window.h"
#include "constants.h"
#include "engine_build_config.h"
@@ -35,11 +37,13 @@ INTERNAL struct game_engine {
AssetManager *asset_manager;
} GameEngine;
bool init_engine(const char *game_name, uint32_t window_width,
uint32_t window_height, SDL_Color window_background_color,
bool full_screen, uint8_t audio_tracks) {
bool init_engine(const char *game_name, WindowSize window_size,
SDL_Color window_background_color, bool full_screen,
uint8_t audio_tracks) {
bool initialisation_complete = true;
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
#ifdef DEBUG_ENGINE
printf("Failed to initialise SDL. Error: %s\n", SDL_GetError());
@@ -88,7 +92,7 @@ bool init_engine(const char *game_name, uint32_t window_width,
}
}
if (!init_window(&(GameEngine.window), game_name, window_width, window_height,
if (!init_window(&(GameEngine.window), game_name, window_size,
window_background_color, full_screen)) {
#ifdef DEBUG_ENGINE
printf("Failed to initialise window\n");
@@ -126,6 +130,12 @@ bool init_engine(const char *game_name, uint32_t window_width,
bool game_running() { return GameEngine.running; }
WindowSize get_window_defined_size() { return GameEngine.window.defined_size; }
WindowSize get_window_drawable_size() {
return GameEngine.window.drawable_size;
}
ObjectID add_object(void *object, EventHandlerPtr event_handler,
UpdateFuncPtr update_func, RenderFuncPtr render_func) {
if (!(GameEngine.running) || !(GameEngine.object_store)) {