Introduce new timer based on vsync

This commit is contained in:
2023-08-27 21:29:43 +02:00
parent db2e5543df
commit c40a8f44a5
6 changed files with 129 additions and 22 deletions

View File

@@ -2,23 +2,40 @@
#include "assets.hpp"
#include <PSX/GPU/gpu_primitives.hpp>
#include <PSX/GPU/gpu.hpp>
#include <PSX/Timer/frame_timer.hpp>
#include <stdio.h>
using namespace JabyEngine;
static SimpleTimer<uint8_t> timer;
static void setup() {
Assets::load_for_main();
FontWriter::setup();
timer.reset();
}
static void update() {
const auto end_pos = FontWriter::write({0, 32}, "Cody is cute\n&\na \x1b[8;0;0mBAAAAABY!!!");
FontWriter::write(end_pos, "\x1b[0;7;7mJaby was\nhere c:");
if(timer.is_expired_for(1000_ms)) {
printf("Dino\n");
timer.reset();
}
}
static void render() {
GPU::swap_buffers_vsync(1);
FontWriter::render();
}
void main() {
setup();
while(true) {
const auto end_pos = FontWriter::write({0, 32}, "Cody is cute\n&\na \x1b[8;0;0mBAAAAABY!!!");
FontWriter::write(end_pos, "\x1b[0;7;7mJaby was\nhere c:");
GPU::swap_buffers_vsync(1);
FontWriter::render();
update();
render();
}
}