mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-01-31 18:56:42 +01:00
make screen rotation working on Android
libsuperderpy now requires Allegro 5.2.2 for Android
This commit is contained in:
parent
d65873d63b
commit
4d749b3ad1
5 changed files with 17 additions and 13 deletions
|
@ -10,7 +10,7 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="unspecified"
|
android:screenOrientation="unspecified"
|
||||||
android:configChanges="screenLayout|uiMode|orientation">
|
android:configChanges="screenLayout|uiMode|orientation|screenSize">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
|
||||||
SET(CMAKE_SYSTEM_NAME Linux)
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
SET(CMAKE_SYSTEM_VERSION 1)
|
SET(CMAKE_SYSTEM_VERSION 1)
|
||||||
|
|
||||||
#set path for android toolchain -- look
|
#set path for android toolchain -- look
|
||||||
|
|
||||||
set(ANDROID_ALLEGRO_ROOT "$ENV{ANDROID_ALLEGRO_ROOT}" CACHE PATH "Path to Allegro 5 source directory after being compiled for Android" )
|
set(ANDROID_ALLEGRO_ROOT "$ENV{ANDROID_ALLEGRO_ROOT}" CACHE PATH "Path to Allegro 5 (>=5.2.2) build directory for Android" )
|
||||||
|
|
||||||
message( STATUS "Selected Allegro dir: ${ANDROID_ALLEGRO_ROOT}" )
|
message( STATUS "Selected Allegro dir: ${ANDROID_ALLEGRO_ROOT}" )
|
||||||
if(NOT EXISTS ${ANDROID_ALLEGRO_ROOT})
|
if(NOT EXISTS "${ANDROID_ALLEGRO_ROOT}")
|
||||||
message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to directory with Allegro 5 source after compiling it for Android.")
|
message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to the build directory of Allegro 5 (>=5.2.2) for Android.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(ANDROID_NDK_TOOLCHAIN_ROOT "$ENV{ANDROID_NDK_TOOLCHAIN_ROOT}" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
|
set(ANDROID_NDK_TOOLCHAIN_ROOT "$ENV{ANDROID_NDK_TOOLCHAIN_ROOT}" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
|
||||||
|
|
|
@ -155,7 +155,7 @@ if(ANDROID)
|
||||||
file(RENAME "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/${LIBSUPERDERPY_GAMENAME}")
|
file(RENAME "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/${LIBSUPERDERPY_GAMENAME}")
|
||||||
|
|
||||||
file(COPY ${ALLEGRO5_LIBS} DESTINATION ${LIBRARY_OUTPUT_PATH})
|
file(COPY ${ALLEGRO5_LIBS} DESTINATION ${LIBRARY_OUTPUT_PATH})
|
||||||
file(COPY "${ANDROID_ALLEGRO_ROOT}/android/libs/${ARM_TARGETS}/Allegro5.jar" DESTINATION ${LIBRARY_OUTPUT_PATH})
|
file(COPY "${ANDROID_ALLEGRO_ROOT}/lib/Allegro5.jar" DESTINATION ${LIBRARY_OUTPUT_PATH})
|
||||||
|
|
||||||
file(COPY "${CMAKE_SOURCE_DIR}/data/" DESTINATION "${CMAKE_BINARY_DIR}/android/assets/")
|
file(COPY "${CMAKE_SOURCE_DIR}/data/" DESTINATION "${CMAKE_BINARY_DIR}/android/assets/")
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
||||||
al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_TRANSPARENT);
|
al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_TRANSPARENT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL );
|
al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); // TODO: make ALLEGRO_PROGRAMMABLE_PIPELINE game-optional
|
||||||
al_set_new_display_option(ALLEGRO_VSYNC, 2-atoi(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1")), ALLEGRO_SUGGEST);
|
al_set_new_display_option(ALLEGRO_VSYNC, 2-atoi(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1")), ALLEGRO_SUGGEST);
|
||||||
al_set_new_display_option(ALLEGRO_OPENGL, atoi(GetConfigOptionDefault(game, "SuperDerpy", "opengl", "1")), ALLEGRO_SUGGEST);
|
al_set_new_display_option(ALLEGRO_OPENGL, atoi(GetConfigOptionDefault(game, "SuperDerpy", "opengl", "1")), ALLEGRO_SUGGEST);
|
||||||
#ifdef ALLEGRO_WINDOWS
|
#ifdef ALLEGRO_WINDOWS
|
||||||
|
@ -399,18 +399,21 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
|
||||||
SetupViewport(game, game->viewport_config);
|
SetupViewport(game, game->viewport_config);
|
||||||
}
|
}
|
||||||
else if(ev.type == ALLEGRO_EVENT_DISPLAY_HALT_DRAWING) {
|
else if(ev.type == ALLEGRO_EVENT_DISPLAY_HALT_DRAWING) {
|
||||||
|
PrintConsole(game, "halt drawing");
|
||||||
game->_priv.draw = false;
|
game->_priv.draw = false;
|
||||||
al_stop_timer(game->_priv.timer);
|
al_stop_timer(game->_priv.timer);
|
||||||
al_detach_voice(game->audio.v);
|
al_detach_voice(game->audio.v);
|
||||||
|
PauseAllGamestates(game); // TODO: store not paused gamestates
|
||||||
al_acknowledge_drawing_halt(game->display);
|
al_acknowledge_drawing_halt(game->display);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING) {
|
else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING) {
|
||||||
al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
|
|
||||||
game->_priv.draw = true;
|
|
||||||
al_acknowledge_drawing_resume(game->display);
|
al_acknowledge_drawing_resume(game->display);
|
||||||
al_resume_timer(game->_priv.timer);
|
PrintConsole(game, "resume drawing");
|
||||||
|
game->_priv.draw = true;
|
||||||
SetupViewport(game, game->viewport_config);
|
SetupViewport(game, game->viewport_config);
|
||||||
|
ResumeAllGamestates(game); // FIXME: resumes even those that were paused earlier!
|
||||||
|
al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
|
||||||
|
al_resume_timer(game->_priv.timer);
|
||||||
}
|
}
|
||||||
else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
|
else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
|
||||||
al_acknowledge_resize(game->display);
|
al_acknowledge_resize(game->display);
|
||||||
|
@ -456,9 +459,8 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
|
||||||
al_save_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), al_get_backbuffer(game->display));
|
al_save_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), al_get_backbuffer(game->display));
|
||||||
PrintConsole(game, "Screenshot stored in %s", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
PrintConsole(game, "Screenshot stored in %s", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||||
al_destroy_path(path);
|
al_destroy_path(path);
|
||||||
} else {
|
|
||||||
EventGamestates(game, &ev);
|
|
||||||
}
|
}
|
||||||
|
EventGamestates(game, &ev);
|
||||||
}
|
}
|
||||||
ClearGarbage(game);
|
ClearGarbage(game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,12 +317,15 @@ SYMBOL_EXPORT char* GetDataFilePath(struct Game *game, char* filename) {
|
||||||
return AddGarbage(game, result);
|
return AddGarbage(game, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALLEGRO_DEBUG_CHANNEL("libsuperderpy")
|
||||||
|
|
||||||
SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
|
SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, format);
|
va_start(vl, format);
|
||||||
char text[1024] = {};
|
char text[1024] = {};
|
||||||
vsnprintf(text, 1024, format, vl);
|
vsnprintf(text, 1024, format, vl);
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
|
ALLEGRO_DEBUG(text);
|
||||||
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
||||||
if (!game->_priv.draw) return;
|
if (!game->_priv.draw) return;
|
||||||
if (!game->_priv.console) return;
|
if (!game->_priv.console) return;
|
||||||
|
|
Loading…
Reference in a new issue