eliminate integer based rendering
parent
378d42a0aa
commit
04621adcd3
|
@ -47,11 +47,11 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) {
|
||||||
extern bool inv_is_open;
|
extern bool inv_is_open;
|
||||||
|
|
||||||
void DEBUG_draw_entities(uint64_t key, entity_view * data) {
|
void DEBUG_draw_entities(uint64_t key, entity_view * data) {
|
||||||
uint16_t size = 16;
|
float size = 16.f;
|
||||||
uint16_t font_size = (uint16_t)lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom);
|
float font_size = lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom);
|
||||||
float font_spacing = 1.1f;
|
float font_spacing = 1.1f;
|
||||||
float title_bg_offset = 4;
|
float title_bg_offset = 4;
|
||||||
float fixed_title_offset = 8;
|
float fixed_title_offset = 8.f;
|
||||||
|
|
||||||
switch (data->kind) {
|
switch (data->kind) {
|
||||||
case EKIND_DEMO_NPC: {
|
case EKIND_DEMO_NPC: {
|
||||||
|
@ -64,10 +64,10 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
|
||||||
float y = data->y;
|
float y = data->y;
|
||||||
float health = (data->hp / data->max_hp);
|
float health = (data->hp / data->max_hp);
|
||||||
const char *title = TextFormat("Player %d", key);
|
const char *title = TextFormat("Player %d", key);
|
||||||
int title_w = MeasureTextEco(title, font_size, font_spacing);
|
float 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.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-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.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, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing);
|
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));
|
DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time));
|
||||||
|
|
||||||
if (data->has_items && !data->inside_vehicle) {
|
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;
|
float y = data->y;
|
||||||
const char *title = TextFormat("Bot %d", key);
|
const char *title = TextFormat("Bot %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(GRAY, data->tran_time));
|
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, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing);
|
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));
|
DrawCircleEco(x, y, size, ColorAlpha(PURPLE, data->tran_time));
|
||||||
}break;
|
}break;
|
||||||
case EKIND_ITEM: {
|
case EKIND_ITEM: {
|
||||||
|
|
|
@ -79,36 +79,36 @@ void DrawTextExEco(Font font, const char *text, Vector2 position, float fontSize
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
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
|
#if 1
|
||||||
// Check if default font has been loaded
|
// Check if default font has been loaded
|
||||||
if (GetFontDefault().texture.id != 0) {
|
if (GetFontDefault().texture.id != 0) {
|
||||||
Vector2 position = { posX , posY };
|
Vector2 position = { posX , posY };
|
||||||
|
|
||||||
float defaultFontSize = 10.0; // Default Font chars height in pixel
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
int MeasureTextEco(const char *text, int fontSize, float spacing) {
|
float MeasureTextEco(const char *text, float fontSize, float spacing) {
|
||||||
#if 1
|
#if 1
|
||||||
Vector2 vec = { 0.0f, 0.0f };
|
Vector2 vec = { 0.0f, 0.0f };
|
||||||
|
|
||||||
// Check if default font has been loaded
|
// Check if default font has been loaded
|
||||||
if (GetFontDefault().texture.id != 0) {
|
if (GetFontDefault().texture.id != 0) {
|
||||||
float defaultFontSize = 10.0; // Default Font chars height in pixel
|
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
|
#else
|
||||||
return 0;
|
return 0.f;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue