Gears-C/src/platform.h

74 lines
1.2 KiB
C

#pragma once
typedef enum Event_e Event_e;
typedef struct WindowEvent WindowEvent;
typedef struct WindowSize WindowSize;
#if __linux__
#include "platform_linux.h"
#endif
#if _WIN32
#include "platform_windows.h"
#endif
#if __APPLE__ || __MACH__
#error Not yet implemented
#endif
#if __unix__ && !__linux__
#error Not yet implemented
#endif
enum Event_e
{
EVENT_NONE = 0,
EVENT_QUIT,
EVENT_RESIZE,
EVENT_MINIMIZE,
EVENT_SHOW,
};
struct WindowSize
{
u16 w;
u16 h;
};
struct WindowEvent
{
union
{
WindowSize resize;
};
Event_e type;
};
// Init
b32 LoadLib(const char *name, Library *out_lib);
b32 LoadFn(const char *name, Library *lib, Function *out_fn);
b32 InitPlatform();
// Memory Functions
rawptr MemAlloc(isize size);
rawptr MemAllocZeroed(isize size);
isize GetPageSize();
// Print Functions
i32 EPrint(void const *str);
i32 Printf(const char *fmt, ...);
i32 Printfln(const char *fmt, ...);
i32 EPrintf(const char *fmt, ...);
// Window Functions
b32 CreatePlatformWindow();
b32 GetWindowEvent(WindowEvent *event);
void WaitForWindowEvent(WindowEvent *event);
WindowSize GetWindowSize();
b32 NeedWindowResize();
b32 ShouldQuit();
// Directory Functions
b32 ChangeWorkingDir(const char *);
u8 *OSOpenFile(const char *);