.
This commit is contained in:
parent
60d7b681f5
commit
bf4fa361b9
1 changed files with 70 additions and 42 deletions
112
src/main.c
112
src/main.c
|
|
@ -2,7 +2,6 @@
|
|||
#include "base.c"
|
||||
|
||||
#define SOKOL_IMPL
|
||||
#define SOKOL_NO_ENTRY
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#define SOKOL_D3D11
|
||||
|
|
@ -18,6 +17,7 @@
|
|||
#include "sokol/sokol_gfx.h"
|
||||
#include "sokol/sokol_glue.h"
|
||||
#include "sokol/sokol_log.h"
|
||||
#include "sokol/util/sokol_debugtext.h"
|
||||
|
||||
sg_pass_action pass_action;
|
||||
|
||||
|
|
@ -34,44 +34,19 @@ init(void) {
|
|||
.clear_value = { 1.0f, 0.0f, 0.0f, 1.0f }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
frame(void) {
|
||||
sg_begin_pass(&(sg_pass){
|
||||
.action.colors[0] = {
|
||||
.load_action = SG_LOADACTION_CLEAR,
|
||||
.clear_value = { 0.5f, 0.25f, 0.75f, 1.0f },
|
||||
},
|
||||
.swapchain = sglue_swapchain(),
|
||||
});
|
||||
sg_end_pass();
|
||||
|
||||
sg_commit();
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(void) {
|
||||
sg_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
event(const sapp_event* event) {
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
sapp_run(&(sapp_desc) {
|
||||
.init_cb = init,
|
||||
.frame_cb = frame,
|
||||
.cleanup_cb = cleanup,
|
||||
.logger.func = slog_func,
|
||||
|
||||
.width = 400,
|
||||
.height = 300,
|
||||
.window_title = "hello, world",
|
||||
});
|
||||
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;
|
||||
|
|
@ -82,13 +57,66 @@ main(int argc, char* argv[]) {
|
|||
printf("it works %d!\n", i);
|
||||
};
|
||||
|
||||
f32 fi = cast(f32, i);
|
||||
printf("%.2f\n", fi);
|
||||
|
||||
printf("x = %d\n", x);
|
||||
inc();
|
||||
inc();
|
||||
inc();
|
||||
inc();
|
||||
|
||||
printf("%d\n", x);
|
||||
inc();
|
||||
inc();
|
||||
printf("x = %d\n", x);
|
||||
}
|
||||
|
||||
static void
|
||||
frame(void) {
|
||||
sg_begin_pass(&(sg_pass){
|
||||
.action.colors[0] = {
|
||||
.load_action = SG_LOADACTION_CLEAR,
|
||||
.clear_value = { 0.10f, 0.10f, 0.10f, 1.0f },
|
||||
},
|
||||
.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_commit();
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(void) {
|
||||
sg_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
event(const sapp_event* event) {
|
||||
if (event->type == SAPP_EVENTTYPE_KEY_DOWN) {
|
||||
if (event->key_code == SAPP_KEYCODE_ESCAPE) {
|
||||
sapp_request_quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sapp_desc
|
||||
sokol_main(int argc, char* argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return (sapp_desc) {
|
||||
.init_cb = init,
|
||||
.frame_cb = frame,
|
||||
.cleanup_cb = cleanup,
|
||||
.event_cb = event,
|
||||
.logger.func = slog_func,
|
||||
|
||||
.width = 400,
|
||||
.height = 300,
|
||||
.window_title = "hello, world",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue