Changeset 37235 in project


Ignore:
Timestamp:
02/14/19 00:10:25 (5 months ago)
Author:
jacius
Message:

Update sdl2 wiki for version 0.3.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/sdl2

    r37226 r37235  
    2727This egg needs volunteers to help with several things:
    2828
     29* Adding bindings to more SDL features.
    2930* Manual testing (installing, running examples) on different platforms
    3031* Writing unit tests and semi-automated test programs
     
    4243
    4344This egg requires CHICKEN Scheme 4.8 or higher.
    44 As of version 0.3.0, it is compatible with both CHICKEN 4 and CHICKEN 5.
     45As of version 0.3.0, this egg is compatible with both CHICKEN 4 and CHICKEN 5.
    4546
    4647The unit tests depend on the [[/egg/test|test]] egg.
     
    5051== Related Libraries
    5152
    52 The [[/egg/sdl2-image|sdl2-image egg]] provides bindings to version 2 of the SDL_image library, which provides the ability to load many image formats. It is built to be compatible with sdl2.
    53 
    54 The [[/egg/sdl2-ttf|sdl2-ttf egg]] provides bindings to version 2 of the SDL_ttf library, which provides the ability to render text using TTF and FON fonts. It is built to be compatible with sdl2.
    55 
    56 The [[/egg/sdl-base|sdl-base egg]] provides bindings to older versions of SDL. Its API is not compatible with sdl2.
     53The [[/egg/sdl2-image|sdl2-image egg]] provides bindings to [[http://www.libsdl.org/projects/SDL_image/|SDL_image]] version 2, which provides the ability to load many image formats. It is built to be compatible with the sdl2 egg.
     54
     55The [[/egg/sdl2-ttf|sdl2-ttf egg]] provides bindings to [[https://www.libsdl.org/projects/SDL_ttf/|SDL_ttf]] version 2, which provides the ability to render text using TTF, OTF, and FON fonts. It is built to be compatible with the sdl2 egg.
     56
     57The [[/egg/sdl-base|sdl-base egg]] provides bindings to older versions of SDL. Its API is not compatible with the sdl2 egg.
    5758
    5859
     
    7576
    7677These environment variables are needed only when installing the egg itself.
    77 They are not needed when compiling or running games that use the egg.
     78They are not needed when compiling or running programs that use the egg.
    7879
    7980=== Installing on macOS
     
    9495If the framework is installed in some other directory,
    9596or if you want to force using the framework even when {{sdl2-config}} is available,
    96 you must set the {{SDL2_CFLAGS}} and {{SDL2_LDFLAGS}} enviroment variables
     97set the {{SDL2_CFLAGS}} and {{SDL2_LDFLAGS}} enviroment variables
    9798to tell the compiler where to find the framework:
    9899
     
    103104== Usage and Examples
    104105
    105 It is recommended that you import the sdl2 module using the prefix
    106 "sdl2:", like so:
     106It is recommended that you import the sdl2 module using the prefix "sdl2:", like so:
    107107
    108108<enscript highlight="scheme">
    109 ;; Works in both CHICKEN 4 and CHICKEN 5.
     109;; Compatible with both CHICKEN 4 and CHICKEN 5.
    110110(cond-expand
    111111 (chicken-4 (use (prefix sdl2 "sdl2:")))
     
    171171== Version History
    172172
     173; 0.3.0 (2019-02-13) : Ported to be compatible with both CHICKEN 4 and CHICKEN 5. More user-friendly installation process. Bug fixes.
    173174; 0.2.0 (2016-02-13) : Added 2D accelerated rendering (renderer and texture). Added hints. Added color, point, and rect operations. Performance improvements. Improved integer type checking. Miscellaneous other changes.
    174175; 0.1.1 (2015-12-22) : Fixed a compile error when compiling with GCC 4.
     
    188189Until version 1.0.0 is released, the API is not guaranteed to be "stable".
    189190That means the maintainer reserves the right to change the API if needed,
    190 possibly in ways that break backwards compatibility with previous versions.
    191 '''Large backwards-incompatible changes are unlikely''',
     191possibly in ways that break backward compatibility with previous versions.
     192'''Large backward-incompatible changes are unlikely''',
    192193but there may be small tweaks and fixes to the API if problems are discovered.
    193194
    194 After version 1.0.0 is released, the API is guaranteed to remain stable (no backwards-incompatible changes)
     195After version 1.0.0 is released, the API is guaranteed to remain stable (no backward-incompatible changes)
    195196until the next new major version (e.g. going from version 1.x to 2.0.0, or 2.x to 3.0.0).
    196197
     
    321322
    322323This procedure can be used with any struct record type provided by this library,
    323 or related libraries such as [[/egg/sdl2-ttf|sdl2-ttf]].
     324or related libraries such as [[/egg/sdl2-image|sdl2-image]] and [[/egg/sdl2-ttf|sdl2-ttf]].
    324325
    325326This procedure is the only reliable way to compare the identities of struct records
     
    334335i.e. it has a pointer to memory address 0.
    335336This procedure can be used with any struct record type provided by this library,
    336 or related libraries such as [[/egg/sdl2-ttf|sdl2-ttf]].
     337or related libraries such as [[/egg/sdl2-image|sdl2-image]] and [[/egg/sdl2-ttf|sdl2-ttf]].
    337338
    338339A struct record will be null after you manually free its memory, e.g. using {{free-surface!}}.
     
    580581<procedure>(colour-mult! color1 color2 #!optional dest) → dest</procedure>
    581582
    582 Efficiently multiply-blend {{color1}} by {{color2}}.
     583Efficiently multiply-blend {{color1}} with {{color2}}.
    583584This is equivalent to the "multiply" blend mode of image editors,
    584585where {{color1}} is the bottom layer and {{color2}} is the top layer.
     
    606607<procedure>(colour-add! color1 color2 #!optional dest) → dest</procedure>
    607608
    608 Efficiently add-blend {{color1}} by {{color2}}.
     609Efficiently add-blend {{color1}} with {{color2}}.
    609610This is equivalent to the "addition" blend mode of image editors,
    610611where {{color1}} is the bottom layer and {{color2}} is the top layer.
     
    630631<procedure>(colour-sub! color1 color2 #!optional dest) → dest</procedure>
    631632
    632 Efficiently subtract-blend {{color1}} by {{color2}}.
     633Efficiently subtract-blend {{color1}} with {{color2}}.
    633634This is equivalent to the "subtract" blend mode of image editors,
    634635where {{color1}} is the bottom layer and {{color2}} is the top layer.
     
    40754076These procedures are available in '''sdl2 egg version 0.2.0 and higher'''.
    40764077
    4077 * {{render-scale}} returns multiple values, the x and y scaling factors, as integers..
    4078 * The setters accept a list {{(x-scale y-scale)}} containing the new scaling factors, as integers.
     4078* {{render-scale}} returns multiple values, the x and y scaling factors, as floats.
     4079* The setters accept a list {{(x-scale y-scale)}} containing the new scaling factors, as floats.
    40794080
    40804081
     
    50755076
    50765077In '''sdl2 egg version 0.2.0 and higher''', the egg registers feature identifiers
    5077 which can be used to detect the versions of the sdl2 egg and SDL at compile time or run time,
    5078 using the {{cond-expand}} macro, {{#+foo}} syntax, or the {{feature?}} procedure.
     5078which can be used to detect the versions of the sdl2 egg and SDL
     5079at run time using the the {{feature?}} procedure,
     5080or at compile time using the {{cond-expand}} macro or {{#+foo}} syntax.
    50795081
    50805082Some or all of the following feature identifiers will be registered depending on the circumstances:
     
    51245126
    51255127<enscript highlight="scheme">
     5128;; use-for-syntax (on CHICKEN 4) or import-for-syntax (on CHICKEN 5)
     5129;; to make the feature identifiers available at compile time.
    51265130(cond-expand
    51275131 (chicken-4 (use (prefix sdl2 "sdl2:"))
     
    51305134            (import-for-syntax sdl2)))
    51315135
     5136;; Run-time check using feature? procedure:
     5137(when (feature? 'sdl2)
     5138  (print "You are using the sdl2 egg. The future seems bright."))
     5139
    51325140;; Compile time check using #+foo reader syntax:
    51335141#+(not sdl2-0.2.0+)
    51345142(begin-for-syntax
    5135   (error "You need sdl2 egg 0.2.0 or higher to compile this program."))
     5143  (error "You need sdl2 egg 0.2.0 or higher."))
    51365144
    51375145;; Compile-time check using cond-expand macro:
     
    51415149 (else
    51425150  (include "alternative-file.scm")))
    5143 
    5144 ;; Run-time check using feature? procedure:
    5145 (when (feature? 'sdl2)
    5146   (print "You are using the sdl2 egg. The future seems bright."))
    51475151</enscript>
    51485152
     
    51695173* {{current-version}} returns the version of SDL that the sdl2 egg is currently using.
    51705174
    5171 For example, the user may have compiled the sdl2 egg with SDL 2.0.3, then later upgraded SDL to 2.1.0, but not yet recompiled the sdl2 egg with the new version.
    5172 In such a case, {{compiled-version}} would return {{(2 0 3)}}, and {{current-version}} would return {{(2 1 0)}}.
     5175For example, the user may have compiled the sdl2 egg with SDL 2.0.3, then later upgraded SDL to 2.0.4, but not yet recompiled the sdl2 egg with the new version.
     5176In such a case, {{compiled-version}} would return {{(2 0 3)}}, and {{current-version}} would return {{(2 0 4)}}.
    51735177But, features from the new version would not be available until the user recompiles the sdl2 egg.
    51745178
     
    51825186indicating the version number of the sdl2 egg itself,
    51835187which is independent of the version number of SDL.
    5184 For example, the list {{'(1 2 3)}} means sdl2 egg version 1.2.3.
    5185 
    5186 '''NOTE:''' This procedure is available in '''sdl2 egg version 0.2.0 or higher'''.
    5187 If you want to check the egg version,
    5188 but users of your program might be using earlier than egg version 0.2.0,
    5189 you can add the following code to your program.
    5190 It will define the {{egg-version}} procedure only if using an earlier version of the sdl2 egg.
    5191 
    5192 <enscript highlight="scheme">
    5193 (cond-expand
    5194  (chicken-4 (use (prefix sdl2 "sdl2:")))
    5195  (chicken-5 (import (prefix sdl2 "sdl2:"))))
    5196 
    5197 #+(not sdl2-0.2.0+)
    5198 (define (sdl2:egg-version) '(0 1 1))
    5199 
    5200 ;; Usage:
    5201 (printf "You are using sdl2 egg version ~S.~%" (sdl2:egg-version))
    5202 </enscript>
     5188For example, the list {{(1 2 3)}} indicates sdl2 egg version 1.2.3.
     5189
     5190This procedure is available in '''sdl2 egg version 0.2.0 and higher'''.
    52035191
    52045192
Note: See TracChangeset for help on using the changeset viewer.