Added support for rendering on Android devices

This commit is contained in:
abdelrahman committed 2022-10-02 20:24:00 +01:00
1 parent e110b1f2fd
commit 2eb8d83dc0
8 files changed
+122 -14

No files matched your search

+15 -3
View File
@@ -9,6 +9,7 @@
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "SDL_pixels.h"
#include "SDL_platform.h"
#include "SDL_render.h"
#include "SDL_surface.h"
#include "SDL_timer.h"
@@ -18,11 +19,11 @@
#include "constants.h"
#include "engine_build_config.h"
#include "reusable_ids.h"
#include <SDL2/SDL_pixels.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#ifdef DEBUG_ENGINE
#include <stdio.h>
@@ -42,8 +43,11 @@ 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;
const char *current_platform = SDL_GetPlatform();
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
if (strcmp(current_platform, "Linux") == 0) {
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
}
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
#ifdef DEBUG_ENGINE
@@ -53,7 +57,15 @@ bool init_engine(const char *game_name, WindowSize window_size,
return false;
}
uint32_t img_flags = IMG_INIT_PNG | IMG_INIT_TIF;
uint32_t img_flags = IMG_INIT_PNG;
if (strcmp(current_platform, "Android") != 0) {
// Apparently, Android devices don't support TIFF images, so we only enable
// TIFF support when we are not running Android.
//
// TODO (Abdelrahman): Check if iOS devices support TIFF images.
img_flags |= IMG_INIT_TIF;
}
if ((IMG_Init(img_flags) & img_flags) != img_flags) {
#ifdef DEBUG_ENGINE
printf("Failed to initialise SDL_image. Error: %s\n", IMG_GetError());