Changeset 33109 in project


Ignore:
Timestamp:
01/21/16 19:06:35 (3 years ago)
Author:
jacius
Message:

sdl2: Added docs about version feature identifiers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/sdl2

    r33100 r33109  
    26342634See [[https://wiki.libsdl.org/SDL_GL_ResetAttributes|SDL_GL_ResetAttributes]].
    26352635
    2636 Requires SDL 2.0.2 or higher. Signals an error if the compiled version
    2637 of SDL is not high enough. Use {{(version-at-least? 2 0 2)}} to
    2638 check before calling this procedure.
     2636Requires '''SDL 2.0.2 or higher'''.
     2637Signals an error if the compiled version of SDL is not high enough.
     2638Use the [[#version-feature-identifiers|{{libSDL-2.0.2+}} feature identifier]]
     2639to check before calling this procedure.
    26392640
    26402641
     
    26452646This procedure returns multiple values.
    26462647
    2647 Requires SDL 2.0.1 or higher. Signals an error if the compiled version
    2648 of SDL is not high enough. Use {{(version-at-least? 2 0 1)}} to
    2649 check before calling this procedure.
     2648Requires '''SDL 2.0.1 or higher'''.
     2649Signals an error if the compiled version of SDL is not high enough.
     2650Use the [[#version-feature-identifiers|{{libSDL-2.0.1+}} feature identifier]]
     2651to check before calling this procedure.
    26502652
    26512653
     
    29162918It requires '''SDL 2.0.4 or higher'''.
    29172919It signals an error if the compiled version of SDL is not high enough.
    2918 Use {{(version-at-least? 2 0 4)}} to check before calling this procedure.
     2920Use the [[#version-feature-identifiers|{{libSDL-2.0.4+}} feature identifier]]
     2921to check before calling this procedure.
    29192922
    29202923
     
    34133416or #f is clipping is disabled.
    34143417See [[https://wiki.libsdl.org/SDL_RenderIsClipEnabled|SDL_RenderIsClipEnabled]].
    3415 
    34163418This procedure is available in '''sdl2 egg version 0.2.0 and higher'''.
    3417 It requires '''SDL 2.0.4 or higher'''.
    3418 It signals an error if the compiled version of SDL is not high enough.
    3419 Use {{(version-at-least? 2 0 4)}} to check before calling this procedure.
     3419
     3420Requires '''SDL 2.0.4 or higher'''.
     3421Signals an error if the compiled version of SDL is not high enough.
     3422Use the [[#version-feature-identifiers|{{libSDL-2.0.4+}} feature identifier]]
     3423to check before calling this procedure.
    34203424
    34213425
     
    41424146=== Version
    41434147
     4148==== Version Feature Identifiers
     4149
     4150In '''sdl2 egg version 0.2.0 and higher''', the egg automatically registers feature identifiers
     4151which can be used to detect the versions of the sdl2 egg and SDL at compile time or run time,
     4152for example using the {{cond-expand}} macro, {{#+foo}} syntax, or the {{feature?}} procedure.
     4153
     4154Some or all of the following feature identifiers will be registered depending on the circumstances:
     4155
     4156<table>
     4157  <tr>
     4158    <th>Feature ID</th>
     4159    <th>Meaning</th>
     4160  </tr>
     4161  <tr>
     4162    <td>sdl2</td>
     4163    <td>Using any version of the sdl2 egg</td>
     4164  <tr>
     4165  <tr>
     4166    <td>sdl2-0.2.0+</td>
     4167    <td>Using sdl2 egg 0.2.0 or higher</td>
     4168  <tr>
     4169  <tr>
     4170    <td>libSDL-2.0.0+</td>
     4171    <td>The sdl2 egg was compiled with SDL 2.0.0 or higher</td>
     4172  <tr>
     4173  <tr>
     4174    <td>libSDL-2.0.1+</td>
     4175    <td>... 2.0.1 or higher</td>
     4176  <tr>
     4177  <tr>
     4178    <td>libSDL-2.0.2+</td>
     4179    <td>... 2.0.2 or higher</td>
     4180  <tr>
     4181  <tr>
     4182    <td>libSDL-2.0.3+</td>
     4183    <td>... 2.0.3 or higher</td>
     4184  <tr>
     4185  <tr>
     4186    <td>libSDL-2.0.4+</td>
     4187    <td>... 2.0.4 or higher</td>
     4188  </tr>
     4189</table>
     4190
     4191These are cumulative, so if you are using the latest version of the sdl2 egg and the latest version of SDL, all of the above identifiers will be defined.
     4192
     4193Here are some examples of how you can use these identifiers:
     4194
     4195<enscript highlight="scheme">
     4196(use (prefix sdl2 sdl2:))
     4197
     4198;; Compile time check using #+foo reader syntax:
     4199#+(not sdl2-0.2.0+)
     4200(begin-for-syntax
     4201  (error "You need sdl2 egg 0.2.0 or higher to compile this program."))
     4202
     4203;; Compile-time check using cond-expand macro:
     4204(cond-expand
     4205 (libSDL-2.0.4+
     4206  (include "file-that-needs-SDL-204.scm"))
     4207 (else
     4208  (include "alternative-file.scm")))
     4209
     4210;; Run-time check using feature? procedure:
     4211(when (feature? 'sdl2)
     4212  (print "You are using the sdl2 egg. The future seems bright."))
     4213</enscript>
     4214
     4215
     4216==== Version Functions
     4217
    41444218<procedure>(version-at-least? major minor patch) → boolean</procedure>
    41454219
     
    41714245<constant>(egg-version) → list of integers</constant>
    41724246
    4173 Returns a list of three nonnegative integers, indicating the version number of the sdl2 egg itself, which is independent of the version number of SDL.
    4174 For example, the list {{'(1 2 3)}} indicates sdl2 egg version 1.2.3.
     4247Returns a list of three nonnegative integers,
     4248indicating the version number of the sdl2 egg itself,
     4249which is independent of the version number of SDL.
     4250For example, the list {{'(1 2 3)}} means sdl2 egg version 1.2.3.
    41754251
    41764252'''NOTE:''' This procedure is available in '''sdl2 egg version 0.2.0 or later'''.
    4177 If you want to check the egg version, but users of your program might be using earlier than egg version 0.2.0,
    4178 you can define and use the following procedure in your program:
     4253If you want to check the egg version,
     4254but users of your program might be using earlier than egg version 0.2.0,
     4255you can add the following code to your program.
     4256It will define the {{egg-version}} procedure only if using an earlier version of the sdl2 egg.
    41794257
    41804258<enscript highlight="scheme">
    4181 ;; Return sdl2 egg version if possible, otherwise return '(0 1 0).
    4182 (define (get-sdl2-egg-version)
    4183   (condition-case (sdl2#egg-version)
    4184     (() '(0 1 0))))
     4259(use (prefix sdl2 sdl2:))
     4260
     4261#+(not sdl2-0.2.0+)
     4262(define (sdl2:egg-version) '(0 1 1))
     4263
     4264;; Usage:
     4265(printf "You are using sdl2 egg version ~S.~%" (sdl2:egg-version))
    41854266</enscript>
    41864267
Note: See TracChangeset for help on using the changeset viewer.