Even more work
This commit is contained in:
parent
0af1300fe0
commit
a939188406
15 changed files with 406 additions and 409 deletions
3
.envrc
3
.envrc
|
@ -1 +1,2 @@
|
|||
use flake path:. --impure --show-trace
|
||||
export NIXPKGS_ALLOW_BROKEN=1
|
||||
use nix
|
||||
|
|
42
flake.lock
42
flake.lock
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1726755586,
|
||||
"narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "systems",
|
||||
"type": "indirect"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
61
flake.nix
61
flake.nix
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
description = "A flake to use Chicken 6 with TinyCC.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
self,
|
||||
nixpkgs,
|
||||
systems,
|
||||
...
|
||||
}: let
|
||||
inherit (nixpkgs) lib;
|
||||
forAllSystems = lib.genAttrs [
|
||||
"aarch64-linux"
|
||||
"i686-linux"
|
||||
"x86_64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
pkgsFor = forAllSystems (system:
|
||||
import nixpkgs {
|
||||
localSystem.system = system;
|
||||
overlays = with self.overlays; [chicken];
|
||||
});
|
||||
mkDate = longDate: (lib.concatStringsSep "-" [
|
||||
(builtins.substring 0 4 longDate)
|
||||
(builtins.substring 4 2 longDate)
|
||||
(builtins.substring 6 2 longDate)
|
||||
]);
|
||||
version = "5.4.0";
|
||||
in {
|
||||
overlays = {
|
||||
default = self.overlays.sdl3;
|
||||
|
||||
sdl3 = final: prev: {
|
||||
sdl3 = final.callPackage ./nix/sdl3.nix {
|
||||
stdenv = final.gcc13Stdenv;
|
||||
version = "2.99.0+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
devShells = forAllSystems (system: {
|
||||
default = let
|
||||
pkgs = import nixpkgs {
|
||||
overlays = [ self.overlays.sdl3 ];
|
||||
};
|
||||
in pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
pkg-config rlwrap sdl3
|
||||
chicken chickenPackages_5.chickenEggs.apropos
|
||||
] ++ (with pkgs.chickenPackages_5.chickenEggs; [
|
||||
apropos chicken-doc srfi-1 srfi-18 lsp-server
|
||||
r7rs srfi-152
|
||||
]);
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
(import (scheme)
|
||||
(chicken base)
|
||||
(chicken bitwise)
|
||||
(chicken syntax)
|
||||
(srfi 152))
|
||||
|
||||
|
@ -10,18 +11,7 @@
|
|||
(char-upcase c)))
|
||||
in))
|
||||
|
||||
(define-syntax define-sdl-flag
|
||||
(er-macro-transformer
|
||||
(lambda (exp rename compare)
|
||||
(let ((flag (cadr exp)))
|
||||
`(begin
|
||||
(export ,flag)
|
||||
(define ,flag
|
||||
(foreign-value
|
||||
,(string-append "SDL_" (snake-upcase (symbol->string flag)))
|
||||
unsigned-int32)))))))
|
||||
|
||||
(define-syntax define-sdl-enum-values
|
||||
(define-syntax define-sdl-const-values
|
||||
(er-macro-transformer
|
||||
(lambda (exp rename compare)
|
||||
(let ((prefix (cadr exp))
|
||||
|
@ -38,3 +28,6 @@
|
|||
,(string-append "SDL_" (snake-upcase full-str))
|
||||
,type)))))
|
||||
enum-labels))))))
|
||||
|
||||
(define (foldl-uint-flags flags)
|
||||
(foldl bitwise-ior (car flags) (cdr flags)))
|
||||
|
|
|
@ -1,33 +1,43 @@
|
|||
(import (scheme)
|
||||
(chicken base)
|
||||
(chicken bitwise)
|
||||
(chicken foreign))
|
||||
(chicken foreign)
|
||||
(sdl internal utilities))
|
||||
(import-for-syntax (sdl3 internal utilities))
|
||||
|
||||
(foreign-declare "#include <SDL3/SDL_init.h>")
|
||||
|
||||
(define init-audio (foreign-value "SDL_INIT_AUDIO" unsigned-int32))
|
||||
(define init-video (foreign-value "SDL_INIT_VIDEO" unsigned-int32))
|
||||
(define init-joystick (foreign-value "SDL_INIT_JOYSTICK" unsigned-int32))
|
||||
(define init-haptic (foreign-value "SDL_INIT_HAPTIC" unsigned-int32))
|
||||
(define init-gamepad (foreign-value "SDL_INIT_GAMEPAD" unsigned-int32))
|
||||
(define init-events (foreign-value "SDL_INIT_EVENTS" unsigned-int32))
|
||||
(define init-sensor (foreign-value "SDL_INIT_SENSOR" unsigned-int32))
|
||||
(define init-camera (foreign-value "SDL_INIT_CAMERA" unsigned-int32))
|
||||
;;; Types
|
||||
|
||||
(define-foreign-type SDL_InitFlags unsigned-int32)
|
||||
(define-foreign-type SDL_AppResult (enum "SDL_AppResult"))
|
||||
|
||||
;;; Constants
|
||||
|
||||
(define-sdl-const-values
|
||||
init SDL_InitFlags
|
||||
(audio video joystick haptic gamepad events sensor camera))
|
||||
|
||||
(define-sdl-const-values
|
||||
app SDL_AppResult
|
||||
(continue success failure))
|
||||
|
||||
;;; Procedures
|
||||
|
||||
(define (init #!rest flags)
|
||||
((foreign-lambda bool "SDL_Init" unsigned-int32)
|
||||
(foldl bitwise-ior (car flags) (cdr flags))))
|
||||
((foreign-lambda bool "SDL_Init" SDL_InitFlags)
|
||||
(foldl-uint-flags flags)))
|
||||
|
||||
(define (init-sub-system #!rest flags)
|
||||
((foreign-lambda bool "SDL_InitSubSystem" unsigned-int32)
|
||||
(foldl bitwise-ior (car flags) (cdr flags))))
|
||||
((foreign-lambda bool "SDL_InitSubSystem" SDL_InitFlags)
|
||||
(foldl-uint-flags flags)))
|
||||
|
||||
(define quit
|
||||
(foreign-lambda void "SDL_Quit" void))
|
||||
|
||||
(define (quit-sub-system #!rest flags)
|
||||
((foreign-lambda void "SDL_QuitSubSystem" unsigned-int32)
|
||||
(foldl bitwise-ior (car flags) (cdr flags))))
|
||||
((foreign-lambda void "SDL_QuitSubSystem" SDL_InitFlags)
|
||||
(foldl-uint-flags flags)))
|
||||
|
||||
(define set-app-metadata
|
||||
(foreign-lambda bool "SDL_SetAppMetadata" c-string c-string c-string))
|
||||
|
@ -39,5 +49,5 @@
|
|||
(foreign-lambda c-string "SDL_GetAppMetadataProperty" c-string))
|
||||
|
||||
(define (was-init #!rest flags)
|
||||
((foreign-lambda unsigned-int32 "SDL_WasInit" unsigned-int32)
|
||||
(foldl bitwise-ior (car flags) (cdr flags))))
|
||||
((foreign-lambda SDL_InitFlags "SDL_WasInit" SDL_InitFlags)
|
||||
(foldl-uint-flags flags)))
|
||||
|
|
|
@ -5,84 +5,129 @@
|
|||
|
||||
(foreign-declare "#include <SDL3/SDL_video.h>")
|
||||
|
||||
(define-sdl-flag window-fullscreen)
|
||||
(define-sdl-flag window-opengl)
|
||||
(define-sdl-flag window-occluded)
|
||||
(define-sdl-flag window-hidden)
|
||||
(define-sdl-flag window-borderless)
|
||||
(define-sdl-flag window-resizable)
|
||||
(define-sdl-flag window-minimized)
|
||||
(define-sdl-flag window-maximized)
|
||||
(define-sdl-flag window-mouse-grabbed)
|
||||
(define-sdl-flag window-input-focus)
|
||||
(define-sdl-flag window-mouse-focus)
|
||||
(define-sdl-flag window-external)
|
||||
(define-sdl-flag window-modal)
|
||||
(define-sdl-flag window-high-pixel-density)
|
||||
(define-sdl-flag window-mouse-capture)
|
||||
(define-sdl-flag window-mouse-relative-mode)
|
||||
(define-sdl-flag window-always-on-top)
|
||||
(define-sdl-flag window-utility)
|
||||
(define-sdl-flag window-tooltip)
|
||||
(define-sdl-flag window-popup-menu)
|
||||
(define-sdl-flag window-keyboard-grabbed)
|
||||
(define-sdl-flag window-vulkan)
|
||||
(define-sdl-flag window-metal)
|
||||
(define-sdl-flag window-transparent)
|
||||
(define-sdl-flag window-not-focusable)
|
||||
;;; Types
|
||||
|
||||
(define create-popup-window
|
||||
(foreign-lambda (c-pointer (struct "SDL_Window")) "SDL_CreatePopupWindow"
|
||||
(struct "SDL_Window") int int int int unsigned-int32))
|
||||
(define-foreign-type SDL_DisplayID unsigned-int32)
|
||||
(define-foreign-type SDL_WindowID unsigned-int32)
|
||||
(define-foreign-type SDL_EGLAttrib size_t)
|
||||
(define-foreign-type SDL_EGLAttribArrayCallback
|
||||
(function SDL_EGLAttrib () "SDLCALL"))
|
||||
(define-foreign-type SDL_EGLDisplay c-pointer)
|
||||
(define-foreign-type SDL_GLContext (struct "SDL_GLContext"))
|
||||
(define-foreign-type SDL_HitTest
|
||||
(function SDL_HitTestResult ((c-pointer SDL_Window) (c-pointer SDL_Point) c-pointer)))
|
||||
(define-foreign-type SDL_Window (struct "SDL_Window"))
|
||||
(define-foreign-type SDL_DisplayMode (struct "SDL_DisplayMode"))
|
||||
|
||||
;;; Constants
|
||||
|
||||
(define-foreign-type SDL_DisplayOrientation (enum "SDL_DisplayOrientation"))
|
||||
(define-sdl-const-values
|
||||
orientation SDL_DisplayOrientation
|
||||
(unknown landscape landscape-flipped portrait portrait-flipped))
|
||||
|
||||
(define-foreign-type SDL_FlashOperation (enum "SDL_FlashOperation"))
|
||||
(define-sdl-const-values
|
||||
flash SDL_FlashOperation
|
||||
(cancel briefly until-focused))
|
||||
|
||||
(define-foreign-type SDL_GLattr (enum "SDL_GLattr"))
|
||||
(define-sdl-const-values
|
||||
(gl SDL_GLattr
|
||||
red-size green-size blue-size alpha-size buffer-size doublebuffer depth-size
|
||||
stencil-size accum-red-size accum-green-size accum-blue-size accum-alpha-size
|
||||
stereo multisamplebuffers multisamplesamples accelerated-visual retained-backing
|
||||
context-major-version context-minor-version context-flags context-profile-mask
|
||||
share-with-current-context framebuffer-srgb-capable context-release-behavior
|
||||
context-reset-notification context-no-error floatbuffers egl-platform))
|
||||
|
||||
(define-foreign-type SDL_GLcontextFlag (enum "SDL_GLcontextFlag"))
|
||||
(define-sdl-const-values
|
||||
gl-context SDL_GLcontextFlag
|
||||
(debug-flag forward-compatible-flag robust-access-flag reset-isolation-flag))
|
||||
|
||||
(define-foreign-type SDL_GLcontextReleaseFlag (enum "SDL_GLcontextReleaseFlag"))
|
||||
(define-sdl-const-values
|
||||
gl-context-release-behavior SDL_GLcontestReleaseFlag
|
||||
(none flush))
|
||||
|
||||
(define-foreign-type SDL_GLContextResetNotification (enum "SDL_GLContextResetNotification"))
|
||||
(define-sdl-const-values
|
||||
gl-context-reset SDL_GLContextResetNotification
|
||||
(no-notification lose-context))
|
||||
|
||||
(define-foreign-type SDL_GLprofile (enum "SDL_GLprofile"))
|
||||
(define-sdl-const-values
|
||||
gl-context-profile SDL_GLprofile
|
||||
(core compatibility es))
|
||||
|
||||
(define-foreign-type SDL_HitTestResult (enum "SDL_HitTestResult"))
|
||||
(define-sdl-const-values
|
||||
hittest SDL_HitTestResult
|
||||
(normal draggable resize-topleft resize-top resize-topright resize-right
|
||||
resize-bottomright resize-bottom resize-bottomleft resize-left))
|
||||
|
||||
(define-foreign-type SDL_SystemTheme (enum "SDL_SystemTheme"))
|
||||
(define-sdl-const-values
|
||||
system-theme SDL_SystemTheme
|
||||
(unknown light dark))
|
||||
|
||||
(define-foreign-type SDL_WindowFlags unsigned-int64)
|
||||
(define-sdl-const-values
|
||||
window SDL_WindowFlags
|
||||
(fullscreen opengl occluded hidden borderless resizable minimized maximized
|
||||
mouse-grabbed input-focus mouse-focus external modal high-pixel-density
|
||||
mouse-capture mouse-relative-mode always-on-top utility tooltip popup-menu
|
||||
keyboard-grabbed vulkan metal transparent not-focusable))
|
||||
|
||||
;; These are weird string properties for CreateWindowWithProperties
|
||||
(define-sdl-const-values
|
||||
prop-window-create c-string
|
||||
(always-on-top-boolean borderless-boolean external-graphics-context-boolean
|
||||
focusable-boolean fullscreen-boolean height-number hidden-boolean
|
||||
high-pixel-density-boolean maximized-boolean menu-boolean
|
||||
metal-boolean minimized-boolean modal-boolean
|
||||
mouse-grabbed-boolean opengl-boolean parent-pointer
|
||||
resizable-boolean title-string transparent-boolean tooltip-boolean
|
||||
utility-boolean vulkan-boolean width-number x-number y-number
|
||||
cocoa-window-pointer cocoa-view-pointer
|
||||
wayland-surface-role-custom-boolean
|
||||
wayland-create-egl-window-boolean wayland-wl-surface-pointer
|
||||
win32-hwnd-pointer win32-pixel-format-hwnd-pointer
|
||||
x11-window-number))
|
||||
|
||||
(define-sdl-const-values
|
||||
pixelformat unsigned-int32
|
||||
(unknown index1lsb index1msb index2lsb index2msb index4lsb index4msb index8 rgb332
|
||||
xrgb4444 xbgr4444 xrgb1555 xbgr1555 argb4444 rgba4444 abgr4444 bgra4444 argb1555
|
||||
rgba5551 abgr1555 bgra5551 rgb565 bgr565 rgb24 bgr24 xrgb8888 rgbx8888
|
||||
pixelformat-xbgr8888 pbgrx8888 pargb8888 prgba8888 pabgr8888 pbgra8888
|
||||
pxrgb2101010 pxbgr2101010 pargb2101010 pabgr2101010 prgb48 pbgr48 prgba64
|
||||
pargb64 pbgra64 pabgr64 prgb48-float pbgr48-float prgba64-float pargb64-float
|
||||
pbgra64-float pabgr64-float prgb96-float pbgr96-float prgba128-float
|
||||
pargb128-float pbgra128-float pabgr128-float pyv12 piyuv pyuy2 puyvy pyvyu pnv12
|
||||
pnv21 pp010 external-oes rgba32 argb32 bgra32 abgr32 rgbx32 xrgb32 bgrx32
|
||||
xbgr32))
|
||||
|
||||
;;; Procedures
|
||||
|
||||
(define (create-popup-window parent offset-x offset-y w h #!rest flags)
|
||||
((foreign-lambda (c-pointer SDL_Window) "SDL_CreatePopupWindow"
|
||||
(struct SDL_Window) int int int int unsigned-int64)
|
||||
parent offset-x offset-y w h (foldl-uint-flags flags)))
|
||||
|
||||
(define (create-window title w h #!rest flags)
|
||||
((foreign-lambda (c-pointer (struct "SDL_Window")) "SDL_CreateWindow"
|
||||
((foreign-lambda (c-pointer SDL_Window) "SDL_CreateWindow"
|
||||
c-string int int unsigned-int32)
|
||||
title w h (foldl bitwise-ior (car flags) (cdr flags))))
|
||||
title w h (foldl-uint-flags flags)))
|
||||
|
||||
(define-sdl-flag prop-window-create-always-on-top-boolean)
|
||||
(define-sdl-flag prop-window-create-borderless-boolean)
|
||||
(define-sdl-flag prop-window-create-external-graphics-context-boolean)
|
||||
(define-sdl-flag prop-window-create-focusable-boolean)
|
||||
(define-sdl-flag prop-window-create-fullscreen-boolean)
|
||||
(define-sdl-flag prop-window-create-height-number)
|
||||
(define-sdl-flag prop-window-create-hidden-boolean)
|
||||
(define-sdl-flag prop-window-create-high-pixel-density-boolean)
|
||||
(define-sdl-flag prop-window-create-maximized-boolean)
|
||||
(define-sdl-flag prop-window-create-menu-boolean)
|
||||
(define-sdl-flag prop-window-create-metal-boolean)
|
||||
(define-sdl-flag prop-window-create-minimized-boolean)
|
||||
(define-sdl-flag prop-window-create-modal-boolean)
|
||||
(define-sdl-flag prop-window-create-mouse-grabbed-boolean)
|
||||
(define-sdl-flag prop-window-create-opengl-boolean)
|
||||
(define-sdl-flag prop-window-create-parent-pointer)
|
||||
(define-sdl-flag prop-window-create-resizable-boolean)
|
||||
(define-sdl-flag prop-window-create-title-string)
|
||||
(define-sdl-flag prop-window-create-transparent-boolean)
|
||||
(define-sdl-flag prop-window-create-tooltip-boolean)
|
||||
(define-sdl-flag prop-window-create-utility-boolean)
|
||||
(define-sdl-flag prop-window-create-vulkan-boolean)
|
||||
(define-sdl-flag prop-window-create-width-number)
|
||||
(define-sdl-flag prop-window-create-x-number)
|
||||
(define-sdl-flag prop-window-create-y-number)
|
||||
(define-sdl-flag prop-window-create-cocoa-window-pointer)
|
||||
(define-sdl-flag prop-window-create-cocoa-view-pointer)
|
||||
(define-sdl-flag prop-window-create-wayland-surface-role-custom-boolean)
|
||||
(define-sdl-flag prop-window-create-wayland-create-egl-window-boolean)
|
||||
(define-sdl-flag prop-window-create-wayland-wl-surface-pointer)
|
||||
(define-sdl-flag prop-window-create-win32-hwnd-pointer)
|
||||
(define-sdl-flag prop-window-create-win32-pixel-format-hwnd-pointer)
|
||||
(define-sdl-flag prop-window-create-x11-window-number)
|
||||
|
||||
(define (create-window-with-properties #!rest props)
|
||||
((foreign-lambda (c-pointer (struct "SDL_Window")) "SDL_CreateWindowWithProperties"
|
||||
(foldl bitwise-ior (car props) (cdr props)))))
|
||||
;; TODO: SDL_CreateWindowWithProperties
|
||||
|
||||
(define destroy-window
|
||||
(foreign-lambda void "SDL_DestroyWindow" (c-pointer (struct "SDL_Window"))))
|
||||
(foreign-lambda void "SDL_DestroyWindow" (c-pointer SDL_Window)))
|
||||
|
||||
(define destroy-window-surface
|
||||
(foreign-lambda bool "SDL_DestroyWindowSurface" (c-pointer (struct "SDL_Window"))))
|
||||
(foreign-lambda bool "SDL_DestroyWindowSurface" (c-pointer SDL_Window)))
|
||||
|
||||
(define disable-screen-saver
|
||||
(foreign-lambda bool "SDL_DisableScreenSaver"))
|
||||
|
@ -97,41 +142,33 @@
|
|||
(foreign-lambda c-pointer "SDL_EGL_GetProcAddress" c-string))
|
||||
|
||||
(define egl-get-window-surface
|
||||
(foreign-lambda c-pointer "SDL_EGL_GetWindowSurface" (c-pointer (struct "SDL_Window"))))
|
||||
(foreign-lambda c-pointer "SDL_EGL_GetWindowSurface" (c-pointer SDL_Window)))
|
||||
|
||||
;; TODO: SDL_EGL_SetAttributeCallbacks
|
||||
|
||||
(define enable-screen-saver
|
||||
(foreign-lambda bool "SDL_EnableScreenSaver"))
|
||||
|
||||
(define-sdl-enum-values
|
||||
flash int
|
||||
(cancel briefly until-focused))
|
||||
|
||||
(define flash-window
|
||||
(foreign-lambda bool "SDL_FlashWindow" (c-pointer (struct "SDL_Window")) (enum "SDL_FlashOperation")))
|
||||
(foreign-lambda bool "SDL_FlashWindow" (c-pointer SDL_Window) SDL_FlashOperation))
|
||||
|
||||
(define get-closest-fullscreen-display-mode
|
||||
(foreign-lambda bool "SDL_GetClosestFullscreenDisplayMode"
|
||||
unsigned-int32 int int float bool (c-pointer (struct "SDL_DisplayMode"))))
|
||||
SDL_DisplayID int int float bool (c-pointer SDL_DisplayMode)))
|
||||
|
||||
(define get-current-display-mode
|
||||
(foreign-lambda (c-pointer (struct "SDL_DisplayMode")) "SDL_DisplayMode" unsigned-int32))
|
||||
|
||||
(define-sdl-enum-values
|
||||
orientation int
|
||||
unknown landscape landscape-flipped portrait portrait-flipped)
|
||||
(foreign-lambda (c-pointer SDL_DisplayMode) "SDL_DisplayMode" SDL_DisplayID))
|
||||
|
||||
(define get-current-display-orientation
|
||||
(foreign-lambda (enum "SDL_DisplayOrientation") "SDL_GetCurrentDisplayOrientation"
|
||||
unsigned-int32))
|
||||
(foreign-lambda SDL_DisplayOrientation "SDL_GetCurrentDisplayOrientation"
|
||||
SDL_DisplayID))
|
||||
|
||||
(define get-current-video-driver
|
||||
(foreign-lambda c-string "SDL_GetCurrentVideoDriver"))
|
||||
|
||||
(define get-desktop-display-mode
|
||||
(foreign-lambda (c-pointer (struct "SDL_DisplayMode")) "SDL_GetDesktopDisplayMode"
|
||||
unsigned-int32))
|
||||
(foreign-lambda (c-pointer SDL_DisplayMode) "SDL_GetDesktopDisplayMode"
|
||||
SDL_DisplayID))
|
||||
|
||||
(define get-display-bounds
|
||||
(foreign-lambda bool "SDL_GetDisplayBounds"
|
||||
|
@ -178,7 +215,7 @@
|
|||
(define get-primary-display
|
||||
(foreign-lambda unsigned-int22 "SDL_GetPrimaryDisplay"))
|
||||
|
||||
(define-sdl-enum-values
|
||||
(define-sdl-const-values
|
||||
system-theme int
|
||||
(unknown light dark))
|
||||
|
||||
|
@ -234,19 +271,6 @@
|
|||
(define get-window-pixel-density
|
||||
(foreign-lambda float "SDL_GetWindowPixelDensity" (c-pointer (struct "SDL_Window"))))
|
||||
|
||||
(define-sdl-enum-values
|
||||
pixelformat unsigned-int32
|
||||
(unknown index1lsb index1msb index2lsb index2msb index4lsb index4msb
|
||||
index8 rgb332 xrgb4444 xbgr4444 xrgb1555 xbgr1555 argb4444
|
||||
rgba4444 abgr4444 bgra4444 argb1555 rgba5551 abgr1555 bgra5551 rgb565
|
||||
bgr565 rgb24 bgr24 xrgb8888 rgbx8888 pixelformat-xbgr8888 pbgrx8888
|
||||
pargb8888 prgba8888 pabgr8888 pbgra8888 pxrgb2101010 pxbgr2101010 pargb2101010
|
||||
pabgr2101010 prgb48 pbgr48 prgba64 pargb64 pbgra64 pabgr64 prgb48-float pbgr48-float
|
||||
prgba64-float pargb64-float pbgra64-float pabgr64-float prgb96-float
|
||||
pbgr96-float prgba128-float pargb128-float pbgra128-float pabgr128-float
|
||||
pyv12 piyuv pyuy2 puyvy pyvyu pnv12 pnv21 pp010 external-oes rgba32 argb32
|
||||
bgra32 abgr32 rgbx32 xrgb32 bgrx32 xbgr32))
|
||||
|
||||
(define get-window-pixel-format
|
||||
(foreign-lambda (enum "SDL_PixelFormat") "SDL_GetWindowPixelFormat"
|
||||
(c-pointer (struct "SDL_Window"))))
|
||||
|
@ -307,15 +331,6 @@
|
|||
(define gl-reset-attributes
|
||||
(foreign-lambda void "SDL_GL_ResetAttributes"))
|
||||
|
||||
(define-sdl-enum-values
|
||||
gl int
|
||||
red-size green-size blue-size alpha-size buffer-size doublebuffer depth-size
|
||||
stencil-size accum-red-size accum-green-size accum-blue-size accum-alpha-size
|
||||
stereo multisamplebuffers multisamplesamples accelerated-visual retained-backing
|
||||
context-major-version context-minor-version context-flags context-profile-mask
|
||||
share-with-current-context framebuffer-srgb-capable context-release-behavior
|
||||
context-reset-notification context-no-error floatbuffers egl-platform)
|
||||
|
||||
(define gl-set-attribute
|
||||
(foreign-lambda bool "SDL_GL_SetAttribute" (enum "SDL_GLattr") int))
|
||||
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
{ lib, stdenv, fetchurl, makeWrapper, darwin, tcc-mob, bootstrap-chicken ? null, testers }:
|
||||
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
stdenv,
|
||||
fetchgit,
|
||||
fetchurl,
|
||||
makeWrapper,
|
||||
darwin,
|
||||
tcc-mob,
|
||||
version ? "git",
|
||||
testers
|
||||
}:
|
||||
let
|
||||
platform = with stdenv;
|
||||
if isDarwin then "macosx"
|
||||
|
@ -10,14 +20,46 @@ let
|
|||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "chicken";
|
||||
version = "5.4.0";
|
||||
inherit version;
|
||||
|
||||
binaryVersion = 11;
|
||||
binaryVersion = 12;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://code.call-cc.org/releases/${finalAttrs.version}/chicken-${finalAttrs.version}.tar.gz";
|
||||
sha256 = "sha256-PF1KphwRZ79tm/nq+JHadjC6n188Fb8JUVpwOb/N7F8=";
|
||||
};
|
||||
srcs = [
|
||||
(fetchgit {
|
||||
url = "git://code.call-cc.org/chicken-core";
|
||||
rev = "2c80bbab33302444bebc7eaac7f42ee9cda50301";
|
||||
sha256 = "sha256-KWL9/s03ZGwjsjvxZxluXtaKvBuimHGH5UXaQVf68Mg=";
|
||||
})
|
||||
(fetchurl {
|
||||
url = "https://code.call-cc.org/dev-snapshots/2024/07/01/chicken-6.0.0-bootstrap.tar.gz";
|
||||
sha256 = "sha256-qkcyWzsaN9+HbMBolmv7zeaPrtbaCTGa9HoF2g/3//o=";
|
||||
})
|
||||
];
|
||||
|
||||
unpackPhase = ''
|
||||
cp -r `echo $srcs | awk '{print $1}'`/* .
|
||||
cp -r `echo $srcs | awk '{print $1}'`/.* .
|
||||
chmod -R 777 .
|
||||
mkdir -p boot/snapshot
|
||||
cd boot
|
||||
tar xzf `echo $srcs | awk '{print $2}'`
|
||||
cd ..
|
||||
echo ${version} > buildid
|
||||
|
||||
cd boot/chicken-6.0.0
|
||||
case "${platform}" in
|
||||
bsd)
|
||||
mkcmd=gmake;;
|
||||
*)
|
||||
mkcmd=make;;
|
||||
esac
|
||||
export CC="${tcc-mob}/bin/tcc"
|
||||
$mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot
|
||||
$mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot install
|
||||
cd ../..
|
||||
./configure --chicken "$(pwd)"/boot/snapshot/bin/chicken --c-compiler "${tcc-mob}/bin/tcc"
|
||||
$mkcmd boot-chicken
|
||||
'';
|
||||
|
||||
# Disable two broken tests: "static link" and "linking tests"
|
||||
postPatch = ''
|
||||
|
@ -25,8 +67,6 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
sed -i tests/runtests.sh -e "/linking tests/,+11 { s/^/# / }"
|
||||
'';
|
||||
|
||||
setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
|
||||
|
||||
# -fno-strict-overflow is not a supported argument in clang
|
||||
hardeningDisable = lib.optionals stdenv.cc.isClang [ "strictoverflow" ];
|
||||
|
||||
|
@ -47,14 +87,15 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
pkgs.hostname
|
||||
tcc-mob
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
darwin.autoSignDarwinBinariesHook
|
||||
];
|
||||
|
||||
buildInputs = lib.optionals (bootstrap-chicken != null) [
|
||||
bootstrap-chicken
|
||||
];
|
||||
configurePhase = ''
|
||||
./configure --chicken ./chicken-boot --prefix $PREFIX --platform=$PLATFORM --c-compiler "${tcc-mob}/bin/tcc"
|
||||
'';
|
||||
|
||||
doCheck = !stdenv.isDarwin;
|
||||
postCheck = ''
|
||||
|
@ -81,4 +122,5 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
Windows, and many Unix flavours.
|
||||
'';
|
||||
};
|
||||
|
||||
})
|
||||
|
|
24
nix/sdl3.nix
24
nix/sdl3.nix
|
@ -7,15 +7,21 @@
|
|||
makeWrapper,
|
||||
darwin,
|
||||
version ? "git",
|
||||
testers
|
||||
testers,
|
||||
}:
|
||||
let
|
||||
platform = with stdenv;
|
||||
if isDarwin then "macosx"
|
||||
else if isCygwin then "cygwin"
|
||||
else if (isFreeBSD || isOpenBSD) then "bsd"
|
||||
else if isSunOS then "solaris"
|
||||
else "linux"; # Should be a sane default
|
||||
platform =
|
||||
with stdenv;
|
||||
if isDarwin then
|
||||
"macosx"
|
||||
else if isCygwin then
|
||||
"cygwin"
|
||||
else if (isFreeBSD || isOpenBSD) then
|
||||
"bsd"
|
||||
else if isSunOS then
|
||||
"solaris"
|
||||
else
|
||||
"linux"; # Should be a sane default
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "SDL3";
|
||||
|
@ -38,9 +44,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
makeWrapper
|
||||
pkgs.hostname
|
||||
pkgs.cmake
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
darwin.autoSignDarwinBinariesHook
|
||||
];
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ darwin.autoSignDarwinBinariesHook ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://libsdl.org/";
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
(define-library (sdl3 features)
|
||||
(module (sdl3 features)
|
||||
()
|
||||
(import (scheme)
|
||||
(chicken foreign))
|
||||
(chicken base)
|
||||
(chicken foreign)
|
||||
(chicken platform))
|
||||
(begin
|
||||
(foreign-declare "#include <SDL3/SDL_version.h>")
|
||||
(register-feature! 'sdl3)
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
(define-library (sdl3 init)
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(export init-audio
|
||||
init-video
|
||||
init-joystick
|
||||
init-haptic
|
||||
init-gamepad
|
||||
init-events
|
||||
init-sensor
|
||||
init-camera
|
||||
(module (sdl3 init)
|
||||
(SDL_InitFlags
|
||||
SDL_AppResult
|
||||
|
||||
init
|
||||
init-sub-system
|
||||
|
@ -18,5 +10,7 @@
|
|||
set-app-metadata-property
|
||||
get-app-metadata-property
|
||||
was-init)
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(begin
|
||||
(include-relative "lib/sdl3-init-impl.scm")))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(define-library (sdl3 internal utilities)
|
||||
(module (sdl3 internal utilities)
|
||||
(define-sdl-flag
|
||||
define-sdl-enum-values)
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(export define-sdl-flag
|
||||
define-sdl-enum-values)
|
||||
(begin
|
||||
(include-relative "internal/utilities.scm")))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(define-library (sdl3 main)
|
||||
(module (sdl3 main)
|
||||
()
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(export)
|
||||
(begin
|
||||
(include-relative "lib/sdl3-main-impl.scm")))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(define-library (sdl3 render)
|
||||
(module (sdl3 render)
|
||||
()
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(export)
|
||||
(begin
|
||||
(include-relative "lib/sdl3-render-impl.scm")))
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
(define-library (sdl3 video)
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(export create-popup-window
|
||||
(module (sdl3 video)
|
||||
(create-popup-window
|
||||
create-window
|
||||
create-window-with-properties
|
||||
destroy-window
|
||||
|
@ -111,5 +109,7 @@
|
|||
;; update-window-surface-rects
|
||||
window-has-surface
|
||||
)
|
||||
(import (scheme)
|
||||
(chicken base))
|
||||
(begin
|
||||
(include-relative "lib/sdl3-video-impl.scm")))
|
||||
|
|
38
shell.nix
Normal file
38
shell.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
with import <nixpkgs> {
|
||||
overlays = [
|
||||
(final: prev: {
|
||||
tcc-mob = final.callPackage ./nix/tinycc.nix { stdenv = final.gcc13Stdenv; };
|
||||
chicken = final.callPackage ./nix/chicken.nix { stdenv = final.gcc13Stdenv; };
|
||||
sdl3 = final.callPackage ./nix/sdl3.nix {
|
||||
stdenv = final.gcc13Stdenv;
|
||||
version = "2.99.0";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
mkShell {
|
||||
packages = with pkgs; [
|
||||
tcc-mob
|
||||
sdl3
|
||||
chicken
|
||||
rlwrap
|
||||
]
|
||||
# ++ (with pkgs.chickenPackages_5.chickenEggs; [
|
||||
# apropos
|
||||
# chicken-doc
|
||||
# srfi-1
|
||||
# srfi-18
|
||||
# lsp-server
|
||||
# srfi-152
|
||||
# ])
|
||||
;
|
||||
shellHook = ''
|
||||
export CC="${pkgs.tcc-mob}/bin/tcc"
|
||||
export CHICKEN_PREFIX="$(pwd)/.chicken"
|
||||
export CHICKEN_INSTALL_REPOSITORY="$(pwd)/.chicken/eggs"
|
||||
export CHICKEN_REPOSITORY_PATH="${pkgs.chicken}/lib/chicken/11:$(pwd)/.chicken/eggs"
|
||||
export PATH="$PATH:$CHICKEN_PREFIX"
|
||||
# chicken-install lsp-server salmonella
|
||||
export CHICKEN_PREFIX="${pkgs.chicken}"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue