|
|
@ -27,6 +27,31 @@ |
|
|
|
(fprintf stderr (token-splice format))))) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
(defun-local render-string (renderer (* SDL_Renderer) font (* font-atlas) font-texture (* SDL_Texture) |
|
|
|
x int y int str (* (const char))) |
|
|
|
(var write-x int x) |
|
|
|
(var write-y int y) |
|
|
|
(each-char-in-string-const str current-char |
|
|
|
(var search-key char (deref current-char)) |
|
|
|
(var glyph (* glyph-entry) (dict-ptr-at (path font > glyph-lookup-table) search-key)) |
|
|
|
(unless glyph ;; fallback |
|
|
|
(set search-key '?') |
|
|
|
(set glyph (dict-ptr-at (path font > glyph-lookup-table) search-key))) |
|
|
|
(unless glyph ;; even the fallback is missing! |
|
|
|
(continue)) |
|
|
|
(var source-rectangle SDL_Rect |
|
|
|
(array (path glyph > x) |
|
|
|
(path glyph > y) |
|
|
|
(path glyph > width) |
|
|
|
(path glyph > height))) |
|
|
|
(var destination-rectangle SDL_Rect |
|
|
|
(array write-x write-y |
|
|
|
(path glyph > width) |
|
|
|
(path glyph > height))) |
|
|
|
(SDL_RenderCopy renderer font-texture |
|
|
|
(addr source-rectangle) (addr destination-rectangle)) |
|
|
|
(set write-x (+ write-x (path glyph > width))))) |
|
|
|
|
|
|
|
(defun main (&return int) |
|
|
|
(data-bundle-load-all-resources) |
|
|
|
|
|
|
@ -100,6 +125,9 @@ |
|
|
|
(sdl-print-error) |
|
|
|
(set exit-reason "SDL failed to render font atlas"))) |
|
|
|
|
|
|
|
(render-string renderer (addr ubuntu-regular-font-atlas) ubuntu-regular-texture |
|
|
|
200 600 "This is a test!") |
|
|
|
|
|
|
|
(SDL_RenderPresent renderer) |
|
|
|
(SDL_UpdateWindowSurface window) |
|
|
|
|
|
|
@ -112,3 +140,9 @@ |
|
|
|
(when exit-reason |
|
|
|
(preslog "Exited reason: %s\n" exit-reason)) |
|
|
|
(return 0)) |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('Windows |
|
|
|
(set-cakelisp-option executable-output "Presentation.exe")) |
|
|
|
(true |
|
|
|
(set-cakelisp-option executable-output "presentation"))) |
|
|
|