mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
fix blinking borders outside clipping rectangle
This commit is contained in:
parent
c3fb2e06f1
commit
51590d9788
5 changed files with 22 additions and 11 deletions
|
@ -144,7 +144,7 @@ if(ANDROID)
|
|||
configure_android_file("project.properties" @ONLY)
|
||||
configure_android_file("res/values/strings.xml")
|
||||
configure_android_file("jni/localgen.mk")
|
||||
if (ALLEGRO5_LIBRARIES MATCHES "^.*-debug$")
|
||||
if (ALLEGRO5_LIBRARIES MATCHES "^.*-debug.*$")
|
||||
configure_file("${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.debug.in" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java")
|
||||
else()
|
||||
configure_file("${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.in" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java")
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "libsuperderpy.h"
|
||||
|
||||
SYMBOL_INTERNAL void DrawGamestates(struct Game *game) {
|
||||
ClearScreen(game);
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if ((tmp->loaded) && (tmp->started)) {
|
||||
|
@ -175,3 +175,16 @@ SYMBOL_INTERNAL void ClearGarbage(struct Game *game) {
|
|||
game->_priv.garbage = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL void ClearScreen(struct Game *game) {
|
||||
ALLEGRO_TRANSFORM identity;
|
||||
int clipX, clipY, clipWidth, clipHeight;
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_get_clipping_rectangle(&clipX, &clipY, &clipWidth, &clipHeight);
|
||||
al_set_clipping_rectangle(0, 0, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_identity_transform(&identity);
|
||||
al_use_transform(&identity);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_use_transform(&game->projection);
|
||||
al_set_clipping_rectangle(clipX, clipY, clipWidth, clipHeight);
|
||||
}
|
||||
|
|
|
@ -52,5 +52,6 @@ void Console_Unload(struct Game *game);
|
|||
void GamestateProgress(struct Game *game);
|
||||
void* AddGarbage(struct Game *game, void* data);
|
||||
void ClearGarbage(struct Game *game);
|
||||
void ClearScreen(struct Game *game);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -255,9 +255,8 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
|
|||
|
||||
while(1) {
|
||||
// TODO: split mainloop to functions to make it readable
|
||||
|
||||
ALLEGRO_EVENT ev;
|
||||
if ((game->_priv.draw && redraw && al_is_event_queue_empty(game->_priv.event_queue)) || (game->_priv.gamestate_scheduled)) {
|
||||
if (game->_priv.draw && ((redraw && al_is_event_queue_empty(game->_priv.event_queue)) || (game->_priv.gamestate_scheduled))) {
|
||||
|
||||
game->_priv.gamestate_scheduled = false;
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
|
@ -398,15 +397,16 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
|
|||
SetupViewport(game, game->viewport_config);
|
||||
}
|
||||
else if(ev.type == ALLEGRO_EVENT_DISPLAY_HALT_DRAWING) {
|
||||
al_stop_timer(game->_priv.timer);
|
||||
game->_priv.draw = false;
|
||||
al_stop_timer(game->_priv.timer);
|
||||
al_detach_voice(game->audio.v);
|
||||
al_acknowledge_drawing_halt(game->display);
|
||||
continue;
|
||||
}
|
||||
else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING) {
|
||||
al_acknowledge_drawing_resume(game->display);
|
||||
al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
|
||||
game->_priv.draw = true;
|
||||
al_acknowledge_drawing_resume(game->display);
|
||||
al_resume_timer(game->_priv.timer);
|
||||
SetupViewport(game, game->viewport_config);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game *game) {
|
|||
tmp=pom;
|
||||
}
|
||||
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
ClearScreen(game);
|
||||
PrintConsole(game, "Shutting down...");
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
|
|
|
@ -324,6 +324,7 @@ SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
|
|||
vsnprintf(text, 1024, format, vl);
|
||||
va_end(vl);
|
||||
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
||||
if (!game->_priv.draw) return;
|
||||
if (!game->_priv.console) return;
|
||||
if ((!game->config.debug) && (!game->_priv.showconsole)) return;
|
||||
al_set_target_bitmap(game->_priv.console_tmp);
|
||||
|
@ -354,10 +355,6 @@ SYMBOL_EXPORT void SetupViewport(struct Game *game, struct Viewport config) {
|
|||
al_use_transform(&game->projection);
|
||||
al_set_clipping_rectangle(0, 0, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_flip_display();
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
|
||||
float resolution = al_get_display_width(game->display) / (float)game->viewport.width;
|
||||
if (al_get_display_height(game->display) / game->viewport.height < resolution) resolution = al_get_display_height(game->display) / (float)game->viewport.height;
|
||||
if (game->viewport.integer_scaling) {
|
||||
|
|
Loading…
Reference in a new issue