This repository has been archived on 2025-02-04. You can view files and clone it, but cannot push or open issues or pull requests.
helpless/entry.c
Charlie c61f216d37 - Simple rectangle drawing
- We just add to a frame of quads which the renderer deals with in gfx_update
	- draw_quad, draw_rect, draw_rect_rotated
	- Currently just implemented with legacy opengl, so we can't do custom shading
- Added third party code from lodepng so we can load pngs without any other dependencies (no C includes)
- ALLOCATOR_REALLOCATE
- Basic Vector2, Vector3, Vector4 stuff, and some math utilities
- Added <math.h> dependency for now.
- Graphics renderer frontend layer
- Naive get_random() implementation
2024-06-29 13:27:37 +02:00

39 lines
955 B
C

int start(int argc, char **argv) {
window.title = fixed_string("My epic game");
window.width = 400;
window.height = 400;
window.x = 200;
window.y = 200;
seed_for_random = os_get_current_cycle_count();
float64 last_time = os_get_current_time_in_seconds();
while (!window.should_close) {
reset_temporary_storage();
context.allocator = temp;
os_update();
float64 now = os_get_current_time_in_seconds();
float64 delta = now - last_time;
last_time = now;
// Print some random FPS samples every now and then
if ((get_random() % 4000) == 3)
print("%2.f FPS\n", 1.0/delta);
draw_rect_rotated(v2(-.25f, -.25f), v2(.5f, .5f), COLOR_RED, v2(.25, .25), (f32)now);
Vector2 hover_position = v2_rotate_point_around_pivot(v2(-.5, -.5), v2(0, 0), -(f32)now);
Vector2 local_pivot = v2(.125f, .125f);
draw_rect(v2_sub(hover_position, local_pivot), v2(.25f, .25f), COLOR_GREEN);
gfx_update();
}
return 0;
}