File canvas-draw/chicken/canvas-draw-native.scm artifact 54e46d244f part of check-in b1dcd0ebc6


(require-library canvas-draw-base)

(module canvas-draw-native
	(context:native-window
	 screen-size)
	(import scheme chicken foreign canvas-draw-base)

;; {{{ Data types

(foreign-declare
	"#include <cd.h>\n"
	"#include <cdnative.h>\n")

(include "canvas-draw-types.scm")

;; }}}

;; {{{ Context types

(define context:native-window
	(foreign-value "CD_NATIVEWINDOW" nonnull-context))

;; }}}

;; {{{ Auxiliary functions

(define screen-size
	(letrec ([screen-size/raw (foreign-lambda void "cdGetScreenSize" (c-pointer int) (c-pointer int) (c-pointer double) (c-pointer double))])
		(lambda ()
			(let-location ([width/px int 0] [height/px int 0]
			               [width/mm double 0] [height/mm double 0])
			  (screen-size/raw
			  	(location width/px) (location height/px)
			  	(location width/mm) (location height/mm))
			  (values
			  	width/px height/px
			  	width/mm height/mm)))))

;; }}}

;; {{{ Library initialization

(foreign-code "cdInitContextPlus();")

;; }}}

)