Remove template code from TELY
This commit is contained in:
parent
59aaf5d093
commit
e3838227a2
560
feely_pona.cpp
560
feely_pona.cpp
@ -177,203 +177,7 @@ void TELY_DLL_Init(void *user_data)
|
||||
first_entity->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
}
|
||||
|
||||
// NOTE: Freya's Game Dev Math Lecture 01
|
||||
TELY_FreyaGameMath *freya_gm = &game->freya_game_math;
|
||||
{
|
||||
TELY_GameEntity *group_box = TELY_Game_MakeEntityPointerF(game, "Lecture 01 Group Box");
|
||||
TELY_Game_PushParentEntity(game, group_box->handle);
|
||||
DQN_DEFER { TELY_Game_PopParentEntity(game); };
|
||||
{
|
||||
group_box->local_pos = Dqn_V2_InitNx2(70, 609);
|
||||
group_box->flags |= TELY_EntityFlag_DrawHitBox;
|
||||
group_box->flags |= TELY_EntityFlag_DeriveHitBoxFromChildrenBoundingBox;
|
||||
group_box->flags |= TELY_EntityFlag_Clickable;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_group_box = group_box->handle;
|
||||
}
|
||||
|
||||
TELY_GameEntity *coordinate_axis = TELY_Game_MakeEntityPointerF(game, "Coordinate Axis");
|
||||
DQN_ASSERT(coordinate_axis->parent == group_box);
|
||||
{
|
||||
coordinate_axis->local_hit_box_size = Dqn_V2_InitNx1(24);
|
||||
coordinate_axis->flags |= TELY_EntityFlag_Clickable;
|
||||
coordinate_axis->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
coordinate_axis->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
|
||||
Dqn_f32 const axis_length = platform->core.window_size.y * 0.25f;
|
||||
|
||||
TELY_GameShape *axis_y = Dqn_FArray_Make(&coordinate_axis->shapes, Dqn_ZeroMem_Yes);
|
||||
axis_y->type = TELY_GameShapeType_Line;
|
||||
axis_y->p2 = Dqn_V2_InitNx2(0, -axis_length);
|
||||
axis_y->line_thickness = 2.f;
|
||||
axis_y->colour = TELY_COLOUR_RED_TOMATO_V4;
|
||||
|
||||
TELY_GameShape *axis_x = Dqn_FArray_Make(&coordinate_axis->shapes, Dqn_ZeroMem_Yes);
|
||||
axis_x->type = TELY_GameShapeType_Line;
|
||||
axis_x->p2 = Dqn_V2_InitNx2(axis_length, 0);
|
||||
axis_x->line_thickness = 2.f;
|
||||
axis_x->colour = TELY_COLOUR_GREEN_DARK_KHAKI_V4;
|
||||
|
||||
freya_gm->lec01_axis = coordinate_axis->handle;
|
||||
}
|
||||
|
||||
// =========================================================================================
|
||||
Dqn_f32 const point_radius = 8.f;
|
||||
Dqn_f32 const point_diameter = point_radius * 2.f;
|
||||
|
||||
TELY_GameEntity *point_a = TELY_Game_MakeEntityPointerF(game, "A");
|
||||
{
|
||||
point_a->local_pos = Dqn_V2_InitNx2(400, -100);
|
||||
point_a->local_hit_box_size = Dqn_V2_InitNx1(point_diameter);
|
||||
point_a->flags |= TELY_EntityFlag_Clickable;
|
||||
point_a->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
point_a->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
point_a->parent = coordinate_axis;
|
||||
|
||||
TELY_GameShape *circle = Dqn_FArray_Make(&point_a->shapes, Dqn_ZeroMem_Yes);
|
||||
circle->type = TELY_GameShapeType_Circle;
|
||||
circle->circle_radius = point_radius;
|
||||
circle->colour = TELY_COLOUR_RED_PALE_VIOLET_V4;
|
||||
freya_gm->lec01_point_a = point_a->handle;
|
||||
}
|
||||
|
||||
TELY_GameEntity *point_b = TELY_Game_MakeEntityPointerF(game, "B");
|
||||
{
|
||||
point_b->local_pos = Dqn_V2_InitNx2(300, -300);
|
||||
point_b->local_hit_box_size = Dqn_V2_InitNx1(point_diameter);
|
||||
point_b->flags |= TELY_EntityFlag_Clickable;
|
||||
point_b->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
point_b->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
|
||||
TELY_GameShape *circle = Dqn_FArray_Make(&point_b->shapes, Dqn_ZeroMem_Yes);
|
||||
circle->type = TELY_GameShapeType_Circle;
|
||||
circle->circle_radius = point_radius;
|
||||
circle->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
freya_gm->lec01_point_b = point_b->handle;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t font_size = 18;
|
||||
// NOTE: Freya's Game Dev Math Lecture 01 Assignment 01
|
||||
{
|
||||
TELY_GameEntity *group_box = TELY_Game_MakeEntityPointerF(game, "Assignment 01 Group Box");
|
||||
TELY_Game_PushParentEntity(game, group_box->handle);
|
||||
DQN_DEFER { TELY_Game_PopParentEntity(game); };
|
||||
{
|
||||
group_box->local_pos = Dqn_V2_InitNx2(659, 404);
|
||||
group_box->flags |= TELY_EntityFlag_DrawHitBox;
|
||||
group_box->flags |= TELY_EntityFlag_DeriveHitBoxFromChildrenBoundingBox;
|
||||
group_box->flags |= TELY_EntityFlag_Clickable;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_task01_group_box = group_box->handle;
|
||||
}
|
||||
|
||||
// NOTE: Radial trigger
|
||||
{
|
||||
TELY_GameEntity *radial_trigger = TELY_Game_MakeEntityPointerF(game, "Radial trigger");
|
||||
freya_gm->lec01_task01_radial_trigger = radial_trigger->handle;
|
||||
freya_gm->lec01_task01_radial_trigger_radius = 100.f;
|
||||
radial_trigger->local_hit_box_size = Dqn_V2_InitNx1(font_size);
|
||||
radial_trigger->flags |= TELY_EntityFlag_Clickable;
|
||||
radial_trigger->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
radial_trigger->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
|
||||
// NOTE: Draw the "sensor"
|
||||
TELY_GameShape *circle = Dqn_FArray_Make(&radial_trigger->shapes, Dqn_ZeroMem_Yes);
|
||||
circle->type = TELY_GameShapeType_Circle;
|
||||
circle->circle_radius = radial_trigger->local_hit_box_size.w * .5f;
|
||||
circle->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
|
||||
// NOTE: Draw the trigger range
|
||||
TELY_GameShape *trigger_circle = Dqn_FArray_Make(&radial_trigger->shapes, Dqn_ZeroMem_Yes);
|
||||
trigger_circle->type = TELY_GameShapeType_Circle;
|
||||
trigger_circle->circle_radius = freya_gm->lec01_task01_radial_trigger_radius;
|
||||
trigger_circle->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
}
|
||||
|
||||
// NOTE: Movable dot that will trigger the radial trigger
|
||||
{
|
||||
TELY_GameEntity *player = TELY_Game_MakeEntityPointerF(game, "Player");
|
||||
freya_gm->lec01_task01_player = player->handle;
|
||||
|
||||
player->local_pos = Dqn_V2_InitNx2(118, 0);
|
||||
player->local_hit_box_size = Dqn_V2_InitNx1(font_size * 2.f);
|
||||
player->flags |= TELY_EntityFlag_Clickable;
|
||||
player->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
player->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
|
||||
// NOTE: Draw the player
|
||||
TELY_GameShape *rect = Dqn_FArray_Make(&player->shapes, Dqn_ZeroMem_Yes);
|
||||
rect->type = TELY_GameShapeType_Rect;
|
||||
rect->p2 = player->local_hit_box_size;
|
||||
rect->colour = TELY_COLOUR_GREEN_DARK_SEA_V4;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
TELY_GameEntity *group_box = TELY_Game_MakeEntityPointerF(game, "Assignment 02 Group Box");
|
||||
TELY_Game_PushParentEntity(game, group_box->handle);
|
||||
DQN_DEFER { TELY_Game_PopParentEntity(game); };
|
||||
{
|
||||
group_box->local_pos = Dqn_V2_InitNx2(761, 590);
|
||||
group_box->flags |= TELY_EntityFlag_DrawHitBox;
|
||||
group_box->flags |= TELY_EntityFlag_DeriveHitBoxFromChildrenBoundingBox;
|
||||
group_box->flags |= TELY_EntityFlag_Clickable;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
group_box->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_task02_group_box = group_box->handle;
|
||||
}
|
||||
|
||||
TELY_GameEntity *ray_begin = TELY_Game_MakeEntityPointerF(game, "Ray Begin");
|
||||
{
|
||||
ray_begin->local_pos = Dqn_V2_InitNx2(0, 0);
|
||||
ray_begin->local_hit_box_size = Dqn_V2_InitNx1(font_size);
|
||||
ray_begin->flags |= TELY_EntityFlag_Clickable;
|
||||
ray_begin->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
ray_begin->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_task02_ray_begin = ray_begin->handle;
|
||||
|
||||
// NOTE: Draw the ray origin
|
||||
TELY_GameShape *circle = Dqn_FArray_Make(&ray_begin->shapes, Dqn_ZeroMem_Yes);
|
||||
circle->type = TELY_GameShapeType_Circle;
|
||||
circle->circle_radius = ray_begin->local_hit_box_size.w * .5f;
|
||||
circle->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
}
|
||||
|
||||
TELY_GameEntity *ray_end = TELY_Game_MakeEntityPointerF(game, "Ray End");
|
||||
{
|
||||
ray_end->local_pos = Dqn_V2_InitNx2(100, 220);
|
||||
ray_end->local_hit_box_size = Dqn_V2_InitNx1(font_size);
|
||||
ray_end->flags |= TELY_EntityFlag_Clickable;
|
||||
ray_end->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
ray_end->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_task02_ray_end = ray_end->handle;
|
||||
|
||||
// NOTE: Draw the ray origin
|
||||
TELY_GameShape *circle = Dqn_FArray_Make(&ray_end->shapes, Dqn_ZeroMem_Yes);
|
||||
circle->type = TELY_GameShapeType_Circle;
|
||||
circle->circle_radius = ray_end->local_hit_box_size.w * .5f;
|
||||
circle->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
}
|
||||
|
||||
TELY_GameEntity *surface = TELY_Game_MakeEntityPointerF(game, "Surface");
|
||||
{
|
||||
surface->local_pos = Dqn_V2_InitNx2(0, 200);
|
||||
surface->local_hit_box_size = Dqn_V2_InitNx2(400, 25);
|
||||
surface->flags |= TELY_EntityFlag_Clickable;
|
||||
surface->flags |= TELY_EntityFlag_MoveByKeyboard;
|
||||
surface->flags |= TELY_EntityFlag_MoveByMouse;
|
||||
freya_gm->lec01_task02_surface = surface->handle;
|
||||
|
||||
TELY_GameShape *rect = Dqn_FArray_Make(&surface->shapes, Dqn_ZeroMem_Yes);
|
||||
rect->type = TELY_GameShapeType_Rect;
|
||||
rect->p2 = surface->local_hit_box_size;
|
||||
rect->colour = TELY_COLOUR_BLUE_CADET_V4;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t font_size = 18;
|
||||
game->camera.scale = Dqn_V2_InitNx1(1);
|
||||
game->inter_regular_font = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Inter-Regular.otf"), font_size);
|
||||
game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Inter-Italic.otf"), font_size);
|
||||
@ -391,132 +195,6 @@ void TELY_DLL_Init(void *user_data)
|
||||
ui->arena.allocs_are_allowed_to_leak = true;
|
||||
}
|
||||
|
||||
static void TELY_DLL_FreyaMathForGameDevs(TELY_Platform *platform)
|
||||
{
|
||||
TELY_Assets *assets = &platform->assets;
|
||||
TELY_Renderer *renderer = &platform->renderer;
|
||||
TELY_Game *game = DQN_CAST(TELY_Game *) platform->user_data;
|
||||
TELY_AssetFont *font = TELY_Asset_GetFont(assets, game->jetbrains_mono_font);
|
||||
Dqn_f32 line_thickness = 2.f;
|
||||
|
||||
TELY_Render_PushFont(renderer, font->handle);
|
||||
TELY_Render_PushColourV4(renderer, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4);
|
||||
DQN_DEFER {
|
||||
TELY_Render_PopFont(renderer);
|
||||
TELY_Render_PopColourV4(renderer);
|
||||
};
|
||||
|
||||
TELY_FreyaGameMath *freya_gm = &game->freya_game_math;
|
||||
// NOTE: Lecture 01: Numbers, Vectors & Dot Product ============================================
|
||||
{
|
||||
{
|
||||
// NOTE: Render label onto the group box
|
||||
TELY_GameEntity const *group_box = TELY_Game_GetEntity(game, freya_gm->lec01_group_box);
|
||||
Dqn_Rect group_box_world_hit_box = TELY_Game_CalcEntityWorldHitBox(game, group_box->handle);
|
||||
TELY_Render_Text(renderer, group_box_world_hit_box.pos, Dqn_V2_InitNx2(0.f, 1.f), DQN_STRING8("Numbers, Vectors & Dot Product"));
|
||||
}
|
||||
|
||||
TELY_GameEntity const *axis = TELY_Game_GetEntity(game, freya_gm->lec01_axis);
|
||||
TELY_GameEntity const *point_a = TELY_Game_GetEntity(game, freya_gm->lec01_point_a);
|
||||
TELY_GameEntity const *point_b = TELY_Game_GetEntity(game, freya_gm->lec01_point_b);
|
||||
|
||||
Dqn_V2 const axis_world_pos = TELY_Game_CalcEntityWorldPos(game, axis->handle);
|
||||
Dqn_V2 const point_a_world_pos = TELY_Game_CalcEntityWorldPos(game, point_a->handle);
|
||||
Dqn_V2 const point_b_world_pos = TELY_Game_CalcEntityWorldPos(game, point_b->handle);
|
||||
|
||||
// NOTE: Render line from axis -> 'A'
|
||||
TELY_Render_LineColourV4(renderer, axis_world_pos, point_a_world_pos, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4, line_thickness);
|
||||
TELY_Render_Text(renderer, point_a_world_pos, Dqn_V2_InitNx1(0.f), DQN_STRING8("A"));
|
||||
|
||||
// NOTE: Render line from axis -> 'B'
|
||||
TELY_Render_LineColourV4(renderer, axis_world_pos, point_b_world_pos, TELY_COLOUR_BLUE_CADET_V4, line_thickness);
|
||||
TELY_Render_Text(renderer, point_b_world_pos, Dqn_V2_InitNx1(0.f), DQN_STRING8("B"));
|
||||
|
||||
// NOTE: Normalise point 'A'
|
||||
Dqn_V2 point_a_norm = Dqn_V2_Normalise(point_a_world_pos - axis_world_pos);
|
||||
Dqn_V2 point_a_norm_to_axis = axis_world_pos + (point_a_norm * font->pixel_height * 5.f);
|
||||
|
||||
// NOTE: Draw the normalised vector of 'A'
|
||||
TELY_Render_CircleColourV4(renderer, point_a_norm_to_axis, (point_a->local_hit_box_size.w * .5f), TELY_RenderShapeMode_Fill, TELY_COLOUR_GREEN_DARK_SEA_V4);
|
||||
TELY_Render_Text(renderer, point_a_norm_to_axis, Dqn_V2_InitNx1(0.5f), DQN_STRING8("A normalised"));
|
||||
|
||||
// NOTE: Draw the scalar projection of 'B' onto 'A'
|
||||
Dqn_f32 scalar_proj = Dqn_V2_Dot(point_a_norm, point_b_world_pos - axis_world_pos);
|
||||
TELY_Render_TextF(renderer,
|
||||
Dqn_V2_InitNx2(axis_world_pos.x, axis_world_pos.y),
|
||||
Dqn_V2_InitNx1(0.f),
|
||||
"Scalar Projection: %.2f", scalar_proj);
|
||||
|
||||
// NOTE: Draw the vector projection of 'B' onto 'A'
|
||||
Dqn_V2 vector_proj = axis_world_pos + (point_a_norm * scalar_proj);
|
||||
TELY_Render_CircleColourV4(renderer, vector_proj, (point_a->local_hit_box_size.w * .5f), TELY_RenderShapeMode_Fill, TELY_COLOUR_GREEN_DARK_SEA_V4);
|
||||
TELY_Render_Text(renderer, vector_proj, Dqn_V2_InitNx1(0.5f), DQN_STRING8("Vector Projection"));
|
||||
|
||||
// NOTE: Draw the line projection the vector 'B' onto 'A'
|
||||
TELY_Render_LineColourV4(renderer, point_b_world_pos, vector_proj, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4, line_thickness);
|
||||
}
|
||||
|
||||
// NOTE: Lecture 01: Assignment 01 - Radial Trigger ============================================
|
||||
{
|
||||
// NOTE: Render label onto the group box
|
||||
TELY_GameEntity const *group_box = TELY_Game_GetEntity(game, freya_gm->lec01_task01_group_box);
|
||||
Dqn_Rect group_box_world_hit_box = TELY_Game_CalcEntityWorldHitBox(game, group_box->handle);
|
||||
TELY_Render_Text(renderer, group_box_world_hit_box.pos, Dqn_V2_InitNx2(0.f, 1.f), DQN_STRING8("Assignment 01: Radial Trigger"));
|
||||
|
||||
// NOTE: Grab the radial trigger and player
|
||||
TELY_GameEntity *radial_trigger = TELY_Game_GetEntity(game, freya_gm->lec01_task01_radial_trigger);
|
||||
TELY_GameEntity *player = TELY_Game_GetEntity(game, freya_gm->lec01_task01_player);
|
||||
|
||||
Dqn_V2 player_world_pos = TELY_Game_CalcEntityWorldPos(game, player->handle);
|
||||
Dqn_V2 radial_trigger_world_pos = TELY_Game_CalcEntityWorldPos(game, radial_trigger->handle);
|
||||
|
||||
Dqn_f32 player_to_radial_trigger_dist_sq = Dqn_V2_LengthSq_V2x2(player_world_pos, radial_trigger_world_pos);
|
||||
Dqn_Rect player_bbox = TELY_Game_CalcEntityWorldBoundingBox(game, player->handle);
|
||||
|
||||
// NOTE: Sweep radius with player size (e.g. minkowski sum)
|
||||
Dqn_f32 trigger_radius = freya_gm->lec01_task01_radial_trigger_radius + (player->local_hit_box_size.w * .5f);
|
||||
|
||||
// NOTE: Check if we trigger the radial trigger
|
||||
if (player_to_radial_trigger_dist_sq < DQN_SQUARED(trigger_radius)) {
|
||||
TELY_Render_Text(renderer,
|
||||
Dqn_V2_InitNx2(player_bbox.pos.x + player_bbox.size.w * .5f, player_bbox.pos.y),
|
||||
Dqn_V2_InitNx2(0.5f, 1),
|
||||
DQN_STRING8("!"));
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Lecture 01: Assignment 02 - Reflect ===================================================
|
||||
{
|
||||
// NOTE: Render label onto the group box
|
||||
TELY_GameEntity const *group_box = TELY_Game_GetEntity(game, freya_gm->lec01_task02_group_box);
|
||||
Dqn_Rect group_box_world_hit_box = TELY_Game_CalcEntityWorldHitBox(game, group_box->handle);
|
||||
TELY_Render_Text(renderer, group_box_world_hit_box.pos, Dqn_V2_InitNx2(0.f, 1.f), DQN_STRING8("Assignment 02: Reflect"));
|
||||
|
||||
TELY_GameEntity *ray_begin = TELY_Game_GetEntity(game, freya_gm->lec01_task02_ray_begin);
|
||||
TELY_GameEntity *ray_end = TELY_Game_GetEntity(game, freya_gm->lec01_task02_ray_end);
|
||||
TELY_GameEntity *surface = TELY_Game_GetEntity(game, freya_gm->lec01_task02_surface);
|
||||
|
||||
Dqn_V2 ray_begin_world_pos = TELY_Game_CalcEntityWorldPos(game, ray_begin->handle);
|
||||
Dqn_V2 ray_end_world_pos = TELY_Game_CalcEntityWorldPos(game, ray_end->handle);
|
||||
Dqn_Rect surface_rect = TELY_Game_CalcEntityWorldBoundingBox(game, surface->handle);
|
||||
Dqn_V2 rect_x0y0 = Dqn_V2_InitNx2(surface_rect.pos.x, surface_rect.pos.y);
|
||||
Dqn_V2 rect_x1y0 = Dqn_V2_InitNx2(surface_rect.pos.x + surface_rect.size.w, surface_rect.pos.y);
|
||||
Dqn_V2 rect_x0y1 = Dqn_V2_InitNx2(surface_rect.pos.x, surface_rect.pos.y + surface_rect.size.h);
|
||||
Dqn_V2 rect_x1y1 = Dqn_V2_InitNx2(surface_rect.pos.x + surface_rect.size.h, surface_rect.pos.y + surface_rect.size.h);
|
||||
|
||||
Dqn_V2 rect_x0y0_dir = rect_x1y0 - rect_x0y0;
|
||||
Dqn_V2 ray_dir = ray_end_world_pos - ray_begin_world_pos;
|
||||
Dqn_RaycastLineIntersectV2Result rect_top_raycast = Dqn_Raycast_LineIntersectV2(ray_begin_world_pos, ray_dir, rect_x0y0, rect_x0y0_dir);
|
||||
if (rect_top_raycast.hit && rect_top_raycast.t_b >= 0 && rect_top_raycast.t_b <= 1.f && rect_top_raycast.t_a >= 0 && rect_top_raycast.t_a <= 1.f) {
|
||||
Dqn_V2 intersect_p = rect_x0y0 + (rect_x0y0_dir * rect_top_raycast.t_b);
|
||||
Dqn_V2 in = intersect_p - ray_begin_world_pos;
|
||||
Dqn_V2 reflect = Dqn_V2_Reflect(in, rect_x0y0_dir);
|
||||
TELY_Render_LineColourV4(renderer, ray_begin_world_pos, ray_end_world_pos, TELY_COLOUR_BLUE_CADET_V4, 2.f);
|
||||
TELY_Render_LineColourV4(renderer, intersect_p, intersect_p + reflect, TELY_COLOUR_BLUE_CADET_V4, 2.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
void TELY_DLL_FrameUpdate(void *user_data)
|
||||
{
|
||||
@ -756,241 +434,5 @@ void TELY_DLL_FrameUpdate(void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================================
|
||||
|
||||
#if 0
|
||||
Dqn_Rect entity_ui_layout = Dqn_Rect_InitNx4(game->entity.pos.x, game->entity.pos.y, 0, 0);
|
||||
TELY_UI_LayoutScope(ui, entity_ui_layout) {
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Bottom) {
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "Anim: %.*s [%I32u, %I32u], Frame %I64u", DQN_STRING_FMT(hero_anim_label), hero_frame_offset, hero_frame_count, hero_frame);
|
||||
|
||||
TELY_UICommand *ticks_per_anim_frame_label = TELY_UI_TextF(ui, TELY_UI_GenerateID(), "Ticks Per Anim Frame: %I32u", hero_ticks_per_anim_frame);
|
||||
TELY_UI_LayoutScope(ui, ticks_per_anim_frame_label->offcut_rect) {
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
if (TELY_UI_Button(ui, TELY_UI_GenerateID(), DQN_STRING8("-"))->interacted) {
|
||||
hero_ticks_per_anim_frame--;
|
||||
}
|
||||
if (TELY_UI_Button(ui, TELY_UI_GenerateID(), DQN_STRING8("+"))->interacted) {
|
||||
hero_ticks_per_anim_frame++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TELY_UICommand *button = TELY_UI_Button(ui, TELY_UI_GenerateID(), DQN_STRING8("Apply"));
|
||||
static char count_hero_frame[3] = {};
|
||||
static Dqn_usize count_hero_frame_size = 0;
|
||||
TELY_UICommand *count_input_box = TELY_UI_InputBox(ui, TELY_UI_GenerateID(), count_hero_frame, sizeof(count_hero_frame), &count_hero_frame_size);
|
||||
TELY_UI_LayoutScope(ui, count_input_box->offcut_rect) {
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Count"));
|
||||
}
|
||||
|
||||
static char start_hero_frame[3] = {};
|
||||
static Dqn_usize start_hero_frame_size = 0;
|
||||
TELY_UICommand *start_sprite_input_box = TELY_UI_InputBox(ui, TELY_UI_GenerateID(), start_hero_frame, sizeof(start_hero_frame), &start_hero_frame_size);
|
||||
TELY_UI_LayoutScope(ui, start_sprite_input_box->offcut_rect) {
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Start Frame"));
|
||||
}
|
||||
|
||||
if (button->interacted) {
|
||||
Dqn_String8ToU64Result start_hero_frame_u64 = Dqn_String8_ToU64(Dqn_String8_Init(start_hero_frame, start_hero_frame_size), /*separator*/ 0);
|
||||
Dqn_String8ToU64Result count_hero_frame_u64 = Dqn_String8_ToU64(Dqn_String8_Init(count_hero_frame, count_hero_frame_size), /*separator*/ 0);
|
||||
if (start_hero_frame_u64.success && count_hero_frame_u64.success) {
|
||||
hero_frame_offset = DQN_CAST(uint32_t)start_hero_frame_u64.value;
|
||||
hero_frame_count = DQN_CAST(uint32_t)count_hero_frame_u64.value;
|
||||
}
|
||||
}
|
||||
|
||||
for (Dqn_usize anim_index = 0; anim_index < DQN_ARRAY_UCOUNT(hero_anims); anim_index++) {
|
||||
TELY_AssetSpriteAnimation *anim = hero_anims + anim_index;
|
||||
if (TELY_UI_Button(ui, TELY_UI_ID(__COUNTER__ + 1, DQN_CAST(uint16_t)anim_index), anim->label)->interacted) {
|
||||
hero_frame_offset = anim->index;
|
||||
hero_frame_count = anim->count;
|
||||
hero_anim_label = anim->label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// =============================================================================================
|
||||
|
||||
// NOTE: Overlay UI
|
||||
Dqn_ProfilerZone profile_build_ui = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("Build UI"), TELY_ProfileZone_BuildUI);
|
||||
|
||||
#if 0
|
||||
Dqn_Rect layout = Dqn_Rect_InitNx4(100, 100, DQN_CAST(Dqn_f32)platform->window_size.w, DQN_CAST(Dqn_f32)platform->window_size.h);
|
||||
TELY_UI_PushRectCutSide(ui, Dqn_RectCutSide_Top);
|
||||
TELY_UI_PushLayout(ui, layout);
|
||||
|
||||
TELY_UI_StringColourV4Scope(ui, Dqn_V4_InitNx4(0.8f, 0.8f, 0.8f, 1.f)) {
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), info_label);
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), info_label);
|
||||
}
|
||||
|
||||
TELY_UI_InnerPaddingScope(ui, Dqn_V2_InitNx1(0)) {
|
||||
TELY_UI_OuterPaddingScope(ui, Dqn_V2_InitNx1(0)) {
|
||||
TELY_UIID container_id = TELY_UI_GenerateID();
|
||||
TELY_UI_BoxScope(ui, container_id) {
|
||||
for (size_t anchor_index = 1; anchor_index < TELY_ProfileZone_Count; anchor_index++) {
|
||||
Dqn_ProfilerAnchor *anchor = Dqn_Profiler_AnchorBuffer(Dqn_ProfilerAnchorBuffer_Front) + anchor_index;
|
||||
uint64_t tsc_exclusive = anchor->tsc_exclusive;
|
||||
uint64_t tsc_inclusive = anchor->tsc_inclusive;
|
||||
Dqn_f64 tsc_exclusive_percentage_of_frame = tsc_exclusive * 100 / DQN_CAST(Dqn_f64)input->delta_time_tsc;
|
||||
Dqn_f64 tsc_exclusive_milliseconds = tsc_exclusive * 1000 / DQN_CAST(Dqn_f64)platform->tsc_per_second;
|
||||
if (tsc_exclusive == tsc_inclusive) {
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "%.*s[%u]: %.1fms (%.1f%%)",
|
||||
DQN_STRING_FMT(g_tely_profile_zone_names[anchor_index]),
|
||||
anchor->hit_count,
|
||||
tsc_exclusive_milliseconds,
|
||||
tsc_exclusive_percentage_of_frame);
|
||||
} else {
|
||||
Dqn_f64 tsc_inclusive_percentage_of_frame = tsc_inclusive * 100 / DQN_CAST(Dqn_f64)input->delta_time_tsc;
|
||||
Dqn_f64 tsc_inclusive_milliseconds = tsc_inclusive * 1000 / DQN_CAST(Dqn_f64)platform->tsc_per_second;
|
||||
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "%.*s[%u]: %.1f/%.1fms (%.1f/%.1f%%)",
|
||||
DQN_STRING_FMT(g_tely_profile_zone_names[anchor_index]),
|
||||
anchor->hit_count,
|
||||
tsc_exclusive_milliseconds,
|
||||
tsc_inclusive_milliseconds,
|
||||
tsc_exclusive_percentage_of_frame,
|
||||
tsc_inclusive_percentage_of_frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "mouse_p={%.2f, %.2f}", input->mouse_p.x, input->mouse_p.y);
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "mouse_p_delta={%.2f, %.2f}", input->mouse_p_delta.x, input->mouse_p_delta.y);
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "mouse_wheel={%.2f, %.2f}", input->mouse_wheel.x, input->mouse_wheel.y);
|
||||
|
||||
TELY_PlatformInputKey *left = input->scan_codes + TELY_PlatformInputScanCode_Left;
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "left={transition_count=%u}", left->transition_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (TELY_UI_Button(ui, TELY_UI_GenerateID(), DQN_STRING8("Hello world, long button"))->interacted) {
|
||||
Dqn_Log_DebugF("Button 2 clicked!");
|
||||
}
|
||||
|
||||
// TODO(doyle): There's some padding issues here
|
||||
static Dqn_f32 f32_val = {};
|
||||
static Dqn_f64 f64_val = {};
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_DragBoxF32(ui, TELY_UI_GenerateID(), &f32_val);
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "F32: %.1f", f32_val);
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_DragBoxF64(ui, TELY_UI_GenerateID(), &f64_val);
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "F64: %.1f", f64_val);
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Draw"));
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_Checkbox(ui, TELY_UI_GenerateID(), &ui->debug_draw_bounding_rect);
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Bounding Rect"));
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_Checkbox(ui, TELY_UI_GenerateID(), &ui->debug_draw_clip_rect);
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Clip Rect"));
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_Checkbox(ui, TELY_UI_GenerateID(), &ui->debug_draw_content_rect);
|
||||
TELY_UI_Text(ui, TELY_UI_GenerateID(), DQN_STRING8("Content Rect"));
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
TELY_UI_BeginBox(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_RectCutSideScope(ui, Dqn_RectCutSide_Left) {
|
||||
TELY_UI_Checkbox(ui, TELY_UI_GenerateID(), &ui->debug_draw_client_rect);
|
||||
TELY_UI_Text(ui,TELY_UI_GenerateID(), DQN_STRING8("Client Rect"));
|
||||
}
|
||||
TELY_UI_EndBox(ui, TELY_UI_GenerateID());
|
||||
|
||||
static char buffer[16] = "012345678";
|
||||
static Dqn_usize buffer_text_size = 9;
|
||||
TELY_UI_InputBox(ui, TELY_UI_GenerateID(), buffer, sizeof(buffer), &buffer_text_size);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// TODO(doyle): Drawing widgets after this window will draw it relative
|
||||
// to the window's origin.
|
||||
static Dqn_Rect window_layout = Dqn_Rect_InitNx4(100, 100, 300, 300);
|
||||
TELY_UI_BeginWindow(ui, TELY_UI_GenerateID(), DQN_STRING8("TSC Profiler"), &window_layout);
|
||||
// TELY_UI_PushInnerPadding(ui, Dqn_V2_InitNx1(0));
|
||||
// TELY_UI_PushOuterPadding(ui, Dqn_V2_InitNx1(0));
|
||||
for (size_t anchor_index = 1; anchor_index < TELY_ProfileZone_Count; anchor_index++) {
|
||||
Dqn_ProfilerAnchor *anchor = Dqn_Profiler_AnchorBuffer(Dqn_ProfilerAnchorBuffer_Front) + anchor_index;
|
||||
uint64_t tsc_exclusive = anchor->tsc_exclusive;
|
||||
uint64_t tsc_inclusive = anchor->tsc_inclusive;
|
||||
Dqn_f64 tsc_exclusive_percentage_of_frame = tsc_exclusive * 100 / DQN_CAST(Dqn_f64)input->delta_time_tsc;
|
||||
Dqn_f64 tsc_exclusive_milliseconds = tsc_exclusive * 1000 / DQN_CAST(Dqn_f64)platform->tsc_per_second;
|
||||
Dqn_String8 zone_name = g_tely_profile_zone_names[anchor_index];
|
||||
if (tsc_exclusive == tsc_inclusive) {
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "%.*s[%u]: %.1fms (%.1f%%)",
|
||||
DQN_STRING_FMT(zone_name),
|
||||
anchor->hit_count,
|
||||
tsc_exclusive_milliseconds,
|
||||
tsc_exclusive_percentage_of_frame);
|
||||
} else {
|
||||
Dqn_f64 tsc_inclusive_percentage_of_frame = tsc_inclusive * 100 / DQN_CAST(Dqn_f64)input->delta_time_tsc;
|
||||
Dqn_f64 tsc_inclusive_milliseconds = tsc_inclusive * 1000 / DQN_CAST(Dqn_f64)platform->tsc_per_second;
|
||||
|
||||
TELY_UI_TextF(ui, TELY_UI_GenerateID(), "%.*s[%u]: %.1f/%.1fms (%.1f/%.1f%%)",
|
||||
DQN_STRING_FMT(zone_name),
|
||||
anchor->hit_count,
|
||||
tsc_exclusive_milliseconds,
|
||||
tsc_inclusive_milliseconds,
|
||||
tsc_exclusive_percentage_of_frame,
|
||||
tsc_inclusive_percentage_of_frame);
|
||||
}
|
||||
}
|
||||
// TELY_UI_PopInnerPadding(ui);
|
||||
// TELY_UI_PopOuterPadding(ui);
|
||||
TELY_UI_EndWindow(ui, TELY_UI_GenerateID());
|
||||
TELY_UI_Flush(ui, platform, renderer, frame_time);
|
||||
#endif
|
||||
|
||||
// =============================================================================================
|
||||
|
||||
TELY_RFui *rfui = &game->rfui;
|
||||
TELY_RFui_FrameSetup(rfui, &platform->frame_arena);
|
||||
TELY_RFui_PushFont(rfui, game->jetbrains_mono_font);
|
||||
#if 0
|
||||
|
||||
TELY_RFuiResult row = TELY_RFui_Row(rfui, DQN_STRING8("Row ID"));
|
||||
TELY_RFui_PushParent(rfui, row.widget);
|
||||
if (TELY_RFui_Button(rfui, DQN_STRING8("File")).clicked) {
|
||||
Dqn_Log_DebugF("Hello Seaman");
|
||||
}
|
||||
if (TELY_RFui_Button(rfui, DQN_STRING8("Window")).clicked) {
|
||||
Dqn_Log_DebugF("Hello Seaman");
|
||||
}
|
||||
if (TELY_RFui_Button(rfui, DQN_STRING8("Panel")).clicked) {
|
||||
Dqn_Log_DebugF("Hello Seaman");
|
||||
}
|
||||
TELY_RFui_PopParent(rfui);
|
||||
#endif
|
||||
|
||||
// =============================================================================================
|
||||
|
||||
TELY_DLL_FreyaMathForGameDevs(platform);
|
||||
|
||||
// =============================================================================================
|
||||
|
||||
TELY_Audio_MixPlaybackSamples(audio, assets);
|
||||
|
||||
// TELY_RFui_Flush(rfui, renderer, input, assets);
|
||||
Dqn_Profiler_EndZone(profile_build_ui);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
#include "tely_dll_unity.h"
|
||||
#include "feely_pona_unity.h"
|
||||
|
@ -60,4 +60,4 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
|
||||
#include "tely_platform_input.cpp"
|
||||
#include "tely_ui.cpp"
|
||||
#include "tely_rfui.cpp"
|
||||
#include "tely_dll.cpp"
|
||||
#include "feely_pona.cpp"
|
||||
|
BIN
project.rdbg
Normal file
BIN
project.rdbg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user