File canvas-draw/racket/native.rkt artifact c102ec574f part of check-in 44f8109293


#lang racket
(require
 ffi/unsafe
 "base.rkt")

(define libcd-native
  (case (system-type 'os)
    [(unix macosx)
     (ffi-lib "libcdx11")]
    [(windows)
     (ffi-lib "cd")]
    [else
     (ffi-lib "libcd")]))

(define libcd-context+
  (case (system-type 'os)
    [(windows)
     (ffi-lib "cdcontextplus")]
    [else
     (ffi-lib "libcdcontextplus")]))

;; {{{ Context types

(define context:native-window
  ((get-ffi-obj "cdContextNativeWindow" libcd-native (_fun -> [context : _context]))))

(provide
 context:native-window)

;; }}}

;; {{{ Auxiliary functions

(define screen-size
  (get-ffi-obj
   "cdGetScreenSize" libcd-native
   (_fun [width/px : (_ptr o _int)] [height/px : (_ptr o _int)]
         [width/mm : (_ptr o _double)] [height/mm : (_ptr o _double)]
         -> _void
         -> (values
             width/px height/px
             width/mm height/mm))))

(provide
 screen-size)

;; }}}

;; {{{ Library initialization

((get-ffi-obj
  "cdInitContextPlus" libcd-context+
  (_fun -> _void)))

;; }}}