Changeset 20640 in project


Ignore:
Timestamp:
10/04/10 10:20:08 (10 years ago)
Author:
felix winkelmann
Message:

squares fixes and bind version

Location:
demonstrations/foreign-functions
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • demonstrations/foreign-functions/squares-plain.scm

    r20585 r20640  
    1 ;;;; squares.scm - draw random squares
    2 
    3 
    4 (use foreigners)
     1;;;; squares-plain.scm - draw random squares
    52
    63
     
    2724;;; Foreign record types
    2825
    29 (define-foreign-record-type (sdl-rect SDL_Rect)
    30   (constructor: make-sdl-rect)
    31   (short x sdl-rect-x sdl-rect-x-set!)
    32   (short y sdl-rect-y sdl-rect-y-set!)
    33   (unsigned-short w sdl-rect-w sdl-rect-w-set!)
    34   (unsigned-short h sdl-rect-h sdl-rect-h-set!) )
     26(define-foreign-type sdl-rect (c-pointer "SDL_Rect"))
    3527
    36 (define-foreign-record-type (sdl-surface SDL_Surface)
    37   ((c-pointer "SDL_PixelFormat") format sdl-surface-format))
     28(define make-sdl-rect
     29  (foreign-lambda* sdl-rect ()
     30    "C_return((SDL_Rect *)malloc(sizeof(SDL_Rect)));"))
    3831
    39 (define-foreign-record-type (sdl-event SDL_Event)
    40   (constructor: make-sdl-event)
    41   (int type sdl-event-type))
     32(define sdl-rect-x
     33  (foreign-lambda* short ((sdl-rect r)) "C_return(r->x);"))
     34
     35(define sdl-rect-y
     36  (foreign-lambda* short ((sdl-rect r)) "C_return(r->y);"))
     37
     38(define sdl-rect-x-set!
     39  (foreign-lambda* void ((sdl-rect r) (short n)) "r->x = n;"))
     40
     41(define sdl-rect-y-set!
     42  (foreign-lambda* void ((sdl-rect r) (short n)) "r->y = n;"))
     43
     44(define sdl-rect-w
     45  (foreign-lambda* unsigned-short ((sdl-rect r)) "C_return(r->w);"))
     46
     47(define sdl-rect-h
     48  (foreign-lambda* unsigned-short ((sdl-rect r)) "C_return(r->w);"))
     49
     50(define sdl-rect-w-set!
     51  (foreign-lambda* void ((sdl-rect r) (unsigned-short n)) "r->w = n;"))
     52
     53(define sdl-rect-h-set!
     54  (foreign-lambda* void ((sdl-rect r) (unsigned-short n)) "r->h = n;"))
     55
     56(define-foreign-type sdl-surface (c-pointer "SDL_Surface"))
     57(define-foreign-type sdl-pixel-format (c-pointer "SDL_PixelFormat"))
     58
     59(define sdl-surface-format
     60  (foreign-lambda* sdl-pixel-format ((sdl-surface s)) "C_return(s->format);"))
     61
     62(define-foreign-type sdl-event (c-pointer "SDL_Event"))
     63
     64(define make-sdl-event
     65  (foreign-lambda* sdl-event ()
     66    "C_return((SDL_Event *)malloc(sizeof(SDL_Event)));"))
     67
     68(define sdl-event-type
     69  (foreign-lambda* int ((sdl-event e)) "C_return(e->type);"))
    4270
    4371
     
    4876
    4977(define SDL_SetVideoMode
    50   (foreign-lambda sdl-screen "SDL_SetVideoMode" int int int unsigned-int32))
     78  (foreign-lambda sdl-surface "SDL_SetVideoMode" int int int unsigned-int32))
    5179
    5280(define SDL_FillRect
Note: See TracChangeset for help on using the changeset viewer.