Skip to content

Commit dc49a84

Browse files
WIP
1 parent 11e41dc commit dc49a84

File tree

8 files changed

+659
-214
lines changed

8 files changed

+659
-214
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sandbox/__pycache__/
1212
pilotlight/__pycache__/
1313
pilotlight/pilotlight.pyd
1414
pilotlight/pilotlight_d.pyd
15+
pilotlight/imgui.pyd
16+
pilotlight/imgui_d.pyd
1517
pilotlight/*.pdb
1618
pilotlight/*.dll
1719
pilotlight/*.so

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"${workspaceFolder}/../pilotlight/shaders",
1313
"${workspaceFolder}/../pilotlight/dependencies/stb",
1414
"${workspaceFolder}/../pilotlight/dependencies/cgltf",
15+
"${workspaceFolder}/../pilotlight/dependencies/imgui",
1516
"${workspaceFolder}/../pilotlight/dependencies/glfw/include",
1617
"${workspaceFolder}/dependencies/cpython",
1718
"${workspaceFolder}/dependencies/cpython/Include",

extensions/pl_starter_ext_m.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,41 @@ plStarterI_get_background_layer(PyObject* self, PyObject* args, PyObject* kwargs
9090
return PyCapsule_New(ptBGLayer, "plDrawLayer2D", NULL);
9191
}
9292

93+
PyObject*
94+
plStarterI_get_device(PyObject* self, PyObject* args, PyObject* kwargs)
95+
{
96+
plDevice* ptDevice = gptStarter->get_device();
97+
return PyCapsule_New(ptDevice, "plDevice", NULL);
98+
}
99+
100+
PyObject*
101+
plStarterI_get_swapchain(PyObject* self, PyObject* args, PyObject* kwargs)
102+
{
103+
plSwapchain* ptSwapchain = gptStarter->get_swapchain();
104+
return PyCapsule_New(ptSwapchain, "plSwapchain", NULL);
105+
}
106+
107+
PyObject*
108+
plStarterI_get_render_pass(PyObject* self, PyObject* args, PyObject* kwargs)
109+
{
110+
plRenderPassHandle tHandle = gptStarter->get_render_pass();
111+
return Py_BuildValue("K", tHandle.uData);
112+
}
113+
114+
PyObject*
115+
plStarterI_begin_main_pass(PyObject* self, PyObject* args, PyObject* kwargs)
116+
{
117+
plRenderEncoder* ptEncoder = gptStarter->begin_main_pass();
118+
return PyCapsule_New(ptEncoder, "plRenderEncoder", NULL);
119+
}
120+
121+
PyObject*
122+
plStarterI_end_main_pass(PyObject* self, PyObject* args, PyObject* kwargs)
123+
{
124+
gptStarter->end_main_pass();
125+
Py_RETURN_NONE;
126+
}
127+
93128
plPythonIntConstantPair gatStarterIntPairs[] = {
94129
PL_ADD_INT_CONSTANT(PL_STARTER_FLAGS_NONE),
95130
PL_ADD_INT_CONSTANT(PL_STARTER_FLAGS_DRAW_EXT),

pilotlight/pl_starter_ext.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ def get_foreground_layer(**kwargs) -> None:
3131

3232
def get_background_layer(**kwargs) -> None:
3333
return internal.plStarterI_get_background_layer(**kwargs)
34+
35+
def get_device(**kwargs) -> None:
36+
return internal.plStarterI_get_device(**kwargs)
37+
38+
def get_swapchain(**kwargs) -> None:
39+
return internal.plStarterI_get_swapchain(**kwargs)
40+
41+
def get_render_pass(**kwargs) -> None:
42+
return internal.plStarterI_get_render_pass(**kwargs)
43+
44+
def begin_main_pass(**kwargs) -> None:
45+
return internal.plStarterI_begin_main_pass(**kwargs)
46+
47+
def end_main_pass(**kwargs) -> None:
48+
return internal.plStarterI_end_main_pass(**kwargs)
3449

3550
########################################################################################################################
3651
# [SECTION] enums

sandbox/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# core
22
import pilotlight.pilotlight as pl
3+
import pilotlight.imgui as imgui
34

45
# core apis
56
from pilotlight.pl_core import plIOI
@@ -41,6 +42,8 @@ def pl_app_load(self):
4142

4243
plStarterI.finalize()
4344

45+
imgui.plImgui_initialize(plStarterI.get_device(), plStarterI.get_swapchain(), plStarterI.get_render_pass())
46+
4447
# mod = plShaderI.load_glsl("draw_3d.frag", "main")
4548
# plShaderI.write_to_disk("C:/dev/pilotlight-python/sandbox/blah.spv", mod)
4649

@@ -63,6 +66,9 @@ def pl_app_update(self):
6366
if not plStarterI.begin_frame():
6467
return
6568

69+
imgui.plImgui_new_frame(plStarterI.get_device(), plStarterI.get_render_pass())
70+
imgui.plImgui_test()
71+
6672
# drawing API
6773
fgLayer = plStarterI.get_foreground_layer()
6874
plDrawI.add_triangle_filled(fgLayer, [50.0, 100.0], [200.0, 0.0], [100.0, 200.0])
@@ -80,6 +86,12 @@ def pl_app_update(self):
8086

8187
plUiI.end_window()
8288

89+
render_encoder = plStarterI.begin_main_pass()
90+
91+
imgui.plImgui_render(render_encoder)
92+
93+
plStarterI.end_main_pass()
94+
8395
plStarterI.end_frame()
8496

8597
# run app

0 commit comments

Comments
 (0)