#pragma once

// ::Platform::Types::Header::

typedef enum Event_e Event_e;
typedef struct WindowEvent WindowEvent;
typedef struct WindowSize WindowSize;

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;
};

#if __linux__

typedef struct {
	void *lib;
} Library;

typedef struct {
	void *fn;
} Function;

#elif _WIN32

typedef struct 
{
	HMODULE module;
} Library;

typedef struct  
{
	FARPROC fn;
} Function;

#endif

// ::Platform::Includes::Header::

#if __linux__
#include "platform/platform_linux.h"
#endif

#if _WIN32
#include "platform/platform_windows.h"
#endif

#if __APPLE__ || __MACH__
#error Not yet implemented
#endif

#if __unix__ && !__linux__
#error Not yet implemented
#endif

// ::Platform::Functions::Header::

// ::Platform::Functions::Init::Header::

b32 LoadLib(const char *name, Library *out_lib);
b32 LoadFn(const char *name, Library *lib, Function *out_fn);

// ::Platform::Functions::Memory::Header::

rawptr MemAlloc(isize size);
rawptr MemAllocZeroed(isize size);
void MemFree(rawptr ptr, isize size);
isize GetPageSize();

// ::Platform::Functions::Print::Header::

i32 EPrint(void const *str);
i32 Printf(const char *fmt, ...);
i32 Printfln(const char *fmt, ...);
i32 EPrintf(const char *fmt, ...);

// ::Platform::Functions::Window::Header::

b32 CreatePlatformWindow(const char *window_name);
WindowSize GetWindowSize();
b32 ShouldQuit();
PlatformWindow *GetPlatformWindow();

// ::Platform::Functions::SystemInfo::Header::

u32 AvailableCPUCount();

// ::Platform::Functions::Directory::Header::

b32 ChangeWorkingDir(const char *);
u8 *OSOpenFile(const char *);
