51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <time.h>
|
|
#include <stdint.h>
|
|
#include <wayland-client.h>
|
|
#include <wayland-util.h>
|
|
#include <SDL3/SDL.h>
|
|
#include <pthread.h>
|
|
#include <sys/mman.h>
|
|
#include "renderer.h"
|
|
#include "wayland.h"
|
|
|
|
struct timespec program_start;
|
|
|
|
int running = 1;
|
|
|
|
void init_timer() {
|
|
clock_gettime(CLOCK_MONOTONIC, &program_start);
|
|
}
|
|
|
|
double time_since_start() {
|
|
struct timespec now;
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
return (now.tv_sec - program_start.tv_sec) +
|
|
(now.tv_nsec - program_start.tv_nsec) / 1e9;
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
char *shader_path = NULL;
|
|
if (argc >= 2) {
|
|
shader_path = argv[1];
|
|
} else {
|
|
printf("need to supply path to shader\n");
|
|
exit(1);
|
|
}
|
|
|
|
struct client_state state = wayland_init();
|
|
|
|
Renderer renderer = new_renderer();
|
|
|
|
while (running) {
|
|
double time = time_since_start();
|
|
render(&renderer, state.width, state.height, time, shader_path, false);
|
|
commit(&state);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|