blob: 23094bbeecbe4c84b0cacd09b5961462d0751658 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#define _XOPEN_SOURCE 600
#define _POSIX_C_SOURCE 200112L
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
typedef struct {
uint16_t width;
uint16_t height;
uint8_t image_count; // amount of frames in flight
uint8_t image_front; // image being drawn to screen
uint8_t image_recent; // last image that finished drawing
uint8_t image_current; // current image being drawn
pthread_mutex_t lock;
uint32_t** images;
} Swapchain;
void swapchain_next(Swapchain* swapchain);
void swapchain_submit(Swapchain* swapchain);
struct Screen {
Swapchain swapchain;
float delta;
void* internal;
};
#define Screen struct Screen
#define KEY_W 25
#define KEY_A 38
#define KEY_S 39
#define KEY_D 40
#define KEY_UP 111
#define KEY_DOWN 116
#define KEY_LEFT 113
#define KEY_RIGHT 114
#define KEY_MINUS 20
#define KEY_EQUALS 21
#define KEY_ESC 9
void init_screen(Screen* screen, uint16_t width, uint16_t height, const char* title, uint16_t update_rate);
bool poll_screen(Screen* screen);
void free_screen(Screen* screen);
bool key_pressed(int keycode);
bool key_down(int keycode);
|