Browse Source

Added some helper functions to SDL and ImGui

master
Macoy Madson 9 months ago
parent
commit
32b521ce24
  1. 9
      src/ImGui.cake
  2. 13
      src/SDL.cake

9
src/ImGui.cake

@ -2,6 +2,7 @@
(c-import "imgui.h")
;; The main interface into imgui.
(defmacro imgui-call (function symbol &rest &optional arguments any)
(if arguments
(tokenize-push output
@ -10,6 +11,14 @@
(call (in ImGui (token-splice function)))))
(return true))
(defun imgui-do-tooltip (text (* (const char)) shortcut (* (const char)))
(when (imgui-call IsItemHovered)
(imgui-call BeginTooltip)
(imgui-call Text "%s" text)
(when shortcut
(imgui-call TextDisabled "%s" shortcut))
(imgui-call EndTooltip)))
;; When you just don't care about the details and want a ImGui window
(defmacro make-imgui-sdl-gl3-application (entry-point-name symbol
window-name string

13
src/SDL.cake

@ -73,6 +73,7 @@
;;
;; Graphics
;;
(defun sdl-list-2d-render-drivers (&return bool)
(var num-render-drivers int (SDL_GetNumRenderDrivers))
(unless num-render-drivers
@ -183,6 +184,18 @@
(SDL_Log "--- %s at %f seconds\n" label delta-time))
;;
;; Input
;;
(defun sdl-is-key-tapped-this-frame (key (unsigned int)
current-key-states (* (const (unsigned char)))
last-frame-key-states (* (const (unsigned char)))
&return bool)
(return (and key
(at key current-key-states)
(not (at key last-frame-key-states)))))
;;
;; Test
;;

Loading…
Cancel
Save