62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#ifndef PLATFORM
|
|
#define PLATFORM
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct Color {
|
|
uint8_t r, g, b;
|
|
} Color;
|
|
|
|
#define WHITE ((Color){255,255,255})
|
|
#define BLACK ((Color){0,0,0})
|
|
|
|
typedef enum Action {
|
|
Action_Backspace,
|
|
Action_Select,
|
|
Action_Next,
|
|
Action_Previous,
|
|
Count_Action
|
|
} Action;
|
|
|
|
bool ActionPressed(Action key);
|
|
bool InputGetNextPrintable(char const *out_key);
|
|
|
|
typedef struct Cell {
|
|
char character;
|
|
Color foreground;
|
|
Color background;
|
|
} Cell;
|
|
|
|
typedef struct Window {
|
|
int width;
|
|
int height;
|
|
Cell *cells;
|
|
} Window;
|
|
|
|
typedef struct PlatformState {
|
|
Window *prev;
|
|
Window *curr;
|
|
} PlatformState;
|
|
|
|
// Options for the backend. These options don't necessarily apply for all platforms.
|
|
typedef struct PlatformOpts {
|
|
float window_width_fraction; // decide the width of the window as a fraction of the total resolution. for gui backends
|
|
float window_height_fraction; // decide the height of the window as a fraction of the total resolution. for gui backends
|
|
} PlatformOpts;
|
|
|
|
PlatformOpts WindowCreateOptsDefault();
|
|
Window *WindowCreate(PlatformOpts opts);
|
|
void WindowClear(Window *window, Color color);
|
|
void WindowFlip(Window *window);
|
|
|
|
void PlatformInit(PlatformOpts opts);
|
|
int PlatformGetWidth();
|
|
int PlatformGetHeight();
|
|
|
|
// TODO: the platform layer would really update the keys being pressed, and
|
|
// receive a diff in the form of actions. print this line from here and change
|
|
// colors at these points.
|
|
|
|
#endif /* PLATFORM */
|