Changeset 32860 in project


Ignore:
Timestamp:
11/04/15 13:10:35 (4 years ago)
Author:
John Croisant
Message:

sdl2: Changes related to rwops.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/sdl2

    r32858 r32860  
    32353235See [[https://wiki.libsdl.org/SDL_RWFromFile|SDL_RWFromFile]].
    32363236
     3237You should close the sdl2:rwops when you are done with it, using
     3238{{rw-close!}} or one of the procedures that can automatically close
     3239the sdl2:rwops, such as {{load-bmp-rw}}.
     3240
    32373241
    32383242<procedure>(rw-from-const-mem pointer) → sdl2:rwops</procedure>
     
    32403244See [[https://wiki.libsdl.org/SDL_RWFromConstMem|SDL_RWFromConstMem]].
    32413245
     3246You should close the sdl2:rwops when you are done with it, using
     3247{{rw-close!}} or one of the procedures that can automatically close
     3248the sdl2:rwops, such as {{load-bmp-rw}}.
     3249
    32423250
    32433251<procedure>(rw-from-mem pointer) → sdl2:rwops</procedure>
     
    32453253See [[https://wiki.libsdl.org/SDL_RWFromMem|SDL_RWFromMem]].
    32463254
     3255You should close the sdl2:rwops when you are done with it, using
     3256{{rw-close!}} or one of the procedures that can automatically close
     3257the sdl2:rwops, such as {{load-bmp-rw}}.
     3258
    32473259
    32483260<procedure>(rw-from-blob blob) → sdl2:rwops</procedure>
    32493261
     3262Create a new sdl2:rwops that accesses the memory of the given
     3263[[http://wiki.call-cc.org/man/4/Unit%20library#blobs|blob]]. You
     3264should close the sdl2:rwops when you are done with it, using
     3265{{rw-close!}} or one of the procedures that can automatically close
     3266the sdl2:rwops, such as {{load-bmp-rw}}.
     3267
     3268You can also use this procedure to create a sdl2:rwops from a
     3269[[/man/4/Unit srfi-4|SRFI-4]] numeric vector, by first converting it
     3270to a blob using e.g. {{u8vector->blob/shared}}.
     3271
     3272'''CAUTION:''' Creating a sdl2:rwops from a blob in CHICKEN-managed
     3273memory is unstable: the blob might be garbage collected or moved in
     3274memory, which would break the sdl2:rwops. To be safe, you should
     3275[[/man/4/Unit lolevel#object-evict|evict]] the blob and create the
     3276sdl2:rwops from the evicted blob (not the original). You may wish to
     3277[[/man/4/Unit lolevel#object-release|release]] the evicted blob after
     3278you have closed the sdl2:rwops. Example:
     3279
     3280<enscript highlight="scheme">
     3281(let* ((evicted-blob (object-evict '#${...}))
     3282       (rwops (sdl2:rw-from-blob evicted-blob))
     3283       (surf (sdl2:load-bmp-rw rwops #t)))
     3284  (object-release evicted-blob)
     3285  surf)
     3286</enscript>
     3287
     3288
     3289<procedure>(rw-from-string str) → sdl2:rwops</procedure>
     3290
    32503291Create a new sdl2:rwops that accesses the memory of the given CHICKEN
    3251 Scheme blob.
    3252 
    3253 '''CAUTION:''' You must make sure that the blob remains in scope for
    3254 at least as long as the resulting sdl2:rwops is open. If the blob is
    3255 garbage collected before the sdl2:rwops, the program may crash if you
    3256 try to read or write from the sdl2:rwops.
    3257 
    3258 
    3259 <procedure>(rw-from-string str) → sdl2:rwops</procedure>
    3260 
    3261 Create a new sdl2:rwops that accesses the memory of the given CHICKEN
    3262 Scheme string.
    3263 
    3264 '''CAUTION:''' You must make sure that the string remains in scope for
    3265 at least as long as the resulting sdl2:rwops is open. If the string is
    3266 garbage collected before the sdl2:rwops, the program may crash if you
    3267 try to read or write from the sdl2:rwops.
    3268 
    3269 
    3270 <procedure>(rw-from-u8vector u8v) → sdl2:rwops</procedure>
    3271 
    3272 Create a new sdl2:rwops that accesses the memory of the given
    3273 [[/man/4/Unit srfi-4|SRFI-4]] u8vector.
    3274 
    3275 '''CAUTION:''' You must make sure that the u8vector remains in scope
    3276 for at least as long as the resulting sdl2:rwops is open. If the
    3277 u8vector is garbage collected before the sdl2:rwops, the program may
    3278 crash if you try to read or write from the sdl2:rwops.
     3292Scheme string. You should close the sdl2:rwops when you are done with
     3293it, using {{rw-close!}} or one of the procedures that can
     3294automatically close the sdl2:rwops, such as {{load-bmp-rw}}.
     3295
     3296'''CAUTION:''' Creating a sdl2:rwops from a string in CHICKEN-managed
     3297memory is unstable: the string might be garbage collected or moved in
     3298memory, which would break the sdl2:rwops. To be safe, you should
     3299[[/man/4/Unit lolevel#object-evict|evict]] the string and create the
     3300sdl2:rwops from the evicted string (not the original). You may wish to
     3301[[/man/4/Unit lolevel#object-release|release]] the evicted string
     3302after you have closed the sdl2:rwops. Example:
     3303
     3304<enscript highlight="scheme">
     3305(let* ((evicted-string (object-evict "..."))
     3306       (rwops (sdl2:rw-from-string evicted-string))
     3307       (surf (sdl2:load-bmp-rw rwops #t)))
     3308  (object-release evicted-string)
     3309  surf)
     3310</enscript>
    32793311
    32803312
     
    32843316
    32853317Close and clean up the given sdl2:rwops. This frees the memory used by
    3286 the SDL_RWops struct itself, but does not free the original pointer,
    3287 blob, string, or u8vector. (It does close files, though.)
     3318the SDL_RWops struct itself, but does not free or release the pointer,
     3319blob, or string that the sdl2:rwops was reading/writing from. (It does
     3320close files opened with {{rw-from-file}}, though.)
    32883321
    32893322Returns zero if successful.
Note: See TracChangeset for help on using the changeset viewer.