2023-08-19 12:49:23 +00:00
|
|
|
/************************************************************/ /**
|
2023-03-05 15:05:43 +00:00
|
|
|
*
|
2023-08-14 08:26:11 +00:00
|
|
|
* @file: app_internal.h
|
2023-03-05 15:05:43 +00:00
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 23/12/2022
|
|
|
|
* @revision:
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
2023-08-14 08:26:11 +00:00
|
|
|
#ifndef __APP_INTERNAL_H_
|
|
|
|
#define __APP_INTERNAL_H_
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "app.h"
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "platform/platform.h"
|
2023-08-30 14:45:56 +00:00
|
|
|
#include "platform/platform_io_internal.h"
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "util/ringbuffer.h"
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#if OC_PLATFORM_WINDOWS
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "win32_app.h"
|
2023-08-14 08:26:11 +00:00
|
|
|
#elif OC_PLATFORM_MACOS
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "osx_app.h"
|
2023-03-05 15:05:43 +00:00
|
|
|
#else
|
2023-08-19 12:49:23 +00:00
|
|
|
#error "platform not supported yet"
|
2023-03-05 15:05:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
// Window structure
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
typedef struct oc_frame_stats
|
2023-03-05 15:05:43 +00:00
|
|
|
{
|
2023-08-19 12:49:23 +00:00
|
|
|
f64 start;
|
|
|
|
f64 workTime;
|
|
|
|
f64 remainingTime;
|
|
|
|
f64 targetFramePeriod;
|
2023-08-14 08:26:11 +00:00
|
|
|
} oc_frame_stats;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
typedef struct oc_window_data
|
2023-03-05 15:05:43 +00:00
|
|
|
{
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_list_elt freeListElt;
|
|
|
|
u32 generation;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_window_style style;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
bool shouldClose; //TODO could be in status flags
|
|
|
|
bool hidden;
|
|
|
|
bool minimized;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
OC_PLATFORM_WINDOW_DATA
|
2023-08-14 08:26:11 +00:00
|
|
|
} oc_window_data;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
// Global App State
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
typedef struct oc_key_utf8
|
2023-04-19 09:28:20 +00:00
|
|
|
{
|
2023-08-19 12:49:23 +00:00
|
|
|
u8 labelLen;
|
|
|
|
char label[8];
|
2023-08-14 08:26:11 +00:00
|
|
|
} oc_key_utf8;
|
2023-04-19 09:28:20 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
OC_APP_MAX_WINDOWS = 128
|
|
|
|
};
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
typedef struct oc_app
|
2023-03-05 15:05:43 +00:00
|
|
|
{
|
2023-08-19 12:49:23 +00:00
|
|
|
bool init;
|
|
|
|
bool shouldQuit;
|
|
|
|
bool minimized;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_str8 pendingPathDrop;
|
|
|
|
oc_arena eventArena;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_ringbuffer eventQueue;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_frame_stats frameStats;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_window_data windowPool[OC_APP_MAX_WINDOWS];
|
|
|
|
oc_list windowFreeList;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_live_resize_callback liveResizeCallback;
|
|
|
|
void* liveResizeData;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
oc_key_utf8 keyLabels[512];
|
|
|
|
int keyCodes[512];
|
|
|
|
int nativeKeys[OC_KEY_COUNT];
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
OC_PLATFORM_APP_DATA
|
2023-08-14 08:26:11 +00:00
|
|
|
} oc_app;
|
2023-03-05 15:05:43 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#endif // __APP_INTERNAL_H_
|