Skip to content

Commit

Permalink
fix: distributable build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan hoffstadt committed Nov 20, 2024
1 parent dcc7324 commit 8194665
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions extensions/pl_debug_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ pl_load_debug_ext(plApiRegistryI* ptApiRegistry, bool bReload)
gptUI = pl_get_api_latest(ptApiRegistry, plUiI);
gptProfile = pl_get_api_latest(ptApiRegistry, plProfileI);
gptLog = pl_get_api_latest(ptApiRegistry, plLogI);
gptIO = gptIOI->get_io();
// #endif

if(bReload)
Expand Down
1 change: 1 addition & 0 deletions extensions/pl_draw_backend_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ pl_load_draw_backend_ext(plApiRegistryI* ptApiRegistry, bool bReload)
gptStats = pl_get_api_latest(ptApiRegistry, plStatsI);
gptGfx = pl_get_api_latest(ptApiRegistry, plGraphicsI);
gptDraw = pl_get_api_latest(ptApiRegistry, plDrawI);
gptShader = pl_get_api_latest(ptApiRegistry, plShaderI);
const plDataRegistryI* ptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);

if(bReload)
Expand Down
2 changes: 1 addition & 1 deletion extensions/pl_draw_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -3619,12 +3619,12 @@ pl_load_draw_ext(plApiRegistryI* ptApiRegistry, bool bReload)

#ifndef PL_UNITY_BUILD
gptMemory = pl_get_api_latest(ptApiRegistry, plMemoryI);
gptFile = pl_get_api_latest(ptApiRegistry, plFileI);
#endif


const plDataRegistryI* ptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);


if(bReload)
gptDrawCtx = ptDataRegistry->get_data("plDrawContext");
else // first load
Expand Down
4 changes: 4 additions & 0 deletions extensions/pl_graphics_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,13 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
};
pl_set_api(ptApiRegistry, plGraphicsI, &tApi);

gptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);
gptThreads = pl_get_api_latest(ptApiRegistry, plThreadsI);
gptProfile = pl_get_api_latest(ptApiRegistry, plProfileI);
gptLog = pl_get_api_latest(ptApiRegistry, plLogI);
gptMemory = pl_get_api_latest(ptApiRegistry, plMemoryI);
gptIOI = pl_get_api_latest(ptApiRegistry, plIOI);
gptIO = gptIOI->get_io();

if(bReload)
{
Expand Down
6 changes: 3 additions & 3 deletions extensions/pl_renderer_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -4515,7 +4515,7 @@ pl_refr_render_scene(uint32_t uSceneHandle, uint32_t uViewHandle, plViewOptions

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~entity selection~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if(gptData->uClickedFrame == uFrameIdx)
if(gptData->uClickedFrame == uFrameIdx && uViewHandle == 0)
{
gptData->uClickedFrame = UINT32_MAX;
plTexture* ptTexture = gptGfx->get_texture(ptDevice, ptView->tPickTexture);
Expand All @@ -4532,7 +4532,7 @@ pl_refr_render_scene(uint32_t uSceneHandle, uint32_t uViewHandle, plViewOptions
}

bool bOwnMouse = gptUI->wants_mouse_capture();
if(!bOwnMouse && gptIOI->is_mouse_clicked(PL_MOUSE_BUTTON_RIGHT, false))
if(!bOwnMouse && gptIOI->is_mouse_clicked(PL_MOUSE_BUTTON_RIGHT, false) && uViewHandle == 0)
{
gptData->uClickedFrame = uFrameIdx;

Expand Down Expand Up @@ -6198,7 +6198,7 @@ pl_load_renderer_ext(plApiRegistryI* ptApiRegistry, bool bReload)
gptStats = pl_get_api_latest(ptApiRegistry, plStatsI);
gptImage = pl_get_api_latest(ptApiRegistry, plImageI);
gptJob = pl_get_api_latest(ptApiRegistry, plJobI);
gptProfile = pl_get_api_latest(ptApiRegistry, plJobI);
gptProfile = pl_get_api_latest(ptApiRegistry, plProfileI);
gptLog = pl_get_api_latest(ptApiRegistry, plLogI);

gptECS = pl_get_api_latest(ptApiRegistry, plEcsI);
Expand Down
15 changes: 13 additions & 2 deletions extensions/pl_script_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ pl_load_script(plApiRegistryI* ptApiRegistry, bool bReload)
.run = pl_script_run
};

ptApiRegistry->set_api("pl_script_camera", plScriptI_version, &tApi, sizeof(plScriptI));
#ifdef PL_CONFIG_DEBUG
ptApiRegistry->set_api("pl_script_camerad", plScriptI_version, &tApi, sizeof(plScriptI));
#endif
#ifdef PL_CONFIG_RELEASE
ptApiRegistry->set_api("pl_script_camera", plScriptI_version, &tApi, sizeof(plScriptI));
#endif
}

PL_EXPORT void
Expand All @@ -103,6 +108,12 @@ pl_unload_script(plApiRegistryI* ptApiRegistry, bool bReload)
if(bReload)
return;

const plScriptI* ptApi = ptApiRegistry->get_api("pl_script_camera", plScriptI_version);

#ifdef PL_CONFIG_DEBUG
const plScriptI* ptApi = ptApiRegistry->get_api("pl_script_camerad", plScriptI_version);
#endif
#ifdef PL_CONFIG_RELEASE
const plScriptI* ptApi = ptApiRegistry->get_api("pl_script_camera", plScriptI_version);
#endif
ptApiRegistry->remove_api(ptApi);
}
3 changes: 3 additions & 0 deletions extensions/pl_shader_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ pl_load_shader_ext(plApiRegistryI* ptApiRegistry, bool bReload)
};
pl_set_api(ptApiRegistry, plShaderI, &tApi);

gptFile = pl_get_api_latest(ptApiRegistry, plFileI);
gptMemory = pl_get_api_latest(ptApiRegistry, plMemoryI);

const plDataRegistryI* ptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);
if(bReload)
{
Expand Down
11 changes: 9 additions & 2 deletions extensions/pl_ui_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,15 +2583,22 @@ pl_load_ui_ext(plApiRegistryI* ptApiRegistry, bool bReload)
};
pl_set_api(ptApiRegistry, plUiI, &tApi);

gptMemory = pl_get_api_latest(ptApiRegistry, plMemoryI);
gptDraw = pl_get_api_latest(ptApiRegistry, plDrawI);
gptIOI = pl_get_api_latest(ptApiRegistry, plIOI);
gptIO = gptIOI->get_io();

const plDataRegistryI* ptDataRegistry = pl_get_api_latest(ptApiRegistry, plDataRegistryI);

if(bReload)
{
gptCtx = gptDataRegistry->get_data("plUiContext");
gptCtx = ptDataRegistry->get_data("plUiContext");
}
else // first load
{
static plUiContext tContext = {0};
gptCtx = &tContext;
gptDataRegistry->set_data("plUiContext", gptCtx);
ptDataRegistry->set_data("plUiContext", gptCtx);
}
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/pl_ui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Index of this file:
#define PL_DS_FREE(x) gptMemory->tracked_realloc((x), 0, __FILE__, __LINE__)
#endif

static const plDataRegistryI* gptDataRegistry = NULL;
// static const plDataRegistryI* gptDataRegistry = NULL;
static const plDrawI* gptDraw = NULL;
static const plIOI* gptIOI = NULL;
static plIO* gptIO = NULL;
Expand Down
3 changes: 3 additions & 0 deletions sandbox/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
gptNetwork = pl_get_api_latest(ptApiRegistry, plNetworkI);
gptString = pl_get_api_latest(ptApiRegistry, plStringInternI);
gptProfile = pl_get_api_latest(ptApiRegistry, plProfileI);
gptFile = pl_get_api_latest(ptApiRegistry, plFileI);

return ptEditorData;
}
Expand Down Expand Up @@ -83,6 +84,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
gptNetwork = pl_get_api_latest(ptApiRegistry, plNetworkI);
gptString = pl_get_api_latest(ptApiRegistry, plStringInternI);
gptProfile = pl_get_api_latest(ptApiRegistry, plProfileI);
gptFile = pl_get_api_latest(ptApiRegistry, plFileI);

gptProfile->begin_frame();

Expand Down Expand Up @@ -141,6 +143,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
.uRangeCount = 1
};
// ptEditorData->tDefaultFont = gptDraw->add_default_font();

ptEditorData->tDefaultFont = gptDraw->add_font_from_file_ttf(ptAtlas, tFontConfig0, "../data/pilotlight-assets-master/fonts/Cousine-Regular.ttf");

const plFontRange tIconRange = {
Expand Down
1 change: 1 addition & 0 deletions sandbox/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static const plMemoryI* gptMemory = NULL;
static const plNetworkI* gptNetwork = NULL;
static const plStringInternI* gptString = NULL;
static const plProfileI* gptProfile = NULL;
static const plFileI* gptFile = NULL;

#define PL_ALLOC(x) gptMemory->tracked_realloc(NULL, (x), __FILE__, __LINE__)
#define PL_REALLOC(x, y) gptMemory->tracked_realloc((x), (y), __FILE__, __LINE__)
Expand Down
3 changes: 2 additions & 1 deletion scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@
"pl_stats_ext",
"pl_string_intern_ext",
"pl_ui_ext",
"pl_unity_ext",
"app",
]

if debug_package:
for i in range(len(extensions)):
extensions[i] = extensions[i] + "d"

extensions.append("pl_unity_ext")

if os.path.isdir(target_directory):
shutil.rmtree(target_directory)

Expand Down

0 comments on commit 8194665

Please sign in to comment.