1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
|
@menu
* Basics:: Initialization and other basic things.
* Window Management:: Working with the window system.
* Input:: Keyboard, mouse, joystick input.
* Events:: Asynchronous event handling.
* Rects:: 2D rectangles.
* Surfaces:: Software rendering.
* Rendering:: Hardware accelerated rendering.
* Blend Modes:: Color blending.
* Images:: Loading and saving images.
* Sound:: Sound effects and music.
* Fonts:: Truetype and bitmap font rendering.
@end menu
@node Basics
@section Basics
@example
(use-modules (sdl2))
@end example
@deffn {Procedure} sdl-init [@var{subsystems}]
Initialize the SDL library. This must be called before using any
other SDL procedure.
@var{subsystems} is an optional list of symbols that specifies the
subsystems to initialize. All subsystems are initialized by default.
The possible flags are @code{timer}, @code{audio}, @code{video},
@code{haptic}, @code{game-controller}, and @code{events}.
@end deffn
@deffn {Procedure} sdl-quit
Quit all activated SDL subsystems. This procedure should be called
upon all exit conditions.
@end deffn
@deffn {Procedure} sdl-version
Return a three element list containing the major, minor, and patch
version of the linked SDL library.
@end deffn
@deffn {Procedure} sdl-ticks
Return the number of milliseconds since the SDL library was
initialized.
@end deffn
@node Window Management
@section Window Management
@menu
* Windows:: Window manipulation.
* OpenGL:: OpenGL contexts.
@end menu
@example
(use-modules (sdl2 video))
@end example
@node Windows
@subsection Windows
@deffn {Procedure} make-window [#:title "Guile SDL2 Window"] @
[#:position (#f #f)] @
[#:size (640 480)] @
[#:maximize? #f] @
[#:minimize? #f] @
[#:opengl? #f] @
[#:border? #t] @
[#:fullscreen? #f] @
[#:fullscreen-desktop? #f] @
[#:grab-input? #f] @
[#:high-dpi? #f]
Create a new window named @var{title} with dimensions @var{size} located
at @var{position} on the display. @var{position} and @var{size} are
two-element lists in the form @code{(x y)}, where each coordinate is
measured in pixels. In the case of @var{position}, a coordinate may use
the special symbol @var{center} to indicate that the window should be
centered on that axis, or @code{#f} to indicate that it does not matter
where the window is located on that axis.
@end deffn
@deffn {Procedure} close-window! window
Close @var{window}.
@end deffn
@deffn {Procedure} call-with-window window proc
Call @var{proc} with @var{window}, an SDL window object, and close it
when @var{proc} returns or otherwise exits.
@end deffn
@deffn {Procedure} window-title window
Return the title for @var{window}.
@end deffn
@deffn {Procedure} window-size window
Return 2 values for the dimensions of @var{window}.
@end deffn
@deffn {Procedure} window-minimum-size window
Return 2 values for the minimal dimensions that @var{window} can be.
Note that SDL does not always enforce this restriction, so you might
end up with a window size that is actually smaller than the value
returned by this procedure.
@end deffn
@deffn {Procedure} window-maximum-size window
Return 2 values for the maximum dimensions that @var{window} can be.
@end deffn
@deffn {Procedure} window-position window
Return 2 values for the position of @var{window} on the display.
@end deffn
@deffn {Procedure} window-id window
Return the numeric ID of @var{window}.
@end deffn
@deffn {Procedure} id->window id
Return the window corresponding to @var{ID}, a positive integer, or
@code{#f} if there is no such window.
@end deffn
@deffn {Procedure} hide-window! window
Hide @var{window}.
@end deffn
@deffn {Procedure} show-window! window
Show @var{window} and focus on it.
@end deffn
@deffn {Procedure} maximize-window! window
Make @var{window} as large as possible.
@end deffn
@deffn {Procedure} minimize-window! window
Shrink @var{window} to an iconic representation.
@end deffn
@deffn {Procedure} raise-window! window
Raise @var{window} above all other windows and set input focus.
@end deffn
@deffn {Procedure} restore-window! window
Restore the size and position of a minimized or maximized @var{window}.
@end deffn
@deffn {Procedure} set-window-border! window border?
When @var{border?}, draw the usual border around @var{window}, otherwise
remove the border.
@end deffn
@deffn {Procedure} set-window-title! window title
Set the title of @var{window} to the string @var{title}.
@end deffn
@deffn {Procedure} set-window-position! window x y
Set the position of @var{window} to (@var{x}, @var{y}).
@end deffn
@deffn {Procedure} set-window-size! window width height
Set the dimensions of @var{window} to @var{width} x @var{height}
pixels.
@end deffn
@deffn {Procedure} set-window-minimum-size! window width height
Set the minimum dimensions of @var{window} to @var{width} x
@var{height} pixels.
@end deffn
@deffn {Procedure} set-window-maximum-size! window width height
Set the maximum dimensions of @var{window} to @var{width} x
@var{height} pixels.
@end deffn
@deffn {Procedure} set-window-resizable! window resizable?
If @var{resizable} is @code{#t}, allow @var{window} to be resized,
otherwise disable resizing.
@end deffn
@deffn {Procedure} set-window-fullscreen! window fullscreen? [#:desktop?]
Toggle fullscreen mode on/off for @var{window}. If @var{fullscreen?},
fullscreen mode is activated, otherwise it is deactivated. If
@var{fullscreen?} and @var{desktop?}, a special "fake" fullscreen mode
is used that takes the size of the desktop.
@end deffn
@node OpenGL
@subsection OpenGL
@deffn {Procedure} make-gl-context window
Create an OpenGL context for @var{window}.
@end deffn
@deffn {Procedure} delete-gl-context! context
Delete @var{context}, an OpenGL context object.
@end deffn
@deffn {Procedure} call-with-gl-context window proc
Call @var{proc} with a new OpenGL context created for @var{window}, and
close the context when @var{proc} returns or otherwise exits.
@end deffn
@deffn {Procedure} swap-gl-window window
Update @var{window} with OpenGL rendering.
@end deffn
@deffn {Procedure} set-gl-attribute! attr value
Set the OpenGL attribute represented by the symbol @var{attr} to
@var{value}. Possible values for @var{attr} are:
@itemize
@item @code{red-size}
@item @code{green-size}
@item @code{blue-size}
@item @code{alpha-size}
@item @code{buffer-size}
@item @code{double-buffer}
@item @code{depth-size}
@item @code{stencil-size}
@item @code{accum-red-size}
@item @code{accum-green-size}
@item @code{accum-blue-size}
@item @code{stereo}
@item @code{multisample-buffers}
@item @code{multisample-samples}
@item @code{retained-backing}
@item @code{context-major-version}
@item @code{context-minor-version}
@item @code{context-egl}
@item @code{context-flags}
@item @code{context-profile-mask}
@item @code{share-with-current-context}
@item @code{framebuffer-srgb-capable}
@end itemize
@end deffn
@deffn {Procedure} set-gl-swap-interval! interval
Set the framebuffer swap interval for the current OpenGL context to the
type indicated by the symbol @var{interval}. Possible values of
@var{interval} are:
@itemize
@item @code{immediate}, for immediate updates
@item @code{vsync}, for updates synchronized with the screen's vertical retrace
@item @code{late-swap-tear}, for late swap tearing
@end itemize
Late swap tearing works the same as vsync, but if the vertical retrace
has been missed for a given frame, buffers are swapped immediately,
which might be less jarring for the user during occasional framerate
drops.
@end deffn
@node Input
@section Input
@menu
* Keyboard:: Keyboard input.
* Mouse:: Mouse input.
* Joysticks:: Joystick input.
* Game Controllers:: Game controller input.
@end menu
@node Keyboard
@subsection Keyboard
@example
(use-modules (sdl2 input keyboard))
@end example
@deffn {Procedure} key-pressed? key
Return @code{#t} if @var{key} is currently being pressed.
@end deffn
@deffn {Procedure} key-released? key
Return @code{#t} is @var{key} is not currently being pressed.
@end deffn
@node Mouse
@subsection Mouse
@example
(use-modules (sdl2 input mouse))
@end example
@deffn {Procedure} mouse-x
Return the x coordinate of the mouse cursor.
@end deffn
@deffn {Procedure} mouse-y
Return the y coordinate of the mouse cursor.
@end deffn
@deffn {Procedure} mouse-button-pressed? button
Return @code{#t} if @var{button} is currently being pressed.
@end deffn
@deffn {Procedure} mouse-button-released? button
Return @code{#t} if @var{button} is not currently being pressed.
@end deffn
@node Joysticks
@subsection Joysticks
@example
(use-modules (sdl2 input joystick))
@end example
@deffn {Procedure} num-joysticks
Return the current number of connected joystick devices.
@end deffn
@deffn {Procedure} open-joystick device-index
Return a joystick object for the physical joystick device associated
with @var{device-index}.
@end deffn
@deffn {Procedure} close-joystick joystick
Close @var{joystick}.
@end deffn
@deffn {Procedure} joystick-instance-id joystick
Return the instance id of @var{joystick}.
@end deffn
@deffn {Procedure} joystick-power-level joystick
Return the symbolic battery power level for @var{joystick}, either
@code{unknown}, @code{empty}, @code{low}, @code{medium}, @code{full},
or @code{wired}.
@end deffn
@deffn {Procedure} joystick-num-axes joystick
Return the number of axes for @var{joystick}.
@end deffn
@deffn {Procedure} joystick-num-balls joystick
Return the number of balls for @var{joystick}.
@end deffn
@deffn {Procedure} joystick-num-buttons joystick
Return the number of buttons for @var{joystick}.
@end deffn
@deffn {Procedure} joystick-num-hats joystick
Return the number of hats for @var{joystick}.
@end deffn
@node Game Controllers
@subsection Game Controllers
@example
(use-modules (sdl2 input game-controller))
@end example
@deffn {Procedure} load-game-controller-mappings! file
Load game controller mapping from @var{file} and return the number of
mappings added this way.
See @url{https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt}
for a community maintained controller mapping file.
@end deffn
@deffn {Procedure} open-game-controller joystick-index
Return a game controller object for the physical joystick device associated
with the @var{joystick-index}.
@end deffn
@deffn {Procedure} close-game-controller controller
Close @var{controller}.
@end deffn
@deffn {Procedure} game-controller? controller
Close @var{controller}.
@end deffn
@deffn {Procedure} game-controller-attached? controller
Return @code{#t} if @var{controller} is currently in use.
@end deffn
@deffn {Procedure} game-controller-joystick controller
Return the underlying joystick object associated with @var{controller}.
@end deffn
@deffn {Procedure} game-controller-name controller
Return the human readable name for @var{controller}.
@end deffn
@deffn {Procedure} game-controller-axis controller axis
Return a number in the range [-32768, 32767] representing the
current state of @var{axis} on @var{controller}.
@var{axis} may be one of the following symbols:
@itemize
@item @code{left-x}
@item @code{left-y}
@item @code{right-x}
@item @code{right-y}
@item @code{trigger-left}
@item @code{trigger-right}
@end itemize
@end deffn
@deffn {Procedure} game-controller-button-pressed? controller button
Return @code{#t} if @var{button} is pressed on @var{controller}.
@var{button} may be one of the following symbols:
@itemize
@item @code{a}
@item @code{b}
@item @code{x}
@item @code{y}
@item @code{back}
@item @code{guide}
@item @code{start}
@item @code{left-stick}
@item @code{right-stick}
@item @code{left-shoulder}
@item @code{right-shoulder}
@item @code{dpad-up}
@item @code{dpad-down}
@item @code{dpad-left}
@item @code{dpad-right}
@end itemize
@end deffn
@deffn {Procedure} game-controller-index? joystick-index
Return @code{#t} if @var{joystick-index} is a valid game controller index.
@end deffn
@node Events
@section Events
@example
(use-modules (sdl2 events))
@end example
@deffn {Procedure} make-quit-event timestamp
@end deffn
@deffn {Procedure} quit-event? e
Return @code{#t} if @var{e} is a quit event.
@end deffn
@deffn {Procedure} quit-event-timestamp e
@end deffn
@deffn {Procedure} make-window-event timestamp window-id type vector
@end deffn
@deffn {Procedure} window-event? e
Return @code{#t} if @var{e} is a window event.
@end deffn
@deffn {Procedure} window-shown-event? e
Return @code{#t} if @var{e} is a window shown event.
@end deffn
@deffn {Procedure} window-hidden-event? e
Return @code{#t} if @var{e} is a window hidden event.
@end deffn
@deffn {Procedure} window-exposed-event? e
Return @code{#t} if @var{e} is a window exposed event.
@end deffn
@deffn {Procedure} window-moved-event? e
Return @code{#t} if @var{e} is a window moved event.
@end deffn
@deffn {Procedure} window-resized-event? e
Return @code{#t} if @var{e} is a window resized event.
@end deffn
@deffn {Procedure} window-size-changed-event? e
Return @code{#t} if @var{e} is a window size changed event.
@end deffn
@deffn {Procedure} window-minimized-event? e
Return @code{#t} if @var{e} is a window minimized event.
@end deffn
@deffn {Procedure} window-maximized-event? e
Return @code{#t} if @var{e} is a window maximized event.
@end deffn
@deffn {Procedure} window-restored-event? e
Return @code{#t} if @var{e} is a window restored event.
@end deffn
@deffn {Procedure} window-enter-event? e
Return @code{#t} if @var{e} is a window enter event.
@end deffn
@deffn {Procedure} window-leave-event? e
Return @code{#t} if @var{e} is a window leave event.
@end deffn
@deffn {Procedure} window-focus-gained-event? e
Return @code{#t} if @var{e} is a window focus gained event.
@end deffn
@deffn {Procedure} window-focus-lost-event? e
Return @code{#t} if @var{e} is a window focus lost event.
@end deffn
@deffn {Procedure} window-closed-event? e
Return @code{#t} if @var{e} is a window closed event.
@end deffn
@deffn {Procedure} window-event-timestamp e
@end deffn
@deffn {Procedure} window-event-window-id e
@end deffn
@deffn {Procedure} window-event-type e
@end deffn
@deffn {Procedure} window-event-vector e
@end deffn
@deffn {Procedure} make-keyboard-event timestamp @
window-id @
pressed? @
repeat? @
key @
scancode @
modifiers
@end deffn
@deffn {Procedure} keyboard-event? e
Return @code{#t} if @var{e} is a keyboard event.
@end deffn
@deffn {Procedure} keyboard-down-event? e
Return @code{#t} if @var{e} is a key press event.
@end deffn
@deffn {Procedure} keyboard-up-event? e
Return @code{#t} if @var{e} is a key release event.
@end deffn
@deffn {Procedure} keyboard-event-timestamp e
@end deffn
@deffn {Procedure} keyboard-event-window-id e
@end deffn
@deffn {Procedure} keyboard-event-pressed? e
@end deffn
@deffn {Procedure} keyboard-event-repeat? e
@end deffn
@deffn {Procedure} keyboard-event-key e
@end deffn
@deffn {Procedure} keyboard-event-scancode e
@end deffn
@deffn {Procedure} keyboard-event-modifiers e
@end deffn
@deffn {Procedure} make-text-input-event timestamp window-id text
@end deffn
@deffn {Procedure} text-input-event? e
Return @code{#t} if @var{e} is a text input event.
@end deffn
@deffn {Procedure} text-input-event-timestamp e
@end deffn
@deffn {Procedure} text-input-event-window-id e
@end deffn
@deffn {Procedure} text-input-event-text e
@end deffn
@deffn {Procedure} make-mouse-button-event timestamp @
window-id @
which @
button @
pressed? @
clicks @
x @
y
@end deffn
@deffn {Procedure} mouse-button-event? e
Return @code{#t} if @var{e} is a mouse button event.
@end deffn
@deffn {Procedure} mouse-button-down-event? e
Return @code{#t} if @var{e} is a mouse button down event.
@end deffn
@deffn {Procedure} mouse-button-up-event? e
Return @code{#t} if @var{e} is a mouse button up event.
@end deffn
@deffn {Procedure} mouse-button-event-timestamp e
@end deffn
@deffn {Procedure} mouse-button-event-window-id e
@end deffn
@deffn {Procedure} mouse-button-event-which e
@end deffn
@deffn {Procedure} mouse-button-event-button e
@end deffn
@deffn {Procedure} mouse-button-event-pressed? e
@end deffn
@deffn {Procedure} mouse-button-event-clicks e
@end deffn
@deffn {Procedure} mouse-button-event-x e
@end deffn
@deffn {Procedure} mouse-button-event-y e
@end deffn
@deffn {Procedure} make-mouse-motion-event timestamp @
window-id @
which @
buttons @
x @
y @
x-rel @
y-rel
@end deffn
@deffn {Procedure} mouse-motion-event? e
Return @code{#t} if @var{e} is a mouse motion event.
@end deffn
@deffn {Procedure} mouse-motion-event-timestamp e
@end deffn
@deffn {Procedure} mouse-motion-event-window-id e
@end deffn
@deffn {Procedure} mouse-motion-event-which e
@end deffn
@deffn {Procedure} mouse-motion-event-buttons e
@end deffn
@deffn {Procedure} mouse-motion-event-x e
@end deffn
@deffn {Procedure} mouse-motion-event-y e
@end deffn
@deffn {Procedure} mouse-motion-event-x-rel e
@end deffn
@deffn {Procedure} mouse-motion-event-y-rel e
@end deffn
@deffn {Procedure} make-joystick-axis-event timestamp which axis value
@end deffn
@deffn {Procedure} joystick-axis-event? e
Return @code{#t} if @var{e} is a joystick axis event.
@end deffn
@deffn {Procedure} joystick-axis-event-timestamp e
@end deffn
@deffn {Procedure} joystick-axis-event-which e
@end deffn
@deffn {Procedure} joystick-axis-event-button e
@end deffn
@deffn {Procedure} joystick-axis-event-pressed? e
@end deffn
@deffn {Procedure} make-joystick-ball-event timestamp @
which @
ball @
x-rel @
y-rel
@end deffn
@deffn {Procedure} joystick-ball-event? e
Return @code{#t} if @var{e} is a joystick ball event.
@end deffn
@deffn {Procedure} joystick-ball-event-timestamp e
@end deffn
@deffn {Procedure} joystick-ball-event-which e
@end deffn
@deffn {Procedure} joystick-ball-event-ball e
@end deffn
@deffn {Procedure} joystick-ball-event-x-rel e
@end deffn
@deffn {Procedure} joystick-ball-event-y-rel e
@end deffn
@deffn {Procedure} make-joystick-hat-event timestamp which hat value
@end deffn
@deffn {Procedure} joystick-hat-event? e
Return @code{#t} if @var{e} is a joystick hat event.
@end deffn
@deffn {Procedure} joystick-hat-event-timestamp e
@end deffn
@deffn {Procedure} joystick-hat-event-which e
@end deffn
@deffn {Procedure} joystick-hat-event-hat e
@end deffn
@deffn {Procedure} joystick-hat-event-value e
@end deffn
@deffn {Procedure} make-joystick-device-event timestamp which action
@end deffn
@deffn {Procedure} joystick-device-event? e
Return @code{#t} if @var{e} is a joystick device event.
@end deffn
@deffn {Procedure} joystick-device-event-timestamp e
@end deffn
@deffn {Procedure} joystick-device-event-which e
@end deffn
@deffn {Procedure} joystick-device-event-action e
@end deffn
@deffn {Procedure} make-controller-axis-event timestamp which axis value
@end deffn
@deffn {Procedure} controller-axis-event? e
Return @code{#t} if @var{e} is a game controller axis event.
@end deffn
@deffn {Procedure} controller-axis-event-timestamp e
@end deffn
@deffn {Procedure} controller-axis-event-which e
@end deffn
@deffn {Procedure} controller-axis-event-axis e
@end deffn
@deffn {Procedure} controller-axis-event-value e
@end deffn
@deffn {Procedure} make-controller-button-event timestamp @
which @
button @
pressed?
@end deffn
@deffn {Procedure} controller-button-event? e
Return @code{#t} if @var{event} is a game controller button event.
@end deffn
@deffn {Procedure} controller-button-down-event? e
@end deffn
@deffn {Procedure} controller-button-up-event? e
@end deffn
@deffn {Procedure} controller-button-event-timestamp e
@end deffn
@deffn {Procedure} controller-button-event-which e
@end deffn
@deffn {Procedure} controller-button-event-button e
@end deffn
@deffn {Procedure} controller-button-event-pressed? e
@end deffn
@deffn {Procedure} make-controller-device-event timestamp which action
@end deffn
@deffn {Procedure} controller-device-event? e
Return @code{#t} if @var{event} is a game controller device event.
@end deffn
@deffn {Procedure} controller-added-event? e
Return @code{#t} if @var{event} is a game controller device event with the
'added' action.
@end deffn
@deffn {Procedure} controller-removed-event? e
Return @code{#t} if @var{event} is a game controller device event with the
'removed' action.
@end deffn
@deffn {Procedure} controller-remapped-event? e
Return @code{#t} if @var{event} is a game controller device event with the
'remapped' action.
@end deffn
@deffn {Procedure} controller-device-event-timestamp e
@end deffn
@deffn {Procedure} controller-device-event-which e
@end deffn
@deffn {Procedure} controller-device-event-action e
@end deffn
@deffn {Procedure} poll-event
@end deffn
@node Rects
@section Rects
@example
(use-modules (sdl2 rect))
@end example
@deffn {Procedure} make-rect @var{x} @var{y} @var{width} @var{height}
Return a new rectangle whose upper-left corner is at (@var{x},
@var{y}) and is @var{width} pixels wide and @var{height} pixels high.
@end deffn
@deffn {Procedure} rect-x @var{rect}
Return the X coordinate of @var{rect}.
@end deffn
@deffn {Procedure} rect-y @var{rect}
Return the Y coordinate of @var{rect}.
@end deffn
@deffn {Procedure} rect-width @var{rect}
Return the width of @var{rect}.
@end deffn
@deffn {Procedure} rect-height @var{rect}
Return the height of @var{rect}.
@end deffn
@node Surfaces
@section Surfaces
@example
(use-modules (sdl2 surface))
@end example
@deffn {Procedure} color? c
Return @code{#t} if @var{c} is a color.
@end deffn
@deffn {Procedure} color-r c
@end deffn
@deffn {Procedure} color-g c
@end deffn
@deffn {Procedure} color-b c
@end deffn
@deffn {Procedure} color-a c
@end deffn
@deffn {Procedure} palette? p
Return @code{#t} if @var{p} is a palette.
@end deffn
@deffn {Procedure} palette-length palette
Return the number of colors in @var{palette}.
@end deffn
@deffn {Procedure} palette-colors palette
Return the colors in @var{palette}.
@end deffn
@deffn {Procedure} pixel-format? pf
Return @code{#t} if @var{pf} is a pixel format.
@end deffn
@deffn {Procedure} pixel-format-name pf
Return the symbolic name of the pixel format @var{pf}.
@end deffn
@deffn {Procedure} pixel-format-palette pf
Return the palette for the pixel format @var{pf}.
@end deffn
@deffn {Procedure} pixel-format-bits-per-pixel pf
Return the number of bits per pixel for the pixel format @var{pf}.
@end deffn
@deffn {Procedure} pixel-format-bytes-per-pixel pf
Return the number of bytes per pixel for the pixel format @var{pf}.
@end deffn
@deffn {Procedure} pixel-format-red-mask pf
Return the bitmask for the red component of a pixel in the pixel format
@var{pf}.
@end deffn
@deffn {Procedure} pixel-format-green-mask pf
Return the bitmask for the green component of a pixel in the pixel format
@var{pf}.
@end deffn
@deffn {Procedure} pixel-format-blue-mask pf
Return the bitmask for the blue component of a pixel in the pixel format
@var{pf}.
@end deffn
@deffn {Procedure} pixel-format-alpha-mask pf
Return the bitmask for the alpha component of a pixel in the pixel format
@var{pf}.
@end deffn
@deffn {Procedure} make-rgb-surface width height depth
Create a new SDL surface with the dimensions @var{width} and @var{height} and
@var{depth} bits per pixel.
@end deffn
@deffn {Procedure} bytevector->surface bv width height depth pitch
Convert @var{bv}, a bytevector of pixel data with dimensions
@var{width}x@var{height}, to an SDL surface. Each pixel is @var{depth} bits in
size, and each row of pixels is @var{pitch} bytes in size.
@end deffn
@deffn {Procedure} delete-surface! surface
Free the memory used by @var{surface}.
@end deffn
@deffn {Procedure} call-with-surface surface proc
Call @var{proc}, passing it @var{surface} and deleting @var{surface} upon exit
of @var{proc}.
@end deffn
@deffn {Procedure} load-bmp file
Create a new surface from the bitmap data in @var{file}.
@end deffn
@deffn {Procedure} surface-width surface
Return the width of @var{surface} in pixels.
@end deffn
@deffn {Procedure} surface-height surface
Return the height of @var{surface} in pixels.
@end deffn
@deffn {Procedure} surface-pitch surface
Return the length of a row of pixels in @var{surface} in bytes.
@end deffn
@deffn {Procedure} surface-pixels surface
Return a bytevector containing the raw pixel data in @var{surface}.
@end deffn
@deffn {Procedure} surface-pixel-format surface
Return the pixel format for @var{surface}.
@end deffn
@deffn {Procedure} convert-surface-format surface format
Convert the pixels in @var{surface} to @var{format}, a symbol representing a
specific pixel format, and return a new surface object.
Valid format types are:
@itemize
@item @code{index1lsb}
@item @code{index1msb}
@item @code{index4lsb}
@item @code{index4msb}
@item @code{index8}
@item @code{rgb332}
@item @code{rgb444}
@item @code{rgb555}
@item @code{bgr555}
@item @code{argb4444}
@item @code{rgba4444}
@item @code{abgr4444}
@item @code{bgra4444}
@item @code{argb1555}
@item @code{rgba5551}
@item @code{abgr1555}
@item @code{bgra5551}
@item @code{rgb565}
@item @code{bgr565}
@item @code{rgb24}
@item @code{bgr24}
@item @code{rgb888}
@item @code{rgbx8888}
@item @code{bgr888}
@item @code{bgrx8888}
@item @code{argb8888}
@item @code{rgba8888}
@item @code{abgr8888}
@item @code{bgra8888}
@item @code{argb2101010}
@item @code{yv12}
@item @code{iyuv}
@item @code{yuy2}
@item @code{uyvy}
@item @code{yvyu}
@end itemize
@end deffn
@deffn {Procedure} blit-surface @var{src} @var{src-rect} @var{dst} @var{dst-rect}
Blit the rectangle @var{src-rect} from the surface @var{src} to
@var{dst-rect} of the surface @var{dst}.
@end deffn
@deffn {Procedure} blit-scaled @var{src} @var{src-rect} @var{dst} @var{dst-rect}
Blit the rectangle @var{src-rect} from the surface @var{src} to
@var{dst-rect} of the surface @var{dst}, scaling the source to fit the
destination.
@end deffn
@deffn {Procedure} fill-rect @var{dst} @var{rect} @var{color}
Fill @var{rect} with @var{color}, a 32-bit color encoded as an integer
value, in the surface @var{dst}.
@end deffn
@node Rendering
@section Rendering
@example
(use-modules (sdl2 render))
@end example
@deffn {Procedure} make-renderer window @
[#:optional flags='(accelerated vsync)]
Return a new renderer for @var{window} created with the options specified
in @var{flags}, a list of symbols. The valid symbols that may appear in
@var{flags} are:
@itemize
@item software, to use a software renderer fallback
@item accelerated, to use hardware acceleration
@item vsync, to synchronize rendering with the monitor's refresh rate
@item texture, for render to texture support
@end itemize
@end deffn
@deffn {Procedure} renderer? r
Return @code{#t} if @var{r} is a renderer.
@end deffn
@deffn {Procedure} delete-renderer! renderer
Delete the rendering context @var{renderer}.
@end deffn
@deffn {Procedure} call-with-renderer renderer proc
Call @var{proc}, passing it @var{renderer} and closing @var{renderer} upon exit
of @var{proc}.
@end deffn
@deffn {Procedure} clear-renderer renderer
Clear the rendering target @var{renderer} with the current drawing color.
@end deffn
@deffn {Procedure} present-renderer renderer
Display @var{renderer}.
@end deffn
@deffn {Procedure} renderer-integer-scale renderer
Returns @code{#t} if @var{renderer} currently uses integer scaling and
@code{#f} otherwise. Integer scaling can be used together with
logical size to effectively restrict the drawing region to an area
even if the window is larger than that.
@end deffn
@deffn {Procedure} set-renderer-integer-scale! renderer enable?
If @var{enable?} is @code{#t}, enable integer scaling, otherwise
disable it.
@end deffn
@deffn {Procedure} renderer-logical-size renderer
Return the current logical size used by @var{renderer}.
@end deffn
@deffn {Procedure} set-renderer-logical-size! renderer width height
Set the logical size of @var{renderer} to @var{width} x @var{height}.
@end deffn
@deffn {Procedure} renderer-scale renderer
Return the scaling factors @code{(X Y)} used by @var{renderer} to
scale coordinates.
@end deffn
@deffn {Procedure} set-renderer-scale! renderer scale-x scale-y
Set the factors by which @var{renderer} scales coordinates according
to the scaling factors @var{scale-x} and @var{scale-y}.
@end deffn
@deffn {Procedure} renderer-viewport renderer
Return the rectangle that @var{renderer} currently draws on. If the
entire region is used, all values of that rectangle will be 0.
@end deffn
@deffn {Procedure} set-renderer-viewport! renderer rect
Set the drawing area for @var{renderer} to @var{rect}.
@end deffn
@deffn {Procedure} render-copy renderer @
texture @
[#:angle 0] @
[#:srcrect] @
[#:dstrect] @
[#:center]
Copy @var{texture} to the rendering target of @var{renderer}.
@end deffn
@deffn {Procedure} set-render-draw-color renderer r g b a
Set color of @var{renderer} to the 32-bit color defined by the 8-bit
color channels @var{r}, @var{g}, @var{b}, @var{a}. Each color channel
value is in the range [0, 255].
@end deffn
@deffn {Procedure} set-render-draw-blend-mode renderer blend-mode
Set blend mode of @var{renderer} to @var{blend-mode}. @xref{Blend
Modes} for more information.
@end deffn
@deffn {Procedure} render-draw-line renderer x1 y1 x2 y2
Draw a line from (@var{x1}, @var{y1}) to (@var{x2}, @var{y2}) on the
current rendering target of @var{renderer}.
@end deffn
@deffn {Procedure} render-draw-lines renderer points
Draw a series of connected lines from @var{points} on the current
rendering target of @var{renderer}.
@end deffn
@deffn {Procedure} render-draw-point renderer x y
Draw a point at (@var{x}, @var{y}) on the current rendering target
of @var{renderer}.
@end deffn
@deffn {Procedure} render-draw-points renderer points
Draw a multiple points from @var{points} on the current rendering
target of @var{renderer}.
@end deffn
@deffn {Procedure} render-draw-rect renderer rectangle
Draw the outline of @var{rectangle} onto renderer.
@end deffn
@deffn {Procedure} render-draw-rects renderer rectangles
Draw the outline of the list @var{rectangles} onto @var{renderer}.
@end deffn
@deffn {Procedure} render-fill-rect renderer rectangle
Fill @var{rectangle} onto @var{renderer}.
@end deffn
@deffn {Procedure} render-fill-rects renderer rectangles
Fill the list @var{rectangles} onto @var{renderer}.
@end deffn
@deffn {Procedure} set-render-target! renderer texture
Sets the render target for @var{renderer} to @var{texture}, making all
comming draw requests redirect to @var{texture}.
Pass @code{#f} to reset it to the default target.
@end deffn
@deffn {Procedure} get-render-target renderer
Returns the current render target of @var{renderer} or @code{#f} if
it's a texture.
@end deffn
@deffn {Procedure} make-texture renderer format access width height
Returns a new texture for @var{renderer} with pixel @var{format}.
@var{access} is one of the symbols:
@itemize
@item static, changes rarely, not lockable
@item streaming, changes frequently, lockable
@item target, can be used as a render target
requires that renderer was created with the @code{texture} flag.
@end itemize
@end deffn
@deffn {Procedure} surface->texture renderer surface
Convert @var{surface} to a texture suitable for @var{renderer}.
@end deffn
@deffn {Procedure} delete-texture! texture
Free the memory used by @var{texture}.
@end deffn
@deffn {Procedure} get-texture-color-mod texture
Get color mod of @var{texture} as a list of the integers.
@end deffn
@deffn {Procedure} get-texture-alpha-mod texture
Get alpha mod of @var{texture} as a single integer.
@end deffn
@deffn {Procedure} set-texture-color-mod! texture r g b
Set the color mod of @var{texture}.
@end deffn
@deffn {Procedure} set-texture-alpha-mod! texture a
Set the alpha mod of @var{texture}.
@end deffn
@node Blend Modes
@section Blend Modes
@example
(use-modules (sdl2 blend-mode))
@end example
SDL2 provides several of the most commonly used blend modes:
@defvar none
No blending.
@end defvar
@defvar blend
Alpha blending.
@end defvar
@defvar add
Additive blending.
@end defvar
@defvar mul
Multiplicative blending.
@end defvar
@defvar mod
Color modulation.
@end defvar
Custom blend modes can be created using the @code{make-blend-mode}
procedure.
@deffn {Procedure} make-blend-mode src-color-factor dst-color-factor color-operation src-alpha-factor dst-alpha-factor alpha-operation
Return a new custom blend mode for renderers.
@var{src-color-factor} applies to the red, green, and blue components
of the source pixels.
@var{dst-color-factor} applies to the red, green, and blue components of the
destination pixels.
@var{color-operation} specifies how to combine the red, green, and blue
components of the source and destination pixels.
@var{src-alpha-factor} applies to the alpha component of the source pixels.
@var{dst-alpha-factor} applies to the alpha component of the destination
pixels.
@var{alpha-operation} specifies how to combine the alpha component of the
source and destination pixels.
Possible values for factors are @code{zero}, @code{one},
@code{src-color}, @code{one-minus-src-color}, @code{src-alpha},
@code{one-minus-src-alpha}, @code{dst-color},
@code{one-minus-dst-color}, @code{dst-alpha}, and @code{one-minus-dst
alpha}.
Possible values for operations are @code{add}, @code{subtract},
@code{rev-subtract}, @code{minimum}, and @code{maximum}.
@end deffn
@deffn {Procedure} blend-mode? obj
Return @code{#t} if @var{obj} is a blend mode object.
@end deffn
@deffn {Procedure} blend-mode-src-color-factor blend-mode
Return the source red, green, and blue channel blend factor for
@var{blend-mode}.
@end deffn
@deffn {Procedure} blend-mode-dst-color-factor blend-mode
Return the destination red, green, and blue channel blend factor for
@var{blend-mode}.
@end deffn
@deffn {Procedure} blend-mode-color-operation blend-mode
Return the red, green, and blue channel blend operation for
@var{blend-mode}.
@end deffn
@deffn {Procedure} blend-mode-src-alpha-factor blend-mode
Return the source alpha channel blend factor for @var{blend-mode}.
@end deffn
@deffn {Procedure} blend-mode-dst-alpha-factor blend-mode
Return the destination alpha channel blend factor for
@var{blend-mode}.
@end deffn
@deffn {Procedure} blend-mode-alpha-operation blend-mode
Return the alpha channel blend operation for @var{blend-mode}.
@end deffn
@node Images
@section Images
@example
(use-modules (sdl2 image))
@end example
@deffn {Procedure} image-init
Initialize dynamically loaded image libraries.
@end deffn
@deffn {Procedure} image-quit
Clean up dynamically loaded image libraries.
@end deffn
@deffn {Procedure} load-image file
Load the image in @var{file} and return an SDL surface.
@end deffn
@deffn {Procedure} save-png surface file
Save @var{surface} to @var{file} as a PNG formatted image.
@end deffn
@node Sound
@section Sound
@example
(use-modules (sdl2 mixer))
@end example
@defvr {Scheme Variable} %default-frequency
@end defvr
@defvr {Scheme Variable} %default-format
@end defvr
@defvr {Scheme Variable} %default-chunk-size
@end defvr
@deffn {Procedure} mixer-init [#:optional formats='(flac mod modplug mp3 ogg fluidsynth)]
Initialize mixer library with support for @var{formats}, a list of
symbols representing audio file formats. Possible formats are:
@itemize
@item flac
@item mod
@item modplug
@item mp3
@item ogg
@item fluidsynth
@end itemize
@end deffn
@deffn {Procedure} mixer-quit
Shutdown mixer library.
@end deffn
@deffn {Procedure} open-audio [#:frequency=%default-frequency] @
[#:format=%default-format] @
[#:stereo?=#t] @
[#:chunk-size=%default-chunk-size]
Initialize the mixer API. @var{frequency} specificies the sample rate in
hertz. When @var{stereo?} is @code{#t}, two output channels are used, otherwise
mono output is used instead. @var{chunk-size} specifies the number of bytes
used per output sample. @var{format} is a symbol that specifies the output
sample format. Possible values are:
@itemize
@item u8
@item s8
@item u16lsb
@item s16lsb
@item u16msb
@item s16msb
@item u16
@item s16
@item s32lsb
@item s32msb
@item s32
@item f32lsb
@item f32msb
@item f32
@end itemize
@end deffn
@deffn {Procedure} close-audio
Shut down the mixer API.
@end deffn
@deffn {Procedure} chunk? c
Return @code{#t} if @var{c} is a chunk.
@end deffn
@deffn {Procedure} load-chunk file
Load the audio data in @var{file} and return an audio chunk.
@end deffn
@deffn {Procedure} delete-chunk! chunk
Free the memory used for @var{chunk}.
@end deffn
@deffn {Procedure} set-chunk-volume! chunk volume
Set the loudness of @var{chunk} to @var{volume}, an integer in the range
[0,128]. Return the previous chunk volume setting.
@end deffn
@deffn {Procedure} play-chunk! chunk @
[#:loops=0] @
[#:channel]
Play @var{chunk} on @var{channel}, an integer channel identifier or @code{#f}
to use the first unreserved audio channel. @var{chunk} will play @var{loops} +
1 times. Return the channel identifier that @var{chunk} is played on.
@end deffn
@deffn {Procedure} set-channel-volume! channel volume
Set the loudness of @var{channel}, an integer channel identifier or @code{#f}
for all channels, to @var{volume}, an integer in the range [0,128]. Return
the previous volume of @var{channel}, or the average of all channels if
@var{channel} is @code{#f}.
@end deffn
@deffn {Procedure} pause-channel! channel
Pause playback on @var{channel}, an integer channel identifier, or @code{#f} to
pause all channels.
@end deffn
@deffn {Procedure} resume-channel! channel
Resume playback on @var{channel}, an integer channel identifier, or @code{#f} to
resume all channels.
@end deffn
@deffn {Procedure} stop-channel! channel
Halt playback on @var{channel}, an integer channel identifier, or @code{#f} to
halt all channels.
@end deffn
@deffn {Procedure} channel-playing? channel
Return @code{#t} if @var{channel} is playing.
@end deffn
@deffn {Procedure} playing-channels-count
Return the number of channels currently playing.
@end deffn
@deffn {Procedure} channel-paused? channel
Return @code{#t} if @var{channel} is paused.
@end deffn
@deffn {Procedure} paused-channels-count
Return the number of channels that are paused.
@end deffn
@deffn {Procedure} music? m
Return @code{#t} if @var{m} is music.
@end deffn
@deffn {Procedure} load-music file
Load music from @var{file}.
@end deffn
@deffn {Procedure} delete-music! music
Delete the memory used for @var{music}.
@end deffn
@deffn {Procedure} play-music! music [#:optional loops=1]
Play @var{music}, repeated @var{loops} times. @var{loops} may be @code{#f}, in
which case the music loops indefinitely.
@end deffn
@deffn {Procedure} set-music-volume! volume
Set music loudness to @var{volume}, an integer in the range [0,128]. Return the
previous volume.
@end deffn
@deffn {Procedure} music-volume
Return the music volume.
@end deffn
@deffn {Procedure} pause-music!
Puase the music.
@end deffn
@deffn {Procedure} resume-music!
Resume music playback.
@end deffn
@deffn {Procedure} rewind-music!
Start music playback from the beginning. Rewinding is only supported for MOD,
OGG, MP3, and native MIDI music.
@end deffn
@deffn {Procedure} stop-music!
Halt music playback.
@end deffn
@deffn {Procedure} music-playing?
Return @code{#t} if music is currently playing.
@end deffn
@deffn {Procedure} music-paused?
Return @code{#t} if music is currently paused.
@end deffn
@node Fonts
@section Fonts
@example
(use-modules (sdl2 ttf))
@end example
@deffn {Procedure} ttf-init
Initialize the TTF system.
@end deffn
@deffn {Procedure} ttf-quit
Shut down and clean up the TTF system.
@end deffn
@deffn {Procedure} load-font file point-size
Load TTF font from @var{file} and return a new font object whose glyph size is
@var{point-size}.
@end deffn
@deffn {Procedure} delete-font! font
Delete the memory allocated for @var{font}.
@end deffn
@deffn {Procedure} font-height font
Return the maximum height of @var{font}.
@end deffn
@deffn {Procedure} font-ascent font
Return the maximum pixel ascent of all glyphs in @var{font}. This can
also be interpreted as the distance from the top of the font to the
baseline.
@end deffn
@deffn {Procedure} font-descent font
Return the maximum pixel descent of all glyphs in @var{font}. This
can also be interpreted as the distance from the baseline to the
bottom of the font.
@end deffn
@deffn {Procedure} font-line-skip font
Return the recommended pixel height of a line of text using
@var{font}.
@end deffn
@deffn {Procedure} font-size-text font text
Return 2 values for the resulting surface size of the string
@var{text} using @var{font}.
@end deffn
@deffn {Procedure} font-glyph-index font char
Return the index of the glyph for @var{char} in @var{font}, or
@code{#f} if @var{char} is not present.
@end deffn
@deffn {Procedure} font-glyph-metrics font char
Return values for the metrics of @var{char} in @var{font}: min x, max
x, min y, max y, and advance.
@end deffn
@deffn font-style font
Return the rendering style of @var{font} as a list that may contain
any of the following symbols:
@itemize
@item @code{bold}
@item @code{italic}
@item @code{underline}
@item @code{strikethrough}
@end itemize
The empty list is returned if none of the above styles are applied.
@end deffn
@deffn font-set-style! font style
Set the rendering style of @var{font} to @var{style}, a list that may
contain any of the following symbols:
@itemize
@item @code{bold}
@item @code{italic}
@item @code{underline}
@item @code{strikethrough}
@end itemize
The empty list means that none of the above stylings will be used.
@end deffn
@deffn {Procedure} render-font-solid font text color
Render @var{text}, a UTF-8 encoded string, using @var{font} and @var{color}, the
foreground color, and return a surface containing the results.
@end deffn
@deffn {Procedure} render-font-blended font text color
Render @var{text}, a UTF-8 encoded string, using @var{font} and @var{color}, the
foreground color, and return a high-quality alpha-blended surface containing the
results.
@end deffn
|