55/*
66Index of this file:
77// [SECTION] includes
8- // [SECTION] binding apis
8+ // [SECTION] enums
99// [SECTION] implementations
1010*/
1111
@@ -15,6 +15,35 @@ Index of this file:
1515
1616#include "pilotlight.h"
1717
18+ //-----------------------------------------------------------------------------
19+ // [SECTION] enums
20+ //-----------------------------------------------------------------------------
21+
22+ plPythonIntConstantPair gatDrawIntPairs [] = {
23+
24+ // plDrawFlags
25+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_NONE ),
26+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_DEPTH_TEST ),
27+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_DEPTH_WRITE ),
28+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_CULL_FRONT ),
29+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_CULL_BACK ),
30+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_FRONT_FACE_CW ),
31+ PL_ADD_INT_CONSTANT (PL_DRAW_FLAG_REVERSE_Z_DEPTH ),
32+
33+ // plDrawRectFlags
34+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_NONE ),
35+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_TOP_LEFT ),
36+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_TOP_RIGHT ),
37+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_BOTTOM_LEFT ),
38+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_BOTTOM_RIGHT ),
39+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_NONE ),
40+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_TOP ),
41+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_BOTTOM ),
42+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_LEFT ),
43+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_RIGHT ),
44+ PL_ADD_INT_CONSTANT (PL_DRAW_RECT_FLAG_ROUND_CORNERS_All )
45+ };
46+
1847//-----------------------------------------------------------------------------
1948// [SECTION] implementations
2049//-----------------------------------------------------------------------------
@@ -27,7 +56,9 @@ plDrawI_add_triangle_filled(PyObject* self, PyObject* args, PyObject* kwargs)
2756 PyObject * ptPythonP0 = NULL ;
2857 PyObject * ptPythonP1 = NULL ;
2958 PyObject * ptPythonP2 = NULL ;
30- uint32_t uColor = PL_COLOR_32_WHITE ;
59+ plDrawSolidOptions tOptions = {
60+ .uColor = PL_COLOR_32_WHITE
61+ };
3162
3263 static const char * apcKeywords [] = {
3364 "layer" ,
@@ -39,7 +70,7 @@ plDrawI_add_triangle_filled(PyObject* self, PyObject* args, PyObject* kwargs)
3970 };
4071
4172 if (!pl_parse ("OOOO|$I" , (const char * * )apcKeywords , args , kwargs , __FUNCTION__ ,
42- & ptPythonLayer , & ptPythonP0 , & ptPythonP1 , & ptPythonP2 , & uColor ))
73+ & ptPythonLayer , & ptPythonP0 , & ptPythonP1 , & ptPythonP2 , & tOptions . uColor ))
4374 return NULL ;
4475
4576 plDrawLayer2D * ptLayer = PyCapsule_GetPointer (ptPythonLayer , "plDrawLayer2D" );
@@ -48,7 +79,118 @@ plDrawI_add_triangle_filled(PyObject* self, PyObject* args, PyObject* kwargs)
4879 pl_get_vec2_from_python (ptPythonP0 ),
4980 pl_get_vec2_from_python (ptPythonP1 ),
5081 pl_get_vec2_from_python (ptPythonP2 ),
51- (plDrawSolidOptions ){.uColor = uColor });
82+ tOptions );
83+
84+ Py_RETURN_NONE ;
85+ }
86+
87+ PyObject *
88+ plDrawI_add_line (PyObject * self , PyObject * args , PyObject * kwargs )
89+ {
90+
91+ PyObject * ptPythonLayer = NULL ;
92+ PyObject * ptPythonP0 = NULL ;
93+ PyObject * ptPythonP1 = NULL ;
94+
95+ plDrawLineOptions tOptions = {
96+ .uColor = PL_COLOR_32_WHITE ,
97+ .fThickness = 1.0f
98+ };
99+
100+ static const char * apcKeywords [] = {
101+ "layer" ,
102+ "p0" ,
103+ "p1" ,
104+ "uColor" ,
105+ "thickness" ,
106+ NULL ,
107+ };
108+
109+ if (!pl_parse ("OOO|$If" , (const char * * )apcKeywords , args , kwargs , __FUNCTION__ ,
110+ & ptPythonLayer , & ptPythonP0 , & ptPythonP1 , & tOptions .uColor , & tOptions .fThickness ))
111+ return NULL ;
112+
113+ plDrawLayer2D * ptLayer = PyCapsule_GetPointer (ptPythonLayer , "plDrawLayer2D" );
114+
115+ gptDraw -> add_line (ptLayer ,
116+ pl_get_vec2_from_python (ptPythonP0 ),
117+ pl_get_vec2_from_python (ptPythonP1 ),
118+ tOptions );
119+
120+ Py_RETURN_NONE ;
121+ }
122+
123+ PyObject *
124+ plDrawI_add_triangle (PyObject * self , PyObject * args , PyObject * kwargs )
125+ {
126+
127+ PyObject * ptPythonLayer = NULL ;
128+ PyObject * ptPythonP0 = NULL ;
129+ PyObject * ptPythonP1 = NULL ;
130+ PyObject * ptPythonP2 = NULL ;
131+
132+ plDrawLineOptions tOptions = {
133+ .uColor = PL_COLOR_32_WHITE ,
134+ .fThickness = 1.0f
135+ };
136+
137+ static const char * apcKeywords [] = {
138+ "layer" ,
139+ "p0" ,
140+ "p1" ,
141+ "p2" ,
142+ "uColor" ,
143+ "thickness" ,
144+ NULL ,
145+ };
146+
147+ if (!pl_parse ("OOOO|$If" , (const char * * )apcKeywords , args , kwargs , __FUNCTION__ ,
148+ & ptPythonLayer , & ptPythonP0 , & ptPythonP1 , & ptPythonP2 , & tOptions .uColor , & tOptions .fThickness ))
149+ return NULL ;
150+
151+ plDrawLayer2D * ptLayer = PyCapsule_GetPointer (ptPythonLayer , "plDrawLayer2D" );
152+
153+ gptDraw -> add_triangle (ptLayer ,
154+ pl_get_vec2_from_python (ptPythonP0 ),
155+ pl_get_vec2_from_python (ptPythonP1 ),
156+ pl_get_vec2_from_python (ptPythonP2 ),
157+ tOptions );
158+
159+ Py_RETURN_NONE ;
160+ }
161+
162+ PyObject *
163+ plDrawI_add_rect (PyObject * self , PyObject * args , PyObject * kwargs )
164+ {
165+
166+ PyObject * ptPythonLayer = NULL ;
167+ PyObject * ptPythonP0 = NULL ;
168+ PyObject * ptPythonP1 = NULL ;
169+
170+ plDrawLineOptions tOptions = {
171+ .uColor = PL_COLOR_32_WHITE ,
172+ .fThickness = 1.0f
173+ };
174+
175+ static const char * apcKeywords [] = {
176+ "layer" ,
177+ "pMin" ,
178+ "pMax" ,
179+ "uColor" ,
180+ "thickness" ,
181+ NULL ,
182+ };
183+
184+ if (!pl_parse ("OOO|$If" , (const char * * )apcKeywords , args , kwargs , __FUNCTION__ ,
185+ & ptPythonLayer , & ptPythonP0 , & ptPythonP1 , & tOptions .uColor , & tOptions .fThickness ))
186+ return NULL ;
187+
188+ plDrawLayer2D * ptLayer = PyCapsule_GetPointer (ptPythonLayer , "plDrawLayer2D" );
189+
190+ gptDraw -> add_rect (ptLayer ,
191+ pl_get_vec2_from_python (ptPythonP0 ),
192+ pl_get_vec2_from_python (ptPythonP1 ),
193+ tOptions );
52194
53195 Py_RETURN_NONE ;
54196}
0 commit comments