eliminate integer based rendering

isolation_bkp/dynres
Dominik Madarász 2022-09-13 13:52:42 +00:00 committed by GitHub
parent 378d42a0aa
commit 04621adcd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 17 deletions

View File

@ -47,11 +47,11 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) {
extern bool inv_is_open;
void DEBUG_draw_entities(uint64_t key, entity_view * data) {
uint16_t size = 16;
uint16_t font_size = (uint16_t)lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom);
float size = 16.f;
float font_size = lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom);
float font_spacing = 1.1f;
float title_bg_offset = 4;
float fixed_title_offset = 8;
float fixed_title_offset = 8.f;
switch (data->kind) {
case EKIND_DEMO_NPC: {
@ -64,10 +64,10 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
float y = data->y;
float health = (data->hp / data->max_hp);
const char *title = TextFormat("Player %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));
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);
float title_w = MeasureTextEco(title, font_size, font_spacing);
DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(BLACK, data->tran_time));
DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, 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.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing);
DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time));
if (data->has_items && !data->inside_vehicle) {
@ -88,8 +88,8 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
float y = data->y;
const char *title = TextFormat("Bot %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(GRAY, data->tran_time));
DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing);
DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(GRAY, data->tran_time));
DrawTextEco(title, x-title_w/2.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing);
DrawCircleEco(x, y, size, ColorAlpha(PURPLE, data->tran_time));
}break;
case EKIND_ITEM: {

View File

@ -79,36 +79,36 @@ void DrawTextExEco(Font font, const char *text, Vector2 position, float fontSize
}
static inline
void DrawTextEco(const char *text, float posX, float posY, int fontSize, Color color, float spacing) {
void DrawTextEco(const char *text, float posX, float posY, float fontSize, Color color, float spacing) {
#if 1
// Check if default font has been loaded
if (GetFontDefault().texture.id != 0) {
Vector2 position = { posX , posY };
float defaultFontSize = 10.0; // Default Font chars height in pixel
float new_spacing = spacing == 0.0f ? fontSize/(float)defaultFontSize : spacing;
float new_spacing = spacing == 0.0f ? fontSize/defaultFontSize : spacing;
DrawTextExEco(GetFontDefault(), text, position, (float)fontSize , (float)new_spacing , color);
DrawTextExEco(GetFontDefault(), text, position, fontSize , new_spacing , color);
}
#endif
}
static inline
int MeasureTextEco(const char *text, int fontSize, float spacing) {
float MeasureTextEco(const char *text, float fontSize, float spacing) {
#if 1
Vector2 vec = { 0.0f, 0.0f };
// Check if default font has been loaded
if (GetFontDefault().texture.id != 0) {
float defaultFontSize = 10.0; // Default Font chars height in pixel
float new_spacing = spacing == 0.0f ? (float)fontSize/defaultFontSize : spacing;
float new_spacing = spacing == 0.0f ? fontSize/defaultFontSize : spacing;
vec = MeasureTextEx(GetFontDefault(), text, (float)fontSize, (float)new_spacing);
vec = MeasureTextEx(GetFontDefault(), text, fontSize, (float)new_spacing);
}
return (int)vec.x;
return vec.x;
#else
return 0;
return 0.f;
#endif
}