Skip to content

Instantly share code, notes, and snippets.

@cbaggers
cbaggers / enum.lisp
Last active February 20, 2018 18:34
enum issue
(defun blerp ()
(declare (optimize (speed 3) (safety 3) (debug 1)))
(%gl:depth-func :gequal))
; file: /private/var/tmp/slimeUxycfQ
; in: DEFUN BLERP
; (CL-OPENGL-BINDINGS:DEPTH-FUNC :GEQUAL)
; --> BLOCK MULTIPLE-VALUE-PROG1 CFFI:FOREIGN-FUNCALL LET LET IF
; ==>
; #:VALUE2
@cbaggers
cbaggers / extras.el
Last active January 16, 2018 14:51
little helpers
;; You might want to paste these in your .emacs file
;; when over one paren it shows it's match
(show-paren-mode t)
;; C-c ) jumps to the matching paren
(defun goto-match-paren (arg)
"Go to the matching if on (){}[], similar to vi style of % "
(interactive "p")
;; first, check for "outside of bracket" positions expected by forward-sexp, etc.
@cbaggers
cbaggers / emit-values.lisp
Created January 12, 2018 13:30
emit-values
;; like emit except it expects a values for for the data argument
(v-defmacro emit-values ((&key point-size) position data)
`(progn
,@(when point-size `((setf gl-point-size ,point-size)))
(setf gl-position ,position)
,@(when data `((emit-data ,data)))
(emit-vertex)))
@cbaggers
cbaggers / qdot.lisp
Created December 7, 2017 18:37
quaternion dot produce gpu function
(defun-g q:dot ((quat-a :vec4) (quat-b :vec4))
(+ (* (w quat-a) (w quat-b))
(* (x quat-a) (x quat-b))
(* (y quat-a) (y quat-b))
(* (z quat-a) (z quat-b))))
@cbaggers
cbaggers / compute-ssbo.lisp
Created November 25, 2017 20:00
first sign of compute working with ssbos
(in-package :test)
(defvar *data* nil)
(defvar *ssbo* nil)
(defstruct-g bah
(data (:int 100)))
(defun-g yay-compute (&uniform (woop bah :ssbo))
(declare (local-size :x 1 :y 1 :z 1))
<ERROR> [22:22:39] cl-bodge.host system.lisp (initialize-system :after host-system with-truncated-stack-lambda) -
Unhandled error:
WGL: Failed to create OpenGL context
[Condition of type SIMPLE-ERROR]
#<ENVIRONMENT {1007723AC3}>
[Environment of thread #<THREAD "main-thread" RUNNING {1006D66123}>]
Available restarts:
0: [CONTINUE] Skip flow block returning nil
baggers@alittlecave:~/Downloads/notalone$ ./notalone
<ERROR> [22:11:34] cl-bodge.concurrency execution.lisp (ignite h1) -
Uncaught error during task execution: GLX: Failed to make context current
Unhandled SIMPLE-CONDITION in thread #<SB-THREAD:THREAD "single-threaded-executor" RUNNING
{1006466B23}>:
SIMPLE-ERROR: GLX: Failed to make context current
Backtrace for: #<SB-THREAD:THREAD "single-threaded-executor" RUNNING {1006466B23}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SIMPLE-CONDITION "~A: ~A" {10038D5083}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SIMPLE-CONDITION "~A: ~A" {10038D5083}>)
@cbaggers
cbaggers / woo.lisp
Last active June 9, 2017 15:49
Hack swank to run repl in main thread
;; In swank-repl.lisp comment out the original #'spawn-repl-thread and paste this
;;
;; Props to Luis for the idea and Shinmera as I bodged the implementation of find-main-thread
;; from his trivial-main-thread library
(defun find-main-thread ()
(or
#+sbcl (find "main thread" (all-threads) :from-end T :key #'sb-thread:thread-name :test #'equal)
#+ecl (find 'si:top-level (all-threads) :from-end T :key #'mp:process-name)
#+ccl ccl::*initial-process*
@cbaggers
cbaggers / open-externally.el
Created May 28, 2017 21:54
open dired item externally
(defun open-file-externally ()
"In dired, open the file named on this line."
(interactive)
(let* ((file (dired-get-filename nil t)))
(message "Opening %s..." file)
(call-process "gnome-open" nil 0 nil file) ;; switch gnome-open to whatever you prefer. xdg-open is probably sensible
(message "Opening %s done" file)))
(add-hook 'dired-mode-hook
(lambda ()
(defun test-issue (compiled-stages prog-id)
(register-lambda-pipeline
compiled-stages
(let* ((image-unit -1)
(implicit-uniform-upload-func
(or (%create-implicit-uniform-uploader compiled-stages 'nil)
#'fallback-iuniform-func)))
(declare
(ignorable image-unit)
(type function implicit-uniform-upload-func))