Compare commits

..

No commits in common. "bf4fa361b92f312a0419af9d69f8cebbc4543222" and "76e583f4a803c27c44967148ca095ede8881a577" have entirely different histories.

2 changed files with 33 additions and 57 deletions

View file

@ -1,3 +1,7 @@
# Huh
Quick test to see how easy it easy to have a fully self-contained repository that bootstraps its build process.
# Requirements # Requirements
[PowerShell](https://github.com/PowerShell/PowerShell/releases/tag/v7.5.4) (>= 7.5.4) [PowerShell](https://github.com/PowerShell/PowerShell/releases/tag/v7.5.4) (>= 7.5.4)

View file

@ -2,6 +2,7 @@
#include "base.c" #include "base.c"
#define SOKOL_IMPL #define SOKOL_IMPL
#define SOKOL_NO_ENTRY
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
#define SOKOL_D3D11 #define SOKOL_D3D11
@ -17,7 +18,6 @@
#include "sokol/sokol_gfx.h" #include "sokol/sokol_gfx.h"
#include "sokol/sokol_glue.h" #include "sokol/sokol_glue.h"
#include "sokol/sokol_log.h" #include "sokol/sokol_log.h"
#include "sokol/util/sokol_debugtext.h"
sg_pass_action pass_action; sg_pass_action pass_action;
@ -34,37 +34,6 @@ init(void) {
.clear_value = { 1.0f, 0.0f, 0.0f, 1.0f } .clear_value = { 1.0f, 0.0f, 0.0f, 1.0f }
} }
}; };
sdtx_setup(&(sdtx_desc_t){
.fonts = {
[0] = sdtx_font_kc853(),
[1] = sdtx_font_kc854(),
[2] = sdtx_font_z1013(),
[3] = sdtx_font_cpc(),
[4] = sdtx_font_c64(),
[5] = sdtx_font_oric(),
},
});
// c23 tests
capture auto x = 0;
auto inc = closure(^{
x += 1;
});
s32 i = -10243;
scope_exit {
printf("it works %d!\n", i);
};
printf("x = %d\n", x);
inc();
inc();
inc();
inc();
inc();
inc();
printf("x = %d\n", x);
} }
static void static void
@ -72,21 +41,12 @@ frame(void) {
sg_begin_pass(&(sg_pass){ sg_begin_pass(&(sg_pass){
.action.colors[0] = { .action.colors[0] = {
.load_action = SG_LOADACTION_CLEAR, .load_action = SG_LOADACTION_CLEAR,
.clear_value = { 0.10f, 0.10f, 0.10f, 1.0f }, .clear_value = { 0.5f, 0.25f, 0.75f, 1.0f },
}, },
.swapchain = sglue_swapchain(), .swapchain = sglue_swapchain(),
}); });
sdtx_origin(0, 0);
sdtx_canvas(sapp_widthf(), sapp_heightf());
sdtx_font(3);
sdtx_pos(1, 1);
sdtx_color3b(0, 0xFF, 0);
sdtx_puts("press escape to quit");
sdtx_draw();
sg_end_pass(); sg_end_pass();
sg_commit(); sg_commit();
} }
@ -97,26 +57,38 @@ cleanup(void) {
static void static void
event(const sapp_event* event) { event(const sapp_event* event) {
if (event->type == SAPP_EVENTTYPE_KEY_DOWN) {
if (event->key_code == SAPP_KEYCODE_ESCAPE) {
sapp_request_quit();
}
}
} }
sapp_desc int
sokol_main(int argc, char* argv[]) { main(int argc, char* argv[]) {
(void)argc; sapp_run(&(sapp_desc) {
(void)argv;
return (sapp_desc) {
.init_cb = init, .init_cb = init,
.frame_cb = frame, .frame_cb = frame,
.cleanup_cb = cleanup, .cleanup_cb = cleanup,
.event_cb = event,
.logger.func = slog_func, .logger.func = slog_func,
.width = 400, .width = 400,
.height = 300, .height = 300,
.window_title = "hello, world", .window_title = "hello, world",
});
capture auto x = 0;
auto inc = closure(^{
x += 1;
});
s32 i = -10243;
scope_exit {
printf("it works %d!\n", i);
}; };
f32 fi = cast(f32, i);
printf("%.2f\n", fi);
inc();
inc();
inc();
inc();
printf("%d\n", x);
} }