Files
vn/include/window.h
T

78 lines
1.9 KiB
C++

// window.h
#pragma once
#ifndef WINDOW_H
#define WINDOW_H
typedef struct window_t window_t;
enum KeyCode {
// Letters
KEY_A = 4,
KEY_D = 7,
KEY_S = 22,
KEY_W = 26,
// Numbers
KEY_1 = 30,
KEY_0 = 39,
// Controls
KEY_RETURN = 40,
KEY_ESCAPE = 41,
KEY_BACKSPACE = 42,
KEY_TAB = 43,
KEY_SPACE = 44,
// Modifiers
KEY_LCTRL = 224,
KEY_LSHIFT = 225,
KEY_RCTRL = 228,
KEY_RSHIFT = 229,
// Navigation
KEY_RIGHT = 79,
KEY_LEFT = 80,
KEY_DOWN = 81,
KEY_UP = 82,
// Function Keys
KEY_F1 = 58,
KEY_F2 = 59
};
enum MouseButton {
MOUSE_BUTTON_LEFT = 1,
MOUSE_BUTTON_MIDDLE = 2,
MOUSE_BUTTON_RIGHT = 3
};
#ifdef __cplusplus
#include <cstdint>
extern "C" {
#else
#include <stdint.h>
#endif
typedef struct { int x, y; } mouse_pos_t;
// creates a window with given width, height and title, title can be utf8
window_t* window_create(int width, int height, const char* title);
// destroys the window
void window_destroy(window_t* s);
// polls window events, returns true if the window should close
bool window_pollevent(window_t* s);
// blits the given framebuffer to the window. must be the same size as the window and ARGB8888 format
void window_blit(window_t* s, const uint32_t* framebuffer);
// returns true if the given key is currently held down
bool window_is_key_down(window_t* s, int key_scancode);
// returns true if the given mouse button is currently held down
bool window_is_mouse_button_down(window_t* s, int button_index);
// gets the current mouse position in window coordinates
mouse_pos_t window_get_mouse_position(window_t* s);
#ifdef __cplusplus
}
#endif
#endif // WINDOW_H