Skip to content

Commit 3264640

Browse files
committed
feat: add additional extension mvps
1 parent 7ca5e1f commit 3264640

File tree

15 files changed

+342
-15
lines changed

15 files changed

+342
-15
lines changed

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"defines": [
2323
"_DEBUG",
2424
"UNICODE",
25+
"PL_EXPERIMENTAL",
2526
"_UNICODE"
2627
],
2728
"windowsSdkVersion": "10.0.26100.0",

extensions/pl_dearimgui_ext_m.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,26 @@ plImgui_cleanup(PyObject* self, PyObject* args, PyObject* kwargs)
142142
}
143143

144144
PyObject*
145-
plImgui_test(PyObject* self, PyObject* args, PyObject* kwargs)
145+
plImGui_ShowDemoWindow(PyObject* self, PyObject* arg)
146146
{
147-
ImGui::ShowDemoWindow();
148-
ImPlot::ShowDemoWindow();
147+
bool* ptShow = NULL;
148+
if(!Py_IsNone(arg))
149+
{
150+
ptShow = (bool*)PyCapsule_GetPointer(arg, "pb");
151+
}
152+
ImGui::ShowDemoWindow(ptShow);
153+
Py_RETURN_NONE;
154+
}
155+
156+
PyObject*
157+
plImPlot_ShowDemoWindow(PyObject* self, PyObject* arg)
158+
{
159+
bool* ptShow = NULL;
160+
if(!Py_IsNone(arg))
161+
{
162+
ptShow = (bool*)PyCapsule_GetPointer(arg, "pb");
163+
}
164+
ImPlot::ShowDemoWindow(ptShow);
149165
Py_RETURN_NONE;
150166
}
151167

@@ -154,12 +170,15 @@ plImgui_test(PyObject* self, PyObject* args, PyObject* kwargs)
154170

155171
static PyMethodDef gatCommands[] =
156172
{
173+
// imgui
157174
PL_PYTHON_COMMAND(plImgui_initialize, METH_VARARGS | METH_KEYWORDS, NULL),
158175
PL_PYTHON_COMMAND(plImgui_new_frame, METH_VARARGS | METH_KEYWORDS, NULL),
159176
PL_PYTHON_COMMAND(plImgui_render, METH_VARARGS | METH_KEYWORDS, NULL),
160177
PL_PYTHON_COMMAND(plImgui_cleanup, METH_VARARGS | METH_KEYWORDS, NULL),
161-
PL_PYTHON_COMMAND(plImgui_test, METH_VARARGS | METH_KEYWORDS, NULL),
178+
PL_PYTHON_COMMAND(plImGui_ShowDemoWindow, METH_O, NULL),
162179

180+
// implot
181+
PL_PYTHON_COMMAND(plImPlot_ShowDemoWindow, METH_O, NULL),
163182

164183
{NULL, NULL, 0, NULL}
165184
};

extensions/pl_screen_log_ext_m.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
pl_stats_ext_m.c
3+
*/
4+
5+
/*
6+
Index of this file:
7+
// [SECTION] includes
8+
// [SECTION] binding apis
9+
// [SECTION] implementations
10+
*/
11+
12+
//-----------------------------------------------------------------------------
13+
// [SECTION] includes
14+
//-----------------------------------------------------------------------------
15+
16+
#include "pilotlight.h"
17+
18+
//-----------------------------------------------------------------------------
19+
// [SECTION] implementations
20+
//-----------------------------------------------------------------------------
21+
22+
PyObject*
23+
plScreenLogI_clear(PyObject* self)
24+
{
25+
gptScreenLog->clear();
26+
Py_RETURN_NONE;
27+
}
28+
29+
PyObject*
30+
plScreenLogI_add_message(PyObject* self, PyObject* args)
31+
{
32+
static const char* apcKeywords[] = {
33+
"time_to_display",
34+
"message",
35+
NULL,
36+
};
37+
38+
double dTimeToDisplay = 0.0;
39+
const char* pcMessage = NULL;
40+
if (!pl_parse("ds", (const char**)apcKeywords, args, NULL, __FUNCTION__,
41+
&dTimeToDisplay, &pcMessage))
42+
return NULL;
43+
44+
gptScreenLog->add_message(dTimeToDisplay, pcMessage);
45+
Py_RETURN_NONE;
46+
}

extensions/pl_stats_ext_m.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
pl_stats_ext_m.c
3+
*/
4+
5+
/*
6+
Index of this file:
7+
// [SECTION] includes
8+
// [SECTION] binding apis
9+
// [SECTION] implementations
10+
*/
11+
12+
//-----------------------------------------------------------------------------
13+
// [SECTION] includes
14+
//-----------------------------------------------------------------------------
15+
16+
#include "pilotlight.h"
17+
18+
//-----------------------------------------------------------------------------
19+
// [SECTION] implementations
20+
//-----------------------------------------------------------------------------
21+
22+
PyObject*
23+
plStatsI_new_frame(PyObject* self)
24+
{
25+
gptStats->new_frame();
26+
Py_RETURN_NONE;
27+
}
28+
29+
PyObject*
30+
plStatsI_get_counter(PyObject* self, PyObject* arg)
31+
{
32+
const char* pcName = PyUnicode_AsUTF8(arg);
33+
double* pdCounter = gptStats->get_counter(pcName);
34+
return PyCapsule_New(pdCounter, "pd", NULL);
35+
}

extensions/pl_ui_ext_m.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,34 @@ plUiI_button(PyObject* self, PyObject* args, PyObject* kwargs)
5959
return NULL;
6060

6161
return PyBool_FromLong(gptUI->button(pcText));
62+
}
63+
64+
PyObject*
65+
plUiI_checkbox(PyObject* self, PyObject* args, PyObject* kwargs)
66+
{
67+
68+
static const char* apcKeywords[] = {
69+
"name",
70+
"value",
71+
"pointer",
72+
NULL,
73+
};
74+
75+
const char* pcName = NULL;
76+
int iValue = 0;
77+
PyObject* ptPointer = NULL;
78+
if (!pl_parse("sp|$O", (const char**)apcKeywords, args, kwargs, __FUNCTION__,
79+
&pcName, &iValue, &ptPointer))
80+
return NULL;
81+
82+
if(ptPointer)
83+
{
84+
return PyBool_FromLong(gptUI->checkbox(pcName, (bool*)PyCapsule_GetPointer(ptPointer, "pb")));
85+
}
86+
else
87+
{
88+
bool bValue = iValue;
89+
bool bResult = gptUI->checkbox(pcName, &bValue);
90+
return Py_BuildValue("(pp)", bResult, bValue);
91+
}
6292
}

pilotlight/pl_core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def __init__(self):
4444
# [SECTION] apis
4545
########################################################################################################################
4646

47+
class plCoreI:
48+
49+
def get_pointer_value(pointer):
50+
return internal.get_pointer_value(pointer)
51+
52+
def set_pointer_value(pointer, value):
53+
return internal.set_pointer_value(pointer, value)
54+
55+
def create_bool_pointer():
56+
return internal.create_bool_pointer()
57+
58+
def destroy_bool_pointer(pointer):
59+
return internal.destroy_bool_pointer(pointer)
60+
4761
class plIOI:
4862

4963
def get_version_string() -> str:

pilotlight/pl_dearimgui_ext.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import List, Any, Callable, Union, Tuple
22
import pilotlight.imgui as imgui
33

4-
54
class plDearImGuiI:
65

76
def initialize(device, swapchain, renderpass_handle, **kwargs) -> None:
@@ -15,3 +14,13 @@ def render(encoder, **kwargs) -> None:
1514

1615
def cleanup(**kwargs) -> None:
1716
return imgui.plImgui_cleanup(**kwargs)
17+
18+
class ImGui:
19+
20+
def ShowDemoWindow(bool_pointer = None) -> None:
21+
return imgui.plImGui_ShowDemoWindow(bool_pointer)
22+
23+
class ImPlot:
24+
25+
def ShowDemoWindow(bool_pointer = None) -> None:
26+
return imgui.plImPlot_ShowDemoWindow(bool_pointer)

pilotlight/pl_screen_log_ext.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
########################################################################################################################
2+
# User API Index
3+
#
4+
# * Sections
5+
# - imports
6+
# - types
7+
# - apis
8+
# - enums
9+
#
10+
########################################################################################################################
11+
12+
########################################################################################################################
13+
# [SECTION] imports
14+
########################################################################################################################
15+
16+
import pilotlight.pilotlight as internal
17+
18+
########################################################################################################################
19+
# [SECTION] apis
20+
########################################################################################################################
21+
22+
class plScreenLogI:
23+
24+
def clear():
25+
return internal.plScreenLogI_clear()
26+
27+
def add_message(time_to_display, message):
28+
return internal.plScreenLogI_add_message(time_to_display, message)
29+

pilotlight/pl_stats_ext.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
########################################################################################################################
2+
# User API Index
3+
#
4+
# * Sections
5+
# - imports
6+
# - types
7+
# - apis
8+
# - enums
9+
#
10+
########################################################################################################################
11+
12+
########################################################################################################################
13+
# [SECTION] imports
14+
########################################################################################################################
15+
16+
import pilotlight.pilotlight as internal
17+
18+
########################################################################################################################
19+
# [SECTION] apis
20+
########################################################################################################################
21+
22+
class plStatsI:
23+
24+
def new_frame():
25+
return internal.plStatsI_new_frame()
26+
27+
def get_counter(name):
28+
return internal.plStatsI_get_counter(name)
29+

pilotlight/pl_ui_ext.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
class plUiI:
66

7+
def begin_window(name : str, **kwargs):
8+
return internal.plUiI_begin_window(name, **kwargs)
9+
710
def end_window(**kwargs) -> None:
811
return internal.plUiI_end_window(**kwargs)
912

10-
def button(name : str, **kwargs) -> None:
13+
def button(name : str, **kwargs):
1114
return internal.plUiI_button(name, **kwargs)
1215

13-
def begin_window(name : str, **kwargs) -> None:
14-
return internal.plUiI_begin_window(name, **kwargs)
15-
16+
def checkbox(name, value = None, **kwargs):
17+
return internal.plUiI_checkbox(name, value, **kwargs)

0 commit comments

Comments
 (0)