Browse Source

Add window title and size to SDL

RelativeDependencies
Macoy Madson 9 months ago
parent
commit
c3e921f9da
  1. 21
      src/SDL.cake
  2. 2
      test/src/SDLOgreApp.cake
  3. 2
      test/src/VocalGame.cake

21
src/SDL.cake

@ -14,14 +14,18 @@
(printf "SDL_Error: %s\n" (SDL_GetError)))
;; This supports drawing using SDL functions
(defun sdl-initialize-for-2d (window-out (* (* SDL_Window)) &return bool)
(defun sdl-initialize-for-2d (window-out (* (* SDL_Window))
title (* (const char))
width int height int
&return bool)
(when (< (SDL_Init (bit-or SDL_INIT_VIDEO SDL_INIT_AUDIO SDL_INIT_TIMER)) 0)
(sdl-print-error)
(return false))
(set (deref window-out)
(SDL_CreateWindow "Gamelib"
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED 1920 1080
(SDL_CreateWindow title
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED
width height
(bit-or SDL_WINDOW_RESIZABLE)))
(unless (deref window-out)
(sdl-print-error)
@ -30,7 +34,10 @@
(return true))
;; This is the OpenGL version, which may not support SDL drawing functions, only OpenGL
(defun sdl-initialize-for-3d (window-out (* (* SDL_Window)) &return bool)
(defun sdl-initialize-for-3d (window-out (* (* SDL_Window))
title (* (const char))
width int height int
&return bool)
(when (< (SDL_Init (bit-or SDL_INIT_VIDEO SDL_INIT_AUDIO SDL_INIT_TIMER)) 0)
(sdl-print-error)
(return false))
@ -42,8 +49,8 @@
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 6)
(set (deref window-out)
(SDL_CreateWindow "Gamelib"
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED 1920 1080
(SDL_CreateWindow title
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED width height
(bit-or SDL_WINDOW_RESIZABLE SDL_WINDOW_OPENGL)))
(unless (deref window-out)
(sdl-print-error)
@ -102,7 +109,7 @@
(defun test--sdl-main (&return int)
(printf "Hello, SDL!\n")
(var window (* SDL_Window) null)
(unless (sdl-initialize-for-2d (addr window)) (return 1))
(unless (sdl-initialize-for-2d (addr window) "GameLib" 640 480) (return 1))
;; (var window-surface (* SDL_Surface) (SDL_GetWindowSurface window))

2
test/src/SDLOgreApp.cake

@ -13,7 +13,7 @@
(defun main (&return int)
(var window (* SDL_Window) null)
(unless (sdl-initialize-for-3d (addr window))
(unless (sdl-initialize-for-3d (addr window) "SDL + Ogre" 1920 1080)
(return 1))
;; Ogre uses exceptions for error handling, so we can't gracefully close without getting all that
;; stuff set up (which I don't really want to do; it belongs in Gamelib)

2
test/src/VocalGame.cake

@ -371,7 +371,7 @@
(scope-timed
"SDL initialization"
;; (defun main (&return int)
(unless (sdl-initialize-for-3d (addr g-window))
(unless (sdl-initialize-for-3d (addr g-window) "Vocal Game" 1920 1080)
(TracyCZoneEnd startup-zone)
(return 1))))

Loading…
Cancel
Save