put event handling to the front

main
Henri Vasserman 2025-01-07 20:54:01 +02:00
parent 2cf491aa1f
commit 073453e89a
1 changed files with 30 additions and 30 deletions

View File

@ -61,36 +61,6 @@ int main() {
f.offset.y += 16;
}
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderFillRect(rend, &(SDL_FRect) { 0, 0, w, h});
Field_scroll(&f);
Field_draw(&f, rend);
if (debug) {
char buf[72];
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderFillRect(rend, &(SDL_FRect) {
0, 0, sizeof(buf)*font_w, 8*font_h
});
draw_text(rend, ACCEL_PLATFORM_STR, sizeof(ACCEL_PLATFORM_STR), RC(1,1), 255, 255, 255);
size_t len = snprintf(buf, sizeof(buf),
"off.x: %d, off.y: %d, \xEBT: %02" PRIu64, f.offset.x, f.offset.y, delta);
draw_text(rend, buf, len, RC(2, 1), 255, 255, 255);
char *q[] = {"TL", "TR", "BL", "BR"};
for (int i = 0; i < 4; i++) {
Picture *p = f.pics[i];
len = snprintf(buf, sizeof(buf), "%s \xB3 x: %05d, y: %05d, w: %d, h: %d, p: %p",
q[i], p->x, p->y, p->w, p->h, p);
draw_text(rend, buf, len, RC(3+i, 1), 255, 255, 255);
}
}
SDL_RenderPresent(rend);
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
@ -126,6 +96,36 @@ int main() {
}
}
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderFillRect(rend, &(SDL_FRect) { 0, 0, w, h});
Field_scroll(&f);
Field_draw(&f, rend);
if (debug) {
char buf[72];
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderFillRect(rend, &(SDL_FRect) {
0, 0, sizeof(buf)*font_w, 8*font_h
});
draw_text(rend, ACCEL_PLATFORM_STR, sizeof(ACCEL_PLATFORM_STR), RC(1,1), 255, 255, 255);
size_t len = snprintf(buf, sizeof(buf),
"off.x: %d, off.y: %d, \xEBT: %02" PRIu64, f.offset.x, f.offset.y, delta);
draw_text(rend, buf, len, RC(2, 1), 255, 255, 255);
char *q[] = {"TL", "TR", "BL", "BR"};
for (int i = 0; i < 4; i++) {
Picture *p = f.pics[i];
len = snprintf(buf, sizeof(buf), "%s \xB3 x: %05d, y: %05d, w: %d, h: %d, p: %p",
q[i], p->x, p->y, p->w, p->h, p);
draw_text(rend, buf, len, RC(3+i, 1), 255, 255, 255);
}
}
SDL_RenderPresent(rend);
if (delta < 16) {
SDL_Delay(16 - delta);
}