This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun outer (renderer) | |
(unless sdl2::*event-loop* | |
(setf sdl2::*event-loop* t) | |
(sdl2:in-main-thread (:background nil) | |
(unwind-protect | |
(inner renderer nil) | |
(setf sdl2::*event-loop* nil))))) | |
(defun inner (renderer quit?) | |
(flet ((idle-function () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* compile with `gcc ramdisk/opengl.c -lSDL2 -lGL` */ | |
#include <SDL2/SDL.h> | |
#include <GL/gl.h> | |
#include <stdio.h> | |
int main(int argc, char* argv[]) { | |
SDL_Init(SDL_INIT_VIDEO); | |
SDL_Window* win = SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 512, 512, SDL_WINDOW_OPENGL); | |
SDL_GLContext ctx = SDL_GL_CreateContext(win); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.npr.org/sections/goatsandsoda/2018/08/13/636025077/to-fix-that-pain-in-your-back-you-might-have-to-change-the-way-you-sit | |
http://super-memory.com/articles/sleep.htm | |
https://codejamming.org/2019/how-to-return-to-flow | |
https://guzey.com/productivity/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nuklear (https://github.com/vurtun/nuklear) is a single-file immediate-mode GUI library written in ANSI C that has been surprisingly popular in the Common Lisp game development world recently (although by "surprisingly popular" I mean "more than three people have been talking about it") | |
Currently, two people are working on CL bindings for nuklear: baggers (with the cl-nuklear bindings (https://github.com/cbaggers/cl-nuklear) and CEPL backend) and borodust (with cl-bodge integration with said bindings). | |
However, nuklear doesn't appear to have any particularly strong ties to C. | |
That is, (1) it doesn't have insane (BLAS-level) speed requirements and (2) it doesn't rely on any particularly low-level features that can't be achieved in CL through moderate use of libraries. | |
Aside from "it's already in C", the two justifications above are the only reason to write or use things in C. | |
cloc in nuklear/src yields 19k lines of code. As long as nuklear follows a straightforward design and doesn't do any insane pointer magi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (color baz zuul) | |
(restart-bind | |
((enter-new (lambda (&optional v) | |
(declare (ignore v)) | |
(princ "enter a new value: ") | |
(return-from foo (read))) | |
:report-function | |
(lambda (stream) | |
(format stream "Supply a replacement value")))) | |
(typecase color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (color baz zuul) | |
(typecase color | |
(truecolor (let ((r (aref color 0)) | |
(g (aref color 1)) | |
(b (aref color 2))) | |
(list baz 2 r g b))) | |
(ansi-color (+ zuul (ansi-color-code color))) | |
(otherwise (error "~S is not a color" color)))) | |
;; then just |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://snai.pe/posts/modules-in-c99 | |
// ah, much nicer! | |
#include <SDL.h> | |
struct m_sdl { | |
int (*init)(Uint32); | |
SDL_Window* (*create_window)(const char*, int, int, int, int, Uint32); | |
void (*delay)(Uint32); | |
void (*destroy_window)(SDL_Window*); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example code to test out "JIT compilation" in (SBCL) CL | |
(defun foo (x f n) | |
"call f(f(f(...f(x)))) with f being called n times" | |
(dotimes (i n) | |
(setf x (funcall f x))) | |
x) | |
;; no type declarations | |
; Size: 186 bytes. Origin: #x1004C502AC | |
; 2AC: 498B4C2458 MOV RCX, [R12+88] ; no-arg-parsing entry point |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; also add mode to pull multiple symbols | |
(defmacro pull (symbols) | |
(if (listp symbols) | |
`(progn | |
,@(dolist (symbol symbols) | |
`(pull ,symbol))) | |
(if (symbolp symbols) | |
`(pull-helper ',symbols) | |
`(pull-helper ,symbols)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defclass graph () | |
((num :initarg :num :accessor num))) | |
(defmethod print-object ((object graph) stream) | |
(sdl2:with-init (:everything) | |
(sdl2:with-window (win :title "graphical print test" :flags '(:shown)) | |
(sdl2:with-renderer (renderer win :flags '()) | |
(sdl2:with-event-loop (:method :poll) | |
(:keydown (:keysym keysym) | |
(when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape) |