@@ -18,6 +18,7 @@ class App:
1818
1919 def __init__ (self ):
2020 self .ptWindow = None
21+ self .ptFont = None
2122
2223 # -------------------------------------------------------------------------
2324 # Application lifetime
@@ -33,22 +34,22 @@ def pl_app_load(self):
3334 # Mount directories used by the shader system.
3435 # /shaders points at the Python package shader folder.
3536 # /shader-temp is where compiled/intermediate shader output can go.
36- pl_vfs_mount_directory ("/cache" , "cache" )
37- pl_vfs_mount_directory (
37+ plVfsI . mount_directory ("/cache" , "cache" )
38+ plVfsI . mount_directory (
3839 "/shaders" ,
3940 os .path .dirname (os .path .abspath (pl .__file__ )) + "/shaders"
4041 )
41- pl_vfs_mount_directory ("/shader-temp" , "shader-temp" )
42+ plVfsI . mount_directory ("/shader-temp" , "shader-temp" )
4243
4344 # Create and show the OS window.
4445 window_desc = plWindowDesc ()
45- window_desc .pcTitle = "Pilot Light Python - Drawing API Example"
46+ window_desc .pcTitle = "Pilot Light Python - Basic Example 0 "
4647 window_desc .iXPos = 100
4748 window_desc .iYPos = 100
4849 window_desc .uWidth = 1280
4950 window_desc .uHeight = 720
50- _ , self .ptWindow = pl_window_create (window_desc )
51- pl_window_show (self .ptWindow )
51+ _ , self .ptWindow = plWindowI . create (window_desc )
52+ plWindowI . show (self .ptWindow )
5253
5354 # Initialize the starter extension.
5455 # We explicitly disable the shader ext from the starter flags because
@@ -57,7 +58,7 @@ def pl_app_load(self):
5758 starter_flags &= ~ plStarterFlag .PL_STARTER_FLAGS_SHADER_EXT
5859 starter_flags |= plStarterFlag .PL_STARTER_FLAGS_MSAA
5960
60- pl_starter_initialize (self .ptWindow , starter_flags )
61+ plStarterI . initialize (self .ptWindow , starter_flags )
6162
6263 # Initialize shader system.
6364 # This is required even for simple drawing examples because the
@@ -72,27 +73,30 @@ def pl_app_load(self):
7273 | plShaderFlags .PL_SHADER_FLAGS_ALWAYS_COMPILE
7374 )
7475
75- pl_shader_initialize (shader_options )
76+ plShaderI . initialize (shader_options )
7677
7778 # Complete starter initialization after custom systems are ready.
78- pl_starter_finalize ()
79+ plStarterI .finalize ()
80+
81+ ptFontAtlas = plDrawI .get_current_font_atlas ()
82+ self .ptFont = plDrawI .get_first_font (ptFontAtlas )
7983
8084 def pl_app_shutdown (self ):
8185 """
8286 Called once when the app exits.
8387 Flush GPU work, clean up engine systems, then destroy the window.
8488 """
8589
86- pl_graphics_flush_device ( pl_starter_get_device ())
87- pl_starter_cleanup ()
88- pl_window_destroy (self .ptWindow )
90+ plGraphicsI . flush_device ( plStarterI . get_device ())
91+ plStarterI . cleanup ()
92+ plWindowI . destroy (self .ptWindow )
8993
9094 def pl_app_resize (self ):
9195 """
9296 Called when the window changes size.
9397 Let the starter extension rebuild any size-dependent resources.
9498 """
95- pl_starter_resize ()
99+ plStarterI . resize ()
96100
97101 # -------------------------------------------------------------------------
98102 # Per-frame update
@@ -105,31 +109,31 @@ def pl_app_update(self):
105109 """
106110
107111 # Begin the frame. If it returns False, skip rendering this frame.
108- if not pl_starter_begin_frame ():
112+ if not plStarterI . begin_frame ():
109113 return
110114
111115 # Foreground fgLayer is a convenient draw list for 2D overlay-style
112116 # rendering.
113- fgLayer = pl_starter_get_foreground_layer ()
117+ fgLayer = plStarterI . get_foreground_layer ()
114118
115119 # Outer frame
116- pl_draw_add_rect (
120+ plDrawI . add_rect (
117121 fgLayer ,
118122 [40.0 , 40.0 ],
119123 [1240.0 , 680.0 ],
120124 plDrawLineOptions (PL_COLOR_32_YELLOW , 2.0 )
121125 )
122126
123127 # Diagonal guide line
124- pl_draw_add_line (
128+ plDrawI . add_line (
125129 fgLayer ,
126130 [40.0 , 40.0 ],
127131 [1240.0 , 680.0 ],
128132 plDrawLineOptions (PL_COLOR_32_GREEN , 2.0 )
129133 )
130134
131135 # Rounded panel region
132- pl_draw_add_rect_rounded (
136+ plDrawI . add_rect_rounded (
133137 fgLayer ,
134138 [70.0 , 70.0 ],
135139 [500.0 , 300.0 ],
@@ -140,7 +144,7 @@ def pl_app_update(self):
140144 )
141145
142146 # Triangle outline
143- pl_draw_add_triangle (
147+ plDrawI . add_triangle (
144148 fgLayer ,
145149 [120.0 , 240.0 ],
146150 [240.0 , 120.0 ],
@@ -149,7 +153,7 @@ def pl_app_update(self):
149153 )
150154
151155 # Arbitrary quad outline
152- pl_draw_add_quad (
156+ plDrawI . add_quad (
153157 fgLayer ,
154158 [580.0 , 100.0 ],
155159 [760.0 , 120.0 ],
@@ -159,16 +163,30 @@ def pl_app_update(self):
159163 )
160164
161165 # Circle outline
162- pl_draw_add_circle (
166+ plDrawI . add_circle (
163167 fgLayer ,
164168 [930.0 , 180.0 ],
165169 70.0 ,
166170 0 , # segment count (0 = automatic/default)
167171 plDrawLineOptions (PL_COLOR_32_BLUE )
168172 )
169173
174+ # Lines
175+ plDrawI .add_lines (
176+ fgLayer ,
177+ [
178+ [1040.0 , 110.0 ],
179+ [1180.0 , 250.0 ],
180+ [1140.0 , 90.0 ]
181+ ],
182+ plDrawLineOptions (PL_COLOR_32_GREEN )
183+ )
184+
185+ # text
186+ plDrawI .add_text (fgLayer , [300 , 300 ], "Hello Python" , plDrawTextOptions (self .ptFont , 25.0 , PL_COLOR_32_CYAN ))
187+
170188 # Polygon outline
171- pl_draw_add_polygon (
189+ plDrawI . add_polygon (
172190 fgLayer ,
173191 [
174192 [1040.0 , 110.0 ],
@@ -181,7 +199,7 @@ def pl_app_update(self):
181199 plDrawLineOptions (PL_COLOR_32_RED )
182200 )
183201
184- pl_draw_add_bezier_quad (
202+ plDrawI . add_bezier_quad (
185203 fgLayer ,
186204 [120.0 , 420.0 ], # start
187205 [260.0 , 320.0 ], # control
@@ -191,7 +209,7 @@ def pl_app_update(self):
191209 )
192210
193211 # Cubic bezier with thicker line
194- pl_draw_add_bezier_cubic (
212+ plDrawI . add_bezier_cubic (
195213 fgLayer ,
196214 [120.0 , 560.0 ], # start
197215 [220.0 , 460.0 ], # control 1
@@ -202,7 +220,7 @@ def pl_app_update(self):
202220 )
203221
204222 # Filled triangle
205- pl_draw_add_triangle_filled (
223+ plDrawI . add_triangle_filled (
206224 fgLayer ,
207225 [640.0 , 420.0 ],
208226 [820.0 , 360.0 ],
@@ -211,21 +229,21 @@ def pl_app_update(self):
211229 )
212230
213231 # Filled-looking composition using multiple primitives
214- pl_draw_add_line (
232+ plDrawI . add_line (
215233 fgLayer ,
216234 [900.0 , 360.0 ],
217235 [1180.0 , 360.0 ],
218236 plDrawLineOptions (PL_COLOR_32_WHITE , 4.0 )
219237 )
220238
221- pl_draw_add_rect (
239+ plDrawI . add_rect (
222240 fgLayer ,
223241 [920.0 , 390.0 ],
224242 [1160.0 , 560.0 ],
225243 plDrawLineOptions (PL_COLOR_32_WHITE , 3.0 )
226244 )
227245
228- pl_draw_add_circle (
246+ plDrawI . add_circle (
229247 fgLayer ,
230248 [1040.0 , 475.0 ],
231249 50.0 ,
@@ -234,7 +252,7 @@ def pl_app_update(self):
234252 )
235253
236254 # Submit/present the frame.
237- pl_starter_end_frame ()
255+ plStarterI . end_frame ()
238256
239257
240258# Run the application.
0 commit comments