2024-09-24 14:55:41 +00:00
|
|
|
(import (scheme)
|
|
|
|
(chicken base)
|
|
|
|
(chicken foreign))
|
2024-10-08 22:41:17 +00:00
|
|
|
(import-syntax (sdl3 internal utilities))
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(foreign-declare "#include <SDL3/SDL_render.h>")
|
|
|
|
|
|
|
|
(define add-vulkan-render-semaphores
|
|
|
|
(foreign-lambda bool "SDL_AddVulkanRenderSemaphores"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
unsigned-int32 integer64 integer64))
|
|
|
|
|
|
|
|
(define convert-event-to-render-coordinates
|
|
|
|
(foreign-lambda bool "SDL_ConvertEventToRenderCoordinates"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
2024-10-08 22:41:17 +00:00
|
|
|
(c-pointer (union "SDL_Event"))))
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(define create-renderer
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Renderer"))
|
|
|
|
"SDL_CreateRenderer"
|
|
|
|
(c-pointer (struct "SDL_Window"))
|
|
|
|
c-string))
|
|
|
|
|
|
|
|
(define create-renderer-with-properties
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Renderer"))
|
|
|
|
"SDL_CreateRendererWithProperties"
|
|
|
|
unsigned-int32))
|
|
|
|
|
|
|
|
(define create-software-renderer
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Renderer"))
|
|
|
|
"SDL_CreateSoftwareRenderer"
|
|
|
|
(c-pointer (struct "SDL_Surface"))))
|
|
|
|
|
2024-10-08 22:41:17 +00:00
|
|
|
(define-sdl-const-values
|
2024-09-24 14:55:41 +00:00
|
|
|
textureaccess int
|
2024-10-08 22:41:17 +00:00
|
|
|
static streaming target)
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(define create-texture
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Texture"))
|
|
|
|
"SDL_CreateTexture"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(enum "SDL_PixelFormat")
|
|
|
|
(enum "SDL_TextureAccess")
|
|
|
|
int int))
|
|
|
|
|
|
|
|
(define create-texture-from-surface
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Texture"))
|
|
|
|
"SDL_CreateTextureFromSurface"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Surface"))))
|
|
|
|
|
|
|
|
(define create-texture-with-properties
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Texture"))
|
|
|
|
"SDL_CreateTextureWithProperties"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
unsigned-int32))
|
|
|
|
|
|
|
|
;; TODO: SDL_CreateWindowAndRenderer
|
|
|
|
|
|
|
|
(define destroy-renderer
|
|
|
|
(foreign-lambda void "SDL_DestroyRenderer" (c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define destroy-texture
|
|
|
|
(foreign-lambda void "SDL_DestroyTexture" (c-pointer (struct "SDL_Texture"))))
|
|
|
|
|
|
|
|
(define flush-renderer
|
|
|
|
(foreign-lambda bool "SDL_FlushRenderer" (c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetCurrentRenderOutputSize
|
|
|
|
|
|
|
|
(define get-num-render-drivers
|
|
|
|
(foreign-lambda int "SDL_GetNumRenderDrivers"))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderClipRect
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderColorScale
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderDrawBlendMode
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderDrawColor
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderDrawColorFloat
|
|
|
|
|
|
|
|
(define get-render-driver
|
|
|
|
(foreign-lambda c-string "SDL_GetRenderDriver" int))
|
|
|
|
|
|
|
|
(define get-renderer
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Renderer"))
|
|
|
|
"SDL_GetRenderer"
|
|
|
|
(c-pointer (struct "SDL_Window"))))
|
|
|
|
|
|
|
|
(define get-renderer-from-texture
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Renderer"))
|
|
|
|
"SDL_GetRendererFromTexture"
|
|
|
|
(c-pointer (struct "SDL_Texture"))))
|
|
|
|
|
|
|
|
(define get-renderer-name
|
|
|
|
(foreign-lambda c-string "SDL_GetRendererName"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define get-renderer-properties
|
|
|
|
(foreign-lambda unsigned-int32 "SDL_GetRendererProperties"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderLogicalPresentation
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderLogicalPresentationRect
|
|
|
|
|
|
|
|
(define get-render-metal-command-encoder
|
|
|
|
(foreign-lambda c-pointer "SDL_GetRenderMetalCommandEncoder"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define get-render-metal-layer
|
|
|
|
(foreign-lambda c-pointer "SDL_GetRenderMetalLayer"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderOutputSize
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderSafeArea
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderScale
|
|
|
|
|
|
|
|
(define get-render-target
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Texture"))
|
|
|
|
"SDL_GetRenderTarget"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderViewport
|
|
|
|
|
|
|
|
;; TODO: SDL_GetRenderVSync
|
|
|
|
|
|
|
|
(define get-render-window
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Window"))
|
|
|
|
"SDL_GetRenderWindow"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureAlphaMod
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureAlphaModFloat
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureBlendMode
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureColorMod
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureColorModFloat
|
|
|
|
|
|
|
|
(define get-texture-properties
|
|
|
|
(foreign-lambda unsigned-int32 "SDL_GetTextureProperties"
|
|
|
|
(c-pointer (struct "SDL_Texture"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureScaleMode
|
|
|
|
|
|
|
|
;; TODO: SDL_GetTextureSize
|
|
|
|
|
|
|
|
;; TODO: SDL_LockTexture
|
|
|
|
|
|
|
|
;; TODO: SDL_LockTextureToSurface
|
|
|
|
|
|
|
|
(define render-clear
|
|
|
|
(foreign-lambda bool "SDL_RenderClear" (c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define render-clip-enabled
|
|
|
|
(foreign-lambda bool "SDL_RenderClipEnabled" (c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderCoordinatesFromWindow
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderCoordinatesToWindow
|
|
|
|
|
|
|
|
(define render-fill-rect
|
|
|
|
(foreign-lambda bool "SDL_RenderFillRect" (c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderFillRects
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderGeometry
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderGeometryRaw
|
|
|
|
|
|
|
|
(define render-line
|
|
|
|
(foreign-lambda bool "SDL_RenderLine"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
float float float float))
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderLines
|
|
|
|
|
|
|
|
(define render-point
|
|
|
|
(foreign-lambda bool "SDL_RenderPoint" (c-pointer (struct "SDL_Renderer")) float float))
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderPoints
|
|
|
|
|
|
|
|
(define render-present
|
|
|
|
(foreign-lambda bool "SDL_RenderPresent" (c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define render-read-pixels
|
|
|
|
(foreign-lambda (c-pointer (struct "SDL_Surface"))
|
|
|
|
"SDL_RenderReadPixels"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Rect"))))
|
|
|
|
|
|
|
|
(define render-rect
|
|
|
|
(foreign-lambda bool "SDL_RenderRect"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))))
|
|
|
|
|
|
|
|
;; TODO: SDL_RenderRects
|
|
|
|
|
|
|
|
(define render-texture
|
|
|
|
(foreign-lambda bool "SDL_RenderTexture"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))))
|
|
|
|
|
|
|
|
(define render-texture-9-grid
|
|
|
|
(foreign-lambda bool "SDL_RenderTexture9Grid"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))
|
|
|
|
float float float float float
|
|
|
|
(c-pointer (struct "SDL_FRect"))))
|
|
|
|
|
2024-10-08 22:41:17 +00:00
|
|
|
(define-sdl-const-values
|
2024-09-24 14:55:41 +00:00
|
|
|
flip int
|
2024-10-08 22:41:17 +00:00
|
|
|
none horizontal vertical)
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(define render-texture-rotated
|
|
|
|
(foreign-lambda bool "SDL_RenderTextureRotated"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))
|
|
|
|
double
|
|
|
|
(c-pointer (struct "SDL_FPoint"))
|
|
|
|
(enum "SDL_FlipMode")))
|
|
|
|
|
|
|
|
(define render-texture-tiled
|
|
|
|
(foreign-lambda bool "SDL_RenderTextureTiled"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
(c-pointer (struct "SDL_FRect"))
|
|
|
|
float
|
|
|
|
(c-pointer (struct "SDL_FRect"))))
|
|
|
|
|
|
|
|
(define render-viewport-set
|
|
|
|
(foreign-lambda bool "SDL_RenderViewportSet"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))))
|
|
|
|
|
|
|
|
(define set-render-clip-rect
|
|
|
|
(foreign-lambda bool "SDL_SetRenderClipRect"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Rect"))))
|
|
|
|
|
|
|
|
(define set-render-color-scale
|
|
|
|
(foreign-lambda bool "SDL_SetRenderColorScale"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
float))
|
|
|
|
|
|
|
|
(define set-render-draw-blend-mode
|
|
|
|
(foreign-lambda bool "SDL_SetRenderDrawBlendMode"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
unsigned-int32))
|
|
|
|
|
|
|
|
(define set-render-draw-color
|
|
|
|
(foreign-lambda bool "SDL_SetRenderDrawColor"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
unsigned-byte unsigned-byte unsigned-byte unsigned-byte))
|
|
|
|
|
|
|
|
(define set-render-draw-color-float
|
|
|
|
(foreign-lambda bool "SDL_SetRenderDrawColorFloat"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
float float float float))
|
|
|
|
|
2024-10-08 22:41:17 +00:00
|
|
|
(define-sdl-const-values
|
2024-09-24 14:55:41 +00:00
|
|
|
logical-presentation int
|
2024-10-08 22:41:17 +00:00
|
|
|
disabled stretch letterbox overscan integer-scale)
|
2024-09-24 14:55:41 +00:00
|
|
|
|
2024-10-08 22:41:17 +00:00
|
|
|
(define-sdl-const-values
|
2024-09-24 14:55:41 +00:00
|
|
|
scalemode int
|
2024-10-08 22:41:17 +00:00
|
|
|
nearest linear)
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(define set-render-logical-presentation
|
|
|
|
(foreign-lambda bool "SDL_SetRenderLogicalPresentation"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
int int
|
|
|
|
(enum "SDL_RendererLogicalPresentation")
|
|
|
|
(enum "SDL_ScaleMode")))
|
|
|
|
|
|
|
|
(define set-render-scale
|
|
|
|
(foreign-lambda bool "SDL_SetRenderScale"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
float float))
|
|
|
|
|
|
|
|
(define set-render-target
|
|
|
|
(foreign-lambda bool "SDL_SetRenderTarget"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Texture"))))
|
|
|
|
|
|
|
|
(define set-render-viewport
|
|
|
|
(foreign-lambda bool "SDL_SetRenderViewport"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
(c-pointer (struct "SDL_Rect"))))
|
|
|
|
|
2024-10-08 22:41:17 +00:00
|
|
|
(define-sdl-const-values
|
2024-09-24 14:55:41 +00:00
|
|
|
renderer-vsync int
|
2024-10-08 22:41:17 +00:00
|
|
|
disabled adaptive)
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
(define set-render-vsync
|
|
|
|
(foreign-lambda bool "SDL_SetRenderVSync"
|
|
|
|
(c-pointer (struct "SDL_Renderer"))
|
|
|
|
int))
|
|
|
|
|
|
|
|
(define set-texture-alpha-mod
|
|
|
|
(foreign-lambda bool "SDL_SetTextureAlphaMod"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
unsigned-byte))
|
|
|
|
|
|
|
|
(define set-texture-alpha-mod-float
|
|
|
|
(foreign-lambda bool "SDL_SetTextureAlphaModFloat"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
float))
|
|
|
|
|
|
|
|
(define set-texture-blend-mode
|
|
|
|
(foreign-lambda bool "SDL_SetTextureBlendMode"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
unsigned-int32))
|
|
|
|
|
|
|
|
(define set-texture-color-mod
|
|
|
|
(foreign-lambda bool "SDL_SetTextureColorMod"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
unsigned-byte unsigned-byte unsigned-byte))
|
|
|
|
|
|
|
|
(define set-texture-color-mod-float
|
|
|
|
(foreign-lambda bool "SDL_SetTextureColorModFloat"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
float float float))
|
|
|
|
|
|
|
|
(define set-texture-scale-mode
|
|
|
|
(foreign-lambda bool "SDL_SetTextureScaleMode"
|
|
|
|
(c-pointer (struct "SDL_Texture"))
|
|
|
|
(enum "SDL_ScaleMode")))
|
|
|
|
|
|
|
|
(define unlock-texture
|
2024-10-08 22:41:17 +00:00
|
|
|
(foreign-lambda void "SDL_UnlockTexture" (c-pointer (struct "SDL_Texture"))))
|
2024-09-24 14:55:41 +00:00
|
|
|
|
|
|
|
;; TODO: SDL_UpdateNVTexture
|
|
|
|
|
|
|
|
;; TODO: SDL_UpdateTexture
|
|
|
|
|
|
|
|
;; TODO: SDL_UpdateYUVTexture
|