2023-06-17 17:00:55 +00:00
|
|
|
#include "vn_platform.h"
|
|
|
|
#include "vn_platform.cpp"
|
|
|
|
|
2023-06-19 17:12:26 +00:00
|
|
|
#if VN_INTERNAL
|
|
|
|
|
|
|
|
struct debug_settings
|
|
|
|
{
|
|
|
|
b32 RenderUIDebugRects;
|
|
|
|
b32 RenderFPSCounter;
|
|
|
|
};
|
|
|
|
|
|
|
|
per_thread debug_settings *DEBUG_DebugSettings = 0;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2023-06-18 10:09:36 +00:00
|
|
|
#include "vn_config.h"
|
2023-06-19 17:12:26 +00:00
|
|
|
#include "vn_tokenizer.h"
|
2023-06-17 17:00:55 +00:00
|
|
|
#include "vn_font.h"
|
|
|
|
#include "vn_text_op.h"
|
|
|
|
#include "vn_ui.h"
|
|
|
|
#include "vn_workspace.h"
|
|
|
|
#include "vn_theme_dark.h"
|
|
|
|
#include "vn_animation_curve.h"
|
|
|
|
|
2023-06-18 10:09:36 +00:00
|
|
|
#include "vn_config.cpp"
|
2023-06-17 17:00:55 +00:00
|
|
|
#include "vn_render.cpp"
|
|
|
|
#include "vn_font.cpp"
|
|
|
|
#include "vn_ui.cpp"
|
|
|
|
#include "vn_ui_utils.cpp"
|
|
|
|
#include "vn_animation_curve.cpp"
|
|
|
|
#include "vn_workspace.cpp"
|
|
|
|
|
|
|
|
struct vn_state
|
|
|
|
{
|
2023-06-19 17:12:26 +00:00
|
|
|
memory_arena Arena;
|
|
|
|
glyph_atlas *GlyphAtlas;
|
|
|
|
|
|
|
|
config *Config;
|
|
|
|
|
|
|
|
ui UI;
|
|
|
|
workspace Workspace;
|
|
|
|
animation_curve_state AnimationCurveState;
|
|
|
|
|
|
|
|
#if VN_INTERNAL
|
|
|
|
debug_settings DebugSettings;
|
|
|
|
#endif
|
2023-06-17 17:00:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
VN_UPDATE_AND_RENDER(VN_UpdateAndRender)
|
|
|
|
{
|
2023-06-19 17:12:26 +00:00
|
|
|
SetThreadContext(ThreadContext);
|
|
|
|
Platform = Memory->PlatformAPI;
|
|
|
|
|
|
|
|
vn_state *State = Memory->State;
|
|
|
|
|
|
|
|
if(!Memory->State)
|
|
|
|
{
|
|
|
|
State = Memory->State = BootstrapPushStruct(vn_state, Arena);
|
|
|
|
|
|
|
|
State->GlyphAtlas = CreateGlyphAtlas(RenderCommands);
|
|
|
|
State->Config = BootstrapPushStruct(config, Arena);
|
|
|
|
|
|
|
|
// sixten: Setup config binds and load current config.
|
|
|
|
{
|
|
|
|
Config_BindS32(State->Config, StrLit("Platform/RefreshRate"), &Input->RefreshRate, 60);
|
|
|
|
#if VN_INTERNAL
|
|
|
|
Config_BindB32(State->Config, StrLit("Dev/RenderUIDebugRects"), &State->DebugSettings.RenderUIDebugRects, 0);
|
|
|
|
Config_BindB32(State->Config, StrLit("Dev/RenderFPSCounter"), &State->DebugSettings.RenderFPSCounter, 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Config_ReadFile(State->Config, StrLit("config.vn"));
|
|
|
|
}
|
|
|
|
|
|
|
|
Workspace_Init(&State->Workspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if VN_INTERNAL
|
|
|
|
DEBUG_DebugSettings = &State->DebugSettings;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
AnimationCurve_NewFrame(&State->AnimationCurveState, Input->dtForFrame);
|
|
|
|
UI_NewFrame(&State->UI, Input->EventList, Input->MouseP);
|
|
|
|
|
|
|
|
Workspace_Update(&State->Workspace, RenderCommands, Input, State->GlyphAtlas);
|
|
|
|
UI_SignalFromBox(UI_GetState()->ContainerNode); // sixten(TODO): Move elsewhere.
|
2023-06-17 17:00:55 +00:00
|
|
|
|
2023-06-19 17:12:26 +00:00
|
|
|
for(platform_event *Event = Input->EventList->First;
|
|
|
|
Event != 0;
|
|
|
|
Event = Event->Next)
|
|
|
|
{
|
|
|
|
if(Event->Type == PlatformEvent_WindowClose)
|
|
|
|
{
|
|
|
|
Config_WriteFile(State->Config);
|
|
|
|
Input->ExitRequested = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform_ConsumeEvent(Input->EventList, Event);
|
|
|
|
}
|
2023-06-17 17:00:55 +00:00
|
|
|
|
2023-06-19 17:12:26 +00:00
|
|
|
render_group Group = BeginRenderGroup(RenderCommands);
|
|
|
|
PushClear(&Group, V3(0.1, 0.1, 0.1));
|
2023-06-17 17:00:55 +00:00
|
|
|
|
2023-06-19 17:12:26 +00:00
|
|
|
UI_RenderFrame(&Group, State->GlyphAtlas);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|