shaders using wayland time instead of stdtime
This commit is contained in:
parent
bb63b49155
commit
859025a4a3
3 changed files with 14 additions and 31 deletions
29
glonkers.c
29
glonkers.c
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-util.h>
|
||||
|
|
@ -12,20 +11,6 @@
|
|||
#include "wayland.h"
|
||||
#include <string.h>
|
||||
|
||||
struct timespec program_start;
|
||||
|
||||
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;
|
||||
int output_type = OUTPUT_WINDOW;
|
||||
|
|
@ -51,27 +36,21 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct client_state state;
|
||||
wayland_init(&state, output_type);
|
||||
struct client_state *state = wayland_init(output_type);
|
||||
|
||||
Renderer renderer = new_renderer();
|
||||
|
||||
bool running = true;
|
||||
while (running) {
|
||||
double time = time_since_start();
|
||||
|
||||
struct event event = wait_for_event(&state);
|
||||
struct event event = wait_for_event(state);
|
||||
if (event.type == EVENT_DRAW) {
|
||||
printf("drawing!!!! %p\n", event.data.draw.surface);
|
||||
int width = event.data.draw.width;
|
||||
int height = event.data.draw.height;
|
||||
double time = event.data.draw.time / 1000.0;
|
||||
render(&renderer, width, height, time, shader_path, 0);
|
||||
printf("about to 🦬 swap buf %p\n", event.data.draw.surface);
|
||||
swap_buffers(&state, event.data.draw.surface);
|
||||
printf("🦬🦬🦬 swaped a buffalo\n");
|
||||
swap_buffers(state, event.data.draw.surface);
|
||||
}
|
||||
if (event.type == EVENT_NONE) {
|
||||
printf("nothing, absolutely nothing\n");
|
||||
}
|
||||
if (event.type == EVENT_EXIT) {
|
||||
running = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue