@@ -8,55 +8,59 @@ using FileIO
88using ImageIO
99using NeuralGraphicsGL
1010
11+ import NeuralGraphicsGL as NGL
12+
1113function main ()
12- NeuralGraphicsGL . init ()
13- context = NeuralGraphicsGL . Context (" でも" ; width= 1280 , height= 960 , resizable= false )
14- fb = NeuralGraphicsGL . Framebuffer (; width= 1280 , height= 960 )
15- screen = NeuralGraphicsGL . Screen ()
14+ NGL . init ()
15+ context = NGL . Context (" でも" ; width= 1280 , height= 960 , resizable= false )
16+ fb = NGL . Framebuffer (; width= 1280 , height= 960 )
17+ screen = NGL . Screen ()
1618
17- bbox = NeuralGraphicsGL. BBox (zeros (SVector{3 , Float32}), ones (SVector{3 , Float32}))
19+ bbox = NGL. BBox (zeros (SVector{3 , Float32}), ones (SVector{3 , Float32}))
20+ frustum = NGL. Frustum ()
1821 P = SMatrix {4, 4, Float32} (I)
1922 V = SMatrix {4, 4, Float32} (I)
2023
2124 delta_time = 0.0
2225 last_time = time ()
2326 elapsed_time = 0.0
2427
25- NeuralGraphicsGL . render_loop (context; destroy_context= false ) do
26- NeuralGraphicsGL . imgui_begin (context)
28+ NGL . render_loop (context; destroy_context= false ) do
29+ NGL . imgui_begin (context)
2730
28- NeuralGraphicsGL . bind (fb)
31+ NGL . bind (fb)
2932
30- NeuralGraphicsGL . enable_depth ()
31- NeuralGraphicsGL . set_clear_color (0.2 , 0.2 , 0.2 , 1.0 )
32- NeuralGraphicsGL . clear ()
33+ NGL . enable_depth ()
34+ NGL . set_clear_color (0.2 , 0.2 , 0.2 , 1.0 )
35+ NGL . clear ()
3336
3437 bmin = zeros (SVector{3 , Float32}) .- Float32 (delta_time) * 5f0
3538 bmax = ones (SVector{3 , Float32}) .- Float32 (delta_time) * 5f0
36- NeuralGraphicsGL. update_corners! (bbox, bmin, bmax)
37- NeuralGraphicsGL. draw (bbox, P, V)
39+ NGL. update_corners! (bbox, bmin, bmax)
40+ NGL. draw (bbox, P, V; color= SVector {4, Float32} (0f0 , 1f0 , 0f0 , 1f0 ))
41+ NGL. draw (frustum, V, P, V; color= SVector {4, Float32} (0f0 , 1f0 , 0f0 , 1f0 ))
3842
39- NeuralGraphicsGL . unbind (fb)
43+ NGL . unbind (fb)
4044
41- NeuralGraphicsGL . disable_depth ()
42- NeuralGraphicsGL . set_clear_color (0.0 , 0.0 , 0.0 , 1.0 )
43- NeuralGraphicsGL . clear (GL_COLOR_BUFFER_BIT)
45+ NGL . disable_depth ()
46+ NGL . set_clear_color (0.0 , 0.0 , 0.0 , 1.0 )
47+ NGL . clear (GL_COLOR_BUFFER_BIT)
4448
4549 screen_texture = fb[GL_COLOR_ATTACHMENT0]
46- drawed_data = NeuralGraphicsGL . get_data (screen_texture)
50+ drawed_data = NGL . get_data (screen_texture)
4751 save (" screen.png" , rotl90 (colorview (RGB{N0f8}, drawed_data)))
4852
4953 depth_texture = fb[GL_DEPTH_ATTACHMENT]
50- depth_data = NeuralGraphicsGL . get_data (depth_texture)[1 , :, :]
54+ depth_data = NGL . get_data (depth_texture)[1 , :, :]
5155 save (" depth.png" , rotl90 (colorview (Gray{Float32}, depth_data)))
5256
53- NeuralGraphicsGL . draw (screen, screen_texture)
57+ NGL . draw (screen, screen_texture)
5458
5559 CImGui. Begin (" UI" )
5660 CImGui. Text (" HI!" )
5761 CImGui. End ()
5862
59- NeuralGraphicsGL . imgui_end (context)
63+ NGL . imgui_end (context)
6064 glfwSwapBuffers (context. window)
6165 glfwPollEvents ()
6266
@@ -67,9 +71,9 @@ function main()
6771 false
6872 end
6973
70- NeuralGraphicsGL . delete! (bbox)
71- NeuralGraphicsGL . delete! (screen)
72- NeuralGraphicsGL . delete! (fb)
73- NeuralGraphicsGL . delete! (context)
74+ NGL . delete! (bbox)
75+ NGL . delete! (screen)
76+ NGL . delete! (fb)
77+ NGL . delete! (context)
7478end
7579main ()
0 commit comments