Fortran · 1823 bytes Raw Blame History
1 program fortty
2 use window_mod
3 use gl_bindings
4 use renderer_mod
5 implicit none
6
7 type(window_t) :: win
8 type(renderer_t) :: ren
9 integer :: win_width, win_height
10 character(len=256) :: font_path
11
12 ! Window dimensions
13 win_width = 800
14 win_height = 600
15
16 ! Create window with OpenGL context
17 win = window_create(win_width, win_height, "fortty")
18
19 ! Font path - try common system locations
20 font_path = "/usr/share/fonts/TTF/DejaVuSansMono.ttf"
21
22 ! Create renderer with font
23 ren = renderer_create(trim(font_path), 24)
24 if (.not. ren%initialized) then
25 print *, "Warning: Could not load font, trying alternate path..."
26 font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"
27 ren = renderer_create(trim(font_path), 24)
28 end if
29
30 if (.not. ren%initialized) then
31 print *, "Error: Could not initialize renderer"
32 print *, "Please ensure DejaVu Sans Mono font is installed"
33 call window_destroy(win)
34 stop 1
35 end if
36
37 ! Set up projection matrix
38 call renderer_set_projection(ren, win_width, win_height)
39
40 ! Main event loop
41 do while (.not. window_should_close(win))
42 ! Clear screen with dark gray background
43 call glClearColor(0.1, 0.1, 0.12, 1.0)
44 call glClear(GL_COLOR_BUFFER_BIT)
45
46 ! Begin new frame
47 call renderer_begin(ren)
48
49 ! Draw test text
50 call renderer_draw_string(ren, 50.0, 100.0, "Hello, Fortran!", &
51 1.0, 1.0, 1.0, 1.0)
52
53 call renderer_draw_string(ren, 50.0, 150.0, "Terminal emulator in progress...", &
54 0.7, 0.7, 0.7, 1.0)
55
56 ! Flush to GPU
57 call renderer_flush(ren)
58
59 ! Swap buffers and poll events
60 call window_swap_buffers(win)
61 call window_poll_events()
62 end do
63
64 ! Cleanup
65 call renderer_destroy(ren)
66 call window_destroy(win)
67
68 end program fortty
69