Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CardealRusso committed Nov 7, 2024
1 parent 95e8106 commit c4e5ee4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions examples/cookieclicker/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int run() {
if (bonus > 1) {
vsformat_concat("\\c0x3299a8 \\s16 *%d", bonus);
}
fenster_drawtext(&f, font, vsbuffer, 10, 30);
fenster_drawtext(&f, font, vsbuff, 10, 30);

int button_w = 200, button_h = 80, start_y = 100;
for (int i = 0; i < 9; i++) {
Expand Down Expand Up @@ -110,7 +110,7 @@ int run() {
(unsigned long long)autoclickers[i].cost,
(unsigned long long)autoclickers[i].owned);

fenster_drawtext(&f, font, vsbuffer, x + 10, y + 10);
fenster_drawtext(&f, font, vsbuff, x + 10, y + 10);
}
}

Expand Down
10 changes: 6 additions & 4 deletions examples/shapes/lines.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ static int run() {
fenster_drawline(&f, f.width, 0, mouseX, mouseY, GREEN);
fenster_drawline(&f, 0, f.height, mouseX, mouseY, WHITE);
fenster_drawline(&f, f.width, f.height, mouseX, mouseY, WHITE);

fenster_drawtext(&f, font, vsformat("Frame: %d", frame), 10, 10);

fenster_drawtext(&f, font, vsformat("Press F for fullscreen | ESC to exit | Mouse: (%d, %d)", mouseX, mouseY), 10, f.height - 30);

vsformat("Frame: %d", frame);
fenster_drawtext(&f, font, vsbuff, 10, 10);

vsformat("Press F for fullscreen | ESC to exit | Mouse: (%d, %d)", mouseX, mouseY);
fenster_drawtext(&f, font, vsbuff, 10, f.height - 30);

fenster_sync(&f, 60);
if (f.keysp[70] == 1) fenster_fullscreen(&f, fs ^= 1);
Expand Down
9 changes: 6 additions & 3 deletions examples/ttf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ static int run() {
fenster_fill(&f, 0);
fenster_drawtext(&f, font, "\\c0x526D82 Hello \\s32 \\c0xDDE6ED BIG \\s16 \\c0x526D82 World \\n From FensterB!", 10, 10);

fenster_drawtext(&f, font, vsformat("\\s16 \\c0xFFFFFF Press F to %s Full screen", fs == 0 ? "enter" : "leave"), 0, 200);
fenster_drawtext(&f, font, vsformat("\\c%d To save CPU cycles, we\\n reprint this text only\\n when window is resized.", rand()), 0, 100);
vsformat("\\s16 \\c0xFFFFFF Press F to %s Full screen", fs == 0 ? "enter" : "leave");
fenster_drawtext(&f, font, vsbuff, 0, 200);
vsformat("\\c%d To save CPU cycles, we\\n reprint this text only\\n when window is resized.", rand());
fenster_drawtext(&f, font, vsbuff, 0, 100);
}

fenster_drawtext(&f, font, vsformat("\\b%d \\s16 Frame: %d", rand(), frame), 0, f.height-16);
vsformat("\\b%d \\s16 Frame: %d", rand(), frame);
fenster_drawtext(&f, font, vsbuff, 0, f.height-16);
fenster_sync(&f, 30);

if (f.keysp[70] == 1) fenster_fullscreen(&f, fs ^= 1);
Expand Down
12 changes: 6 additions & 6 deletions src/fenster_addons.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@

#define PI 3.14159265358979323846

#define VSBUFFER_SIZE (16 * 1024)
#define VSBUFF_SIZE (16 * 1024)

char vsbuffer[VSBUFFER_SIZE];
char vsbuff[VSBUFF_SIZE];

void vsformat(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
vsnprintf(vsbuffer, VSBUFFER_SIZE, fmt, args);
vsnprintf(vsbuff, VSBUFF_SIZE, fmt, args);
va_end(args);
}

void vsformat_concat(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
size_t len = strlen(vsbuffer);
if (len < VSBUFFER_SIZE - 1) {
vsnprintf(vsbuffer + len, VSBUFFER_SIZE - len, fmt, args);
size_t len = strlen(vsbuff);
if (len < VSBUFF_SIZE - 1) {
vsnprintf(vsbuff + len, VSBUFF_SIZE - len, fmt, args);
}
va_end(args);
}
Expand Down

0 comments on commit c4e5ee4

Please sign in to comment.