diff --git a/.gitignore b/.gitignore index ccf6b34..b5c0bdc 100644 --- a/.gitignore +++ b/.gitignore @@ -64,8 +64,6 @@ test/data/Materials/Textures/*.dds test/data/Models/* -file-helper - imgui.ini UserData.bin @@ -75,8 +73,7 @@ UserData_TestWrite.cakedata # TODO Make this less general *.txt -autoTest - .vs/ -game-dev-environment \ No newline at end of file +presentation +Presentation.exe \ No newline at end of file diff --git a/src/FontAtlas.cake b/src/FontAtlas.cake index 7915c51..f53c21e 100644 --- a/src/FontAtlas.cake +++ b/src/FontAtlas.cake @@ -102,7 +102,7 @@ (return 1))) (var new-glyph-entry glyph-entry (array 0)) - (set (field new-glyph-entry key) 'g') + (set (field new-glyph-entry key) character) (set (field new-glyph-entry x) atlas-write-x) (set (field new-glyph-entry y) atlas-write-y) (set (field new-glyph-entry width) num-columns) diff --git a/src/Presentation.cake b/src/Presentation.cake index 401c2db..9ee2714 100644 --- a/src/Presentation.cake +++ b/src/Presentation.cake @@ -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")))