Welcome to the CHICKEN Scheme pasting service
nuklear hello-world segfault added by megane on Sat Feb 9 15:23:47 2019
(use (prefix glfw3 glfw:) (prefix opengl-glew gl:) (prefix nuklear nk:)) (require-library nuklear-glfw-opengl2) (import (prefix nuklear-glfw-opengl2 backend:)) (define width 250) (define height 150) (glfw:init) (glfw:make-window width height "Hello World") (glfw:make-context-current (glfw:window)) (set!-values (width height) (glfw:get-window-size (glfw:window))) (define context (backend:init! (glfw:window) #t)) (backend:init-font!) (define quit? #f) (define show-greeting? #f) (define layout (nk:make-panel)) (define popup-layout (nk:make-panel)) (define garbage #f) (let loop () (when (and (not (glfw:window-should-close (glfw:window))) (not quit?)) (glfw:poll-events) (backend:new-frame) (when (nk:window-begin context layout "Hello World!" (nk:make-rect 10 10 192 100) '(border no-scrollbar movable)) (when (= 0 (random 10)) (print* "GC") (gc #t) (when (= 0 (random 2)) (print* "2") (set! garbage (make-blob (random 100000))) (gc #t))) (nk:layout-row-dynamic context 30 2) (when (nk:button-label context "Click Me!") (printf "Yay\n") (set! show-greeting? #t)) (when (nk:button-label context "Quit") (set! quit? #t)) (when show-greeting? (if (nk:popup-begin context popup-layout #f "Greeting" '(dynamic) (nk:make-rect 15 50 200 150)) (begin (nk:layout-row-dynamic context 25 1) (nk:label context "Hello World!" 'centered) (nk:layout-row-dynamic context 25 1) (when (nk:button-label context "OK") (set! show-greeting? #f) (nk:popup-close context)) (nk:popup-end context)) (set! show-greeting? #f)))) (nk:window-end context) (let-values (((width height) (glfw:get-window-size (glfw:window)))) (gl:viewport 0 0 width height)) (gl:clear gl:+color-buffer-bit+) (gl:clear-color (/ 28 255) (/ 48 255) (/ 62 255) 0) (backend:render!) (glfw:swap-buffers (glfw:window)) (loop))) (backend:shutdown!) (glfw:terminate) ;; $ hg diff hello-world.scm ;; diff -r 980803bb2342 4/nuklear/examples/hello-world/hello-world.scm ;; --- a/4/nuklear/examples/hello-world/hello-world.scm Sun Jan 20 09:19:01 2019 +0200 ;; +++ b/4/nuklear/examples/hello-world/hello-world.scm Sat Feb 09 16:20:48 2019 +0200 ;; @@ -21,6 +21,7 @@ ;; ;; (define layout (nk:make-panel)) ;; (define popup-layout (nk:make-panel)) ;; +(define garbage #f) ;; ;; (let loop () ;; (when (and (not (glfw:window-should-close (glfw:window))) (not quit?)) ;; @@ -30,6 +31,10 @@ ;; (when (nk:window-begin context layout "Hello World!" ;; (nk:make-rect 10 10 192 100) ;; '(border no-scrollbar movable)) ;; + (when (= 0 (random 10)) (print* "GC") (gc #t) ;; + (when (= 0 (random 2)) (print* "2") ;; + (set! garbage (make-blob (random 100000))) ;; + (gc #t))) ;; (nk:layout-row-dynamic context 30 2) ;; (when (nk:button-label context "Click Me!") ;; (printf "Yay\n")