platform: improve draw

isolation_bkp/dynres
Dominik Madarász 2021-08-11 14:59:29 +02:00
parent c1ab9a2faf
commit ac7030bf2b
2 changed files with 20 additions and 24 deletions

View File

@ -16,11 +16,8 @@
static uint16_t screenWidth = 1600; static uint16_t screenWidth = 1600;
static uint16_t screenHeight = 900; static uint16_t screenHeight = 900;
static float target_zoom = 1.5f; static float target_zoom = 1.5f;
static float zoom_overlay_tran = 0.0f;
static bool request_shutdown; static bool request_shutdown;
#define CAM_OVERLAY_ZOOM_LEVEL 0.80f
#include "renderer_v0.c" #include "renderer_v0.c"
void platform_init() { void platform_init() {
@ -95,7 +92,14 @@ void platform_render() {
game_world_view_active_entity_map(do_entity_fadeinout); game_world_view_active_entity_map(do_entity_fadeinout);
} }
renderer_draw(); BeginDrawing();
{
profile (PROF_RENDER) {
renderer_draw();
}
debug_draw();
}
EndDrawing();
if (request_shutdown) { if (request_shutdown) {
CloseWindow(); CloseWindow();

View File

@ -1,4 +1,8 @@
static Camera2D render_camera; static Camera2D render_camera;
static float zoom_overlay_tran = 0.0f;
#define CAM_OVERLAY_ZOOM_LEVEL 0.80f
float zpl_lerp(float,float,float); float zpl_lerp(float,float,float);
float zpl_to_degrees(float); float zpl_to_degrees(float);
@ -54,25 +58,17 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
case EKIND_DEMO_NPC: { case EKIND_DEMO_NPC: {
float x = data->x; float x = data->x;
float y = data->y; float y = data->y;
#if 0
const char *title = TextFormat("Thing %d", key);
int title_w = MeasureTextEco(title, font_size, font_spacing);
DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time));
DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing);
#endif
DrawCircleEco(x, y, size, ColorAlpha(BLUE, data->tran_time)); DrawCircleEco(x, y, size, ColorAlpha(BLUE, data->tran_time));
}break; }break;
case EKIND_PLAYER: { case EKIND_PLAYER: {
float x = data->x; float x = data->x;
float y = data->y; float y = data->y;
float health = (data->hp / data->max_hp); float health = (data->hp / data->max_hp);
#if 1
const char *title = TextFormat("Player %d", key); const char *title = TextFormat("Player %d", key);
int title_w = MeasureTextEco(title, font_size, font_spacing); int title_w = MeasureTextEco(title, font_size, font_spacing);
DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time)); DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time));
DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-fixed_title_offset, title_w*health+title_bg_offset, font_size*0.2f, ColorAlpha(RED, data->tran_time)); DrawRectangleEco(x-title_w/2-title_bg_offset/2, y-size-fixed_title_offset, title_w*health+title_bg_offset, font_size*0.2f, ColorAlpha(RED, data->tran_time));
DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing); DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing);
#endif
DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time)); DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time));
}break; }break;
case EKIND_MACRO_BOT: { case EKIND_MACRO_BOT: {
@ -111,18 +107,14 @@ void renderer_draw(void) {
render_camera.target = (Vector2){game_camera.x, game_camera.y}; render_camera.target = (Vector2){game_camera.x, game_camera.y};
zoom_overlay_tran = zpl_lerp(zoom_overlay_tran, (target_zoom <= CAM_OVERLAY_ZOOM_LEVEL) ? 1.0f : 0.0f, GetFrameTime()*2.0f); zoom_overlay_tran = zpl_lerp(zoom_overlay_tran, (target_zoom <= CAM_OVERLAY_ZOOM_LEVEL) ? 1.0f : 0.0f, GetFrameTime()*2.0f);
BeginDrawing();
profile (PROF_RENDER) { ClearBackground(GetColor(0x222034));
ClearBackground(GetColor(0x222034)); BeginMode2D(render_camera);
BeginMode2D(render_camera); game_world_view_active_entity_map(DEBUG_draw_ground);
game_world_view_active_entity_map(DEBUG_draw_ground); game_world_view_active_entity_map(DEBUG_draw_entities_low);
game_world_view_active_entity_map(DEBUG_draw_entities_low); game_world_view_active_entity_map(DEBUG_draw_entities);
game_world_view_active_entity_map(DEBUG_draw_entities); EndMode2D();
EndMode2D(); display_conn_status();
display_conn_status();
}
debug_draw();
EndDrawing();
} }
void renderer_init(void) { void renderer_init(void) {