diff --git a/.gitignore b/.gitignore
index ccf6b34..d1b828b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,4 +79,4 @@ autoTest
.vs/
-game-dev-environment
\ No newline at end of file
+vector-puppet-show
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 6bda7d1..312f101 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,12 @@
[submodule "Dependencies/gamelib"]
path = Dependencies/gamelib
url = gitea@macoy.me:macoy/gamelib.git
+[submodule "Dependencies/SDL"]
+ path = Dependencies/SDL
+ url = https://github.com/libsdl-org/SDL
+[submodule "Dependencies/stb"]
+ path = Dependencies/stb
+ url = https://macoy.me/code/macoy/stb
+[submodule "Dependencies/FreeType"]
+ path = Dependencies/FreeType
+ url = https://gitlab.freedesktop.org/freetype/freetype.git
diff --git a/Build.bat b/Build.bat
new file mode 100644
index 0000000..05dbd63
--- /dev/null
+++ b/Build.bat
@@ -0,0 +1,29 @@
+cd Dependencies\cakelisp
+call Build.bat
+@if %ERRORLEVEL% == 0 (
+ echo Successfully built Cakelisp
+ goto user
+) else (
+ echo Error while building cakelisp
+ goto fail
+)
+
+:user
+cd ../../
+"Dependencies\cakelisp\bin\cakelisp.exe" src/Config_Windows.cake src/VectorPuppetShow.cake
+@if %ERRORLEVEL% == 0 (
+ echo Success!
+ goto success
+) else (
+ echo Error while building user program
+ goto fail
+)
+
+:fail
+goto end
+
+:success
+goto end
+
+:end
+exit /B %ERRORLEVEL%
diff --git a/Build.sh b/Build.sh
index b79487d..8163e3a 100755
--- a/Build.sh
+++ b/Build.sh
@@ -9,10 +9,10 @@ cd $CAKELISP_DIR
cd ../..
-echo "\n\nGameLib Project\n\n"
+echo "\n\nVector Puppet Show\n\n"
CAKELISP=./Dependencies/cakelisp/bin/cakelisp
$CAKELISP --verbose-processes --execute \
src/Config_Linux.cake \
- src/Main.cake || exit $?
+ src/VectorPuppetShow.cake || exit $?
diff --git a/COPYING b/COPYING
index ec692e2..dcd8095 100644
--- a/COPYING
+++ b/COPYING
@@ -1,16 +1,16 @@
-Copyright (c) 2021 Macoy Madson
+Copyright (c) 2022 Macoy Madson
-This file is part of GameLib Project.
+This file is part of Vector Puppet Show.
-GameLib Project is free software: you can redistribute it and/or modify
+Vector Puppet Show is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-GameLib Project is distributed in the hope that it will be useful,
+Vector Puppet Show is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GameLib Project. If not, see .
\ No newline at end of file
+along with Vector Puppet Show. If not, see .
\ No newline at end of file
diff --git a/Dependencies/FreeType b/Dependencies/FreeType
new file mode 160000
index 0000000..33ceac2
--- /dev/null
+++ b/Dependencies/FreeType
@@ -0,0 +1 @@
+Subproject commit 33ceac2afc3608be2d12b3dece071a91e34c3062
diff --git a/Dependencies/SDL b/Dependencies/SDL
new file mode 160000
index 0000000..2e9f5b5
--- /dev/null
+++ b/Dependencies/SDL
@@ -0,0 +1 @@
+Subproject commit 2e9f5b5989c5140f47ce3ada603c1ae32d555f01
diff --git a/Dependencies/cakelisp b/Dependencies/cakelisp
new file mode 160000
index 0000000..d1aa08f
--- /dev/null
+++ b/Dependencies/cakelisp
@@ -0,0 +1 @@
+Subproject commit d1aa08f1bbc68856beb699374a5cd32274757e61
diff --git a/Dependencies/gamelib b/Dependencies/gamelib
new file mode 160000
index 0000000..35ee3b0
--- /dev/null
+++ b/Dependencies/gamelib
@@ -0,0 +1 @@
+Subproject commit 35ee3b08a3e4ef87a686ebcaa43c21734b06336f
diff --git a/Dependencies/stb b/Dependencies/stb
new file mode 160000
index 0000000..18a9ccb
--- /dev/null
+++ b/Dependencies/stb
@@ -0,0 +1 @@
+Subproject commit 18a9ccbbbbb179ab3d991afa79e60b48253e1597
diff --git a/ReadMe.org b/ReadMe.org
index 87ecb8b..48d27f2 100644
--- a/ReadMe.org
+++ b/ReadMe.org
@@ -1,3 +1,3 @@
-#+title: GameLib Project
+#+title: Vector Puppet Show
-This is a template repository for gamelib-based projects.
+This is an application which uses vector art assets to create skeletal animated "puppet shows", e.g. for visual novels and the like.
diff --git a/src/Config_Windows.cake b/src/Config_Windows.cake
new file mode 100644
index 0000000..95e756c
--- /dev/null
+++ b/src/Config_Windows.cake
@@ -0,0 +1,5 @@
+(comptime-define-symbol 'Windows)
+
+;; Debug
+(add-build-options-global "/Zi")
+(add-linker-options "/DEBUG")
diff --git a/src/Main.cake b/src/Main.cake
deleted file mode 100644
index 18d4a27..0000000
--- a/src/Main.cake
+++ /dev/null
@@ -1,7 +0,0 @@
-(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
-(add-cakelisp-search-directory "Dependencies/gamelib/src")
-(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
-(add-cakelisp-search-directory "src")
-
-(defun main (&return int)
- (return 0))
diff --git a/src/VectorPuppetShow.cake b/src/VectorPuppetShow.cake
new file mode 100644
index 0000000..a5ba6a6
--- /dev/null
+++ b/src/VectorPuppetShow.cake
@@ -0,0 +1,247 @@
+(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
+(set-cakelisp-option cakelisp-lib-dir "Dependencies/cakelisp/bin")
+(add-cakelisp-search-directory "Dependencies/gamelib/src")
+(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
+(add-cakelisp-search-directory "src")
+
+(import
+ ;; Cakelisp
+ "CHelpers.cake"
+ ;; GameLib
+ "Introspection.cake" "SDL.cake" "DynamicArray.cake" "Dictionary.cake" "DataBundle.cake"
+ "SDLFontAtlas.cake" "FreeType.cake")
+
+(c-import ""
+ &with-decls "")
+
+(bundle-file s-start-ubuntu-regular-font s-end-ubuntu-regular-font
+ (unsigned char) "data/Fonts/Ubuntu-R.ttf")
+
+(bundle-file s-start-ubuntu-mono-font s-end-ubuntu-mono-font
+ (unsigned char) "data/Fonts/UbuntuMono-R.ttf")
+
+(define-keybind s-quit-keybind (array SDL_SCANCODE_Q keybind-modifier-flags-ctrl))
+(define-keybind s-next-slide-keybind (array SDL_SCANCODE_RIGHT)
+ (array SDL_SCANCODE_DOWN)
+ (array SDL_SCANCODE_SPACE)
+ (array SDL_SCANCODE_RETURN)
+ (array SDL_SCANCODE_PAGEDOWN))
+(define-keybind s-previous-slide-keybind (array SDL_SCANCODE_LEFT)
+ (array SDL_SCANCODE_UP)
+ (array SDL_SCANCODE_BACKSPACE)
+ (array SDL_SCANCODE_PAGEUP))
+
+(define-keybind s-toggle-fullscreen-keybind (array SDL_SCANCODE_F11))
+
+(var s-key-states sdl-key-states (array 0))
+
+(defmacro vpslog (format string &optional &rest arguments any)
+ (if arguments
+ (scope
+ (tokenize-push output
+ (fprintf stderr (token-splice format) (token-splice-rest arguments tokens))))
+ (scope
+ (tokenize-push output
+ (fprintf stderr (token-splice format)))))
+ (return true))
+
+(comptime-cond
+ ('Windows
+ (c-import "")
+ (add-static-link-objects "User32.lib")))
+
+(defun main (&return int)
+ (comptime-cond
+ ('Windows
+ (SetProcessDpiAwarenessContext DPI_AWARENESS_CONTEXT_SYSTEM_AWARE)))
+ (data-bundle-load-all-resources)
+
+ (SDL_GL_SetAttribute SDL_GL_CONTEXT_MAJOR_VERSION 4)
+ (SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 6)
+ (SDL_SetHint SDL_HINT_RENDER_VSYNC "1")
+ (var window (addr SDL_Window) null)
+ (unless (sdl-initialize-for-2d (addr window) "Presentation" 1920 1080)
+ (vpslog "Failed to initialize SDL\n")
+ (return 1))
+ (defer (sdl-shutdown window))
+
+ ;; -1 = pick driver that is compatible with what we want
+ (var renderer (addr SDL_Renderer) (SDL_CreateRenderer window -1 SDL_RENDERER_ACCELERATED))
+ (unless renderer
+ (sdl-print-error)
+ (return 1))
+ (defer (SDL_DestroyRenderer renderer))
+
+ ;;
+ ;; Fonts
+ ;;
+
+ (var device-dpi (unsigned char) 144)
+ ;; 1 point = 1/72". Accurate if device-dpi is properly set
+
+ (defstruct font-atlas-texture
+ atlas font-atlas
+ texture (addr SDL_Texture)
+
+ ;; Only needed before it is built
+ start-file-data (addr (unsigned char))
+ end-file-data (addr (unsigned char))
+ font-size-points (unsigned char))
+ (var font-atlases (array font-atlas-texture)
+ (array
+ (array ;; Heading font, 1080p
+ (array 0) null
+ s-start-ubuntu-regular-font s-end-ubuntu-regular-font
+ 38)
+ (array ;; Body font, 1080p
+ (array 0) null
+ s-start-ubuntu-regular-font s-end-ubuntu-regular-font
+ 20)
+ (array ;; Body code font, 1080p
+ (array 0) null
+ s-start-ubuntu-mono-font s-end-ubuntu-mono-font
+ 20)
+
+ (array ;; Heading font, 4k
+ (array 0) null
+ s-start-ubuntu-regular-font s-end-ubuntu-regular-font
+ 58)
+ (array ;; Body font, 4k
+ (array 0) null
+ s-start-ubuntu-regular-font s-end-ubuntu-regular-font
+ 34)
+ (array ;; Body code font, 4k
+ (array 0) null
+ s-start-ubuntu-mono-font s-end-ubuntu-mono-font
+ 34)))
+ (var heading-font-index-1080p (const int) 0)
+ (var body-font-index-1080p (const int) 1)
+ (var body-code-font-index-1080p (const int) 2)
+ (var heading-font-index-4k (const int) 3)
+ (var body-font-index-4k (const int) 4)
+ (var body-code-font-index-4k (const int) 5)
+ (var heading-font-index int heading-font-index-1080p)
+ (var body-font-index int body-font-index-1080p)
+ (var body-code-font-index int body-code-font-index-1080p)
+
+ (defer
+ (each-item-addr-in-array font-atlases i font (addr font-atlas-texture)
+ (free-font-atlas (addr (path font > atlas)))
+ (when (path font > texture)
+ (SDL_DestroyTexture (path font > texture)))))
+
+ (each-item-addr-in-array font-atlases i font (addr font-atlas-texture)
+ (unless (make-font-atlas-and-texture renderer
+ (addr (path font > atlas))
+ (addr (path font > texture))
+ (path font > start-file-data)
+ (- (path font > end-file-data) (path font > start-file-data))
+ device-dpi
+ (path font > font-size-points))
+ (return 1)))
+
+
+ ;; current-key-states is owned by SDL, but we own last-frame-states
+ (defer (dynarray-free (field s-key-states last-frame-states)))
+
+ (var enable-fullscreen bool false)
+
+ (var exit-reason (addr (const char)) null)
+ (while true
+ (var event SDL_Event)
+ (while (SDL_PollEvent (addr event))
+ (when (= (field event type) SDL_QUIT)
+ (set exit-reason "Window event")))
+
+ (var num-keys int 0)
+ (set (field s-key-states this-frame-states) (SDL_GetKeyboardState (addr num-keys)))
+ (when (keybind-tapped (addr s-quit-keybind) (addr s-key-states))
+ (set exit-reason "Quit keybind pressed"))
+
+ (when (keybind-tapped (addr s-toggle-fullscreen-keybind) (addr s-key-states))
+ (set enable-fullscreen (not enable-fullscreen))
+ (if enable-fullscreen
+ (SDL_SetWindowFullscreen window SDL_WINDOW_FULLSCREEN_DESKTOP)
+ (SDL_SetWindowFullscreen window 0)))
+
+ (var true-window-width int 0)
+ (var true-window-height int 0)
+ (SDL_GetWindowSize window (addr true-window-width) (addr true-window-height))
+
+ ;; (if (> true-window-height 1440)
+ ;; (scope
+ ;; (unless upscale-to-4k
+ ;; (vpslog "Now upscaling 2x\n"))
+ ;; (set heading-font-index heading-font-index-4k)
+ ;; (set body-font-index body-font-index-4k)
+ ;; (set body-code-font-index body-code-font-index-4k)
+ ;; (set upscale-to-4k true))
+ ;; (scope
+ ;; (when upscale-to-4k
+ ;; (vpslog "No longer upscaling\n"))
+ ;; (set heading-font-index heading-font-index-1080p)
+ ;; (set body-font-index body-font-index-1080p)
+ ;; (set body-code-font-index body-code-font-index-1080p)
+ ;; (set upscale-to-4k false)))
+
+ ;; (var virtual-window-width int true-window-width)
+ ;; (var virtual-window-height int true-window-height)
+
+ ;; ;; We always master to 1080p in "game space". Text is all true window relative
+ ;; (when upscale-to-4k
+ ;; (set virtual-window-width 1920)
+ ;; (set virtual-window-height 1080))
+
+ (SDL_SetRenderDrawColor renderer 11 19 40 255)
+ (SDL_RenderClear renderer)
+
+ (render-string
+ renderer (addr (field (at heading-font-index font-atlases) atlas))
+ (field (at heading-font-index font-atlases) texture)
+ (/ true-window-width 4.5f) (/ true-window-height 8)
+ "This is a test string")
+
+
+ ;; (when s-enable-debug-overlay
+ ;; (var buffer (array 256 char) (array 0))
+ ;; (var mouse-x int 0)
+ ;; (var mouse-y int 0)
+ ;; (SDL_GetMouseState (addr mouse-x) (addr mouse-y))
+ ;; (snprintf buffer (- (array-size buffer) 1) "Mouse: %4d %4d Percent of window: %.2f %.2f Wizard relative: %4d %4d"
+ ;; mouse-x mouse-y
+ ;; (/ mouse-x (type-cast true-window-width float)) (/ mouse-y (type-cast true-window-height float))
+ ;; (- mouse-x (field g-wizard-hero x)) (- mouse-y (field g-wizard-hero y)))
+ ;; (render-string
+ ;; renderer (addr (field (at body-code-font-index font-atlases) atlas))
+ ;; (field (at body-code-font-index font-atlases) texture)
+ ;; 10 (- true-window-height 20)
+ ;; buffer))
+ ;; ;; #"#
+ ;; ;; result= FT_Set_Char_Size(typeface, 0, (16 * 64), 300, 300);
+ ;; ;; if (!((result== FT_Err_Ok)))
+ ;; ;; {
+ ;; ;; fprintf(stderr, "error: encountered error %d while %s\n", result, "setting character size");
+ ;; ;; FT_Done_Face(typeface);
+ ;; ;; FT_Done_FreeType(freetypeLibrary);
+ ;; ;; return 1;
+ ;; ;; }#"#)
+
+ (SDL_RenderPresent renderer)
+ (SDL_UpdateWindowSurface window)
+
+ (dynarray-set-length (field s-key-states last-frame-states) num-keys)
+ (memcpy (field s-key-states last-frame-states) (field s-key-states this-frame-states) num-keys)
+
+ (when exit-reason
+ (break)))
+
+ (when exit-reason
+ (vpslog "Exited reason: %s\n" exit-reason))
+ (return 0))
+
+(comptime-cond
+ ('Windows
+ (add-c-build-dependency "VectorPuppetShowWinMain.cpp")
+ (set-cakelisp-option executable-output "VectorPuppetShow.exe"))
+ (true
+ (set-cakelisp-option executable-output "vector-puppet-show")))
diff --git a/src/VectorPuppetShowWinMain.cpp b/src/VectorPuppetShowWinMain.cpp
new file mode 100644
index 0000000..19b5741
--- /dev/null
+++ b/src/VectorPuppetShowWinMain.cpp
@@ -0,0 +1,20 @@
+#define WIN32_LEAN_AND_MEAN
+#include
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int main();
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void waitForDebugger();
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
+{
+ return main();
+}