mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
don't create and destroy bitmap on every PrintConsole call
This commit is contained in:
parent
2dfc565178
commit
1afc4a3f31
4 changed files with 6 additions and 6 deletions
|
@ -108,8 +108,6 @@ SYMBOL_INTERNAL void DrawConsole(struct Game *game) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL_INTERNAL void Console_Load(struct Game *game) {
|
SYMBOL_INTERNAL void Console_Load(struct Game *game) {
|
||||||
game->_priv.font_console = NULL;
|
|
||||||
game->_priv.console = NULL;
|
|
||||||
game->_priv.font_console = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),al_get_display_height(game->display)*0.025,0 );
|
game->_priv.font_console = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),al_get_display_height(game->display)*0.025,0 );
|
||||||
if (al_get_display_height(game->display)*0.025 >= 16) {
|
if (al_get_display_height(game->display)*0.025 >= 16) {
|
||||||
game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/PerfectDOSVGA437.ttf"),16 * ((al_get_display_height(game->display) > 1080) ? 2 : 1) ,0 );
|
game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/PerfectDOSVGA437.ttf"),16 * ((al_get_display_height(game->display) > 1080) ? 2 : 1) ,0 );
|
||||||
|
@ -117,6 +115,7 @@ SYMBOL_INTERNAL void Console_Load(struct Game *game) {
|
||||||
game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"), al_get_display_height(game->display)*0.025,0 );
|
game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"), al_get_display_height(game->display)*0.025,0 );
|
||||||
}
|
}
|
||||||
game->_priv.console = al_create_bitmap((al_get_display_width(game->display) / 320) * 320, al_get_font_line_height(game->_priv.font_console)*5);
|
game->_priv.console = al_create_bitmap((al_get_display_width(game->display) / 320) * 320, al_get_font_line_height(game->_priv.font_console)*5);
|
||||||
|
game->_priv.console_tmp = al_create_bitmap((al_get_display_width(game->display) / 320) * 320, al_get_font_line_height(game->_priv.font_console)*5);
|
||||||
al_set_target_bitmap(game->_priv.console);
|
al_set_target_bitmap(game->_priv.console);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,80));
|
al_clear_to_color(al_map_rgba(0,0,0,80));
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
@ -125,6 +124,7 @@ SYMBOL_INTERNAL void Console_Load(struct Game *game) {
|
||||||
SYMBOL_INTERNAL void Console_Unload(struct Game *game) {
|
SYMBOL_INTERNAL void Console_Unload(struct Game *game) {
|
||||||
al_destroy_font(game->_priv.font_console);
|
al_destroy_font(game->_priv.font_console);
|
||||||
al_destroy_bitmap(game->_priv.console);
|
al_destroy_bitmap(game->_priv.console);
|
||||||
|
al_destroy_bitmap(game->_priv.console_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL_INTERNAL void GamestateProgress(struct Game *game) {
|
SYMBOL_INTERNAL void GamestateProgress(struct Game *game) {
|
||||||
|
|
|
@ -65,6 +65,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
||||||
|
|
||||||
game->_priv.font_bsod = NULL;
|
game->_priv.font_bsod = NULL;
|
||||||
game->_priv.console = NULL;
|
game->_priv.console = NULL;
|
||||||
|
game->_priv.console_tmp = NULL;
|
||||||
|
|
||||||
game->_priv.garbage = NULL;
|
game->_priv.garbage = NULL;
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ struct Game {
|
||||||
ALLEGRO_FONT *font_console; /*!< Font used in game console. */
|
ALLEGRO_FONT *font_console; /*!< Font used in game console. */
|
||||||
ALLEGRO_FONT *font_bsod; /*!< Font used in Blue Screens of Derp. */
|
ALLEGRO_FONT *font_bsod; /*!< Font used in Blue Screens of Derp. */
|
||||||
ALLEGRO_BITMAP *console; /*!< Bitmap with game console. */
|
ALLEGRO_BITMAP *console; /*!< Bitmap with game console. */
|
||||||
|
ALLEGRO_BITMAP *console_tmp; /*!< Bitmap used for drawing game console. */
|
||||||
ALLEGRO_EVENT_QUEUE *event_queue; /*!< Main event queue. */
|
ALLEGRO_EVENT_QUEUE *event_queue; /*!< Main event queue. */
|
||||||
ALLEGRO_TIMER *timer; /*!< Main LPS (logic) timer. */
|
ALLEGRO_TIMER *timer; /*!< Main LPS (logic) timer. */
|
||||||
bool showconsole; /*!< If true, game console is rendered on screen. */
|
bool showconsole; /*!< If true, game console is rendered on screen. */
|
||||||
|
|
|
@ -266,16 +266,14 @@ SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
|
||||||
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
||||||
if (!game->_priv.console) return;
|
if (!game->_priv.console) return;
|
||||||
if ((!game->config.debug) && (!game->_priv.showconsole)) return;
|
if ((!game->config.debug) && (!game->_priv.showconsole)) return;
|
||||||
ALLEGRO_BITMAP *con = al_create_bitmap(al_get_bitmap_width(game->_priv.console), al_get_bitmap_height(game->_priv.console));
|
al_set_target_bitmap(game->_priv.console_tmp);
|
||||||
al_set_target_bitmap(con);
|
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,80));
|
al_clear_to_color(al_map_rgba(0,0,0,80));
|
||||||
al_draw_bitmap_region(game->_priv.console, 0, (int)(al_get_bitmap_height(game->_priv.console)*0.2), al_get_bitmap_width(game->_priv.console), (int)(al_get_bitmap_height(game->_priv.console)*0.8), 0, 0, 0);
|
al_draw_bitmap_region(game->_priv.console, 0, (int)(al_get_bitmap_height(game->_priv.console)*0.2), al_get_bitmap_width(game->_priv.console), (int)(al_get_bitmap_height(game->_priv.console)*0.8), 0, 0, 0);
|
||||||
al_draw_text(game->_priv.font_console, al_map_rgb(255,255,255), (int)(game->viewport.width*0.005), (int)(al_get_bitmap_height(game->_priv.console)*0.81), ALLEGRO_ALIGN_LEFT, text);
|
al_draw_text(game->_priv.font_console, al_map_rgb(255,255,255), (int)(game->viewport.width*0.005), (int)(al_get_bitmap_height(game->_priv.console)*0.81), ALLEGRO_ALIGN_LEFT, text);
|
||||||
al_set_target_bitmap(game->_priv.console);
|
al_set_target_bitmap(game->_priv.console);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
al_draw_bitmap(con, 0, 0, 0);
|
al_draw_bitmap(game->_priv.console_tmp, 0, 0, 0);
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
al_destroy_bitmap(con);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL_EXPORT void SetupViewport(struct Game *game) {
|
SYMBOL_EXPORT void SetupViewport(struct Game *game) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue