adding gfx and ui stuff
This commit is contained in:
91
gfx/platform.h
Normal file
91
gfx/platform.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#include "../core.h"
|
||||
|
||||
typedef struct OS_Input OS_Input;
|
||||
struct OS_Input {
|
||||
struct {
|
||||
bool escape;
|
||||
bool enter;
|
||||
bool space;
|
||||
bool lshift;
|
||||
bool x;
|
||||
bool y;
|
||||
bool z;
|
||||
bool w;
|
||||
} keyboard;
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
real32 x;
|
||||
real32 y;
|
||||
};
|
||||
Vec2 point;
|
||||
};
|
||||
struct {
|
||||
real64 dX;
|
||||
real64 dY;
|
||||
} scroll;
|
||||
bool btnLeft;
|
||||
bool btnRight;
|
||||
bool btnMiddle;
|
||||
} mouse;
|
||||
};
|
||||
|
||||
enum OS_WindowEventKind {
|
||||
OS_WindowEventKind_Resize,
|
||||
|
||||
// ---
|
||||
OS_WindowEventKind_Count,
|
||||
};
|
||||
|
||||
typedef struct OS_WindowEvent OS_WindowEvent;
|
||||
struct OS_WindowEvent {
|
||||
enum OS_WindowEventKind kind;
|
||||
union {
|
||||
struct {
|
||||
int32 width;
|
||||
int32 height;
|
||||
} resize;
|
||||
};
|
||||
};
|
||||
|
||||
struct OS_Window;
|
||||
typedef void (*OS_WindowEventCallback)(OS_WindowEvent *e, struct OS_Window *userData);
|
||||
|
||||
typedef struct OS_WindowInitParams OS_WindowInitParams;
|
||||
struct OS_WindowInitParams {
|
||||
string name;
|
||||
int32 width;
|
||||
int32 height;
|
||||
void *data;
|
||||
OS_WindowEventCallback eventHandler;
|
||||
};
|
||||
|
||||
typedef struct OS_Window OS_Window;
|
||||
struct OS_Window {
|
||||
void *handle;
|
||||
int32 width;
|
||||
int32 height;
|
||||
real64 fps;
|
||||
void *userData;
|
||||
void *platformData;
|
||||
struct {
|
||||
real64 start;
|
||||
real64 fps;
|
||||
} frame;
|
||||
};
|
||||
|
||||
|
||||
DefineResult(OS_Window*, OS_WindowInit);
|
||||
OS_WindowInitResult os_windowInit(Arena *arena, OS_WindowInitParams params);
|
||||
bool os_windowShouldClose(OS_Window *window);
|
||||
void os_windowProcessEvents(OS_Window *window);
|
||||
void os_windowGetInput(OS_Window *window, OS_Input *input);
|
||||
void os_windowSwapBuffers(OS_Window *window);
|
||||
void os_windowFrameBegin(OS_Window *window);
|
||||
void os_windowFrameEnd(OS_Window *window);
|
||||
void os_windowTerminate(OS_Window *window);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user