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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2016, 2017, 2018, 2019 David Thompson davet@gnu.org
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
A copy of the license is also available from the Free Software
Foundation Web site at http://www.gnu.org/licenses/fdl.html.
* Guile-SDL2: (guile-sdl2). SDL2 bindings for Guile.
The document was typeset with
http://www.texinfo.org/ (GNU Texinfo).
-->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rendering (Guile-SDL2)</title>
<meta name="description" content="Rendering (Guile-SDL2)">
<meta name="keywords" content="Rendering (Guile-SDL2)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Index.html" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="API-Reference.html" rel="up" title="API Reference">
<link href="Blend-Modes.html" rel="next" title="Blend Modes">
<link href="Surfaces.html" rel="prev" title="Surfaces">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
@media (min-width: 1140px) {
body {
margin-left: 14rem;
margin-right: 4rem;
max-width: 52rem;
}
}
@media (min-width: 800px) and (max-width: 1140px) {
body {
margin-left: 6rem;
margin-right: 4rem;
max-width: 52rem;
}
}
@media (max-width: 800px) {
body {
margin: 1rem;
}
}
-->
</style>
<link rel="stylesheet" type="text/css" href="https://dthompson.us/css/dthompson.css">
</head>
<body lang="en">
<span id="Rendering"></span><div class="header">
<p>
Next: <a href="Blend-Modes.html" accesskey="n" rel="next">Blend Modes</a>, Previous: <a href="Surfaces.html" accesskey="p" rel="prev">Surfaces</a>, Up: <a href="API-Reference.html" accesskey="u" rel="up">API Reference</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Rendering-1"></span><h3 class="section">3.7 Rendering</h3>
<div class="example">
<pre class="example">(use-modules (sdl2 render))
</pre></div>
<dl>
<dt id="index-make_002drenderer">Procedure: <strong>make-renderer</strong> <em>window [#:optional flags='(accelerated vsync)]</em></dt>
<dd><p>Return a new renderer for <var>window</var> created with the options specified
in <var>flags</var>, a list of symbols. The valid symbols that may appear in
<var>flags</var> are:
</p>
<ul>
<li> software, to use a software renderer fallback
</li><li> accelerated, to use hardware acceleration
</li><li> vsync, to synchronize rendering with the monitor’s refresh rate
</li><li> texture, for render to texture support
</li></ul>
</dd></dl>
<dl>
<dt id="index-renderer_003f">Procedure: <strong>renderer?</strong> <em>r</em></dt>
<dd><p>Return <code>#t</code> if <var>r</var> is a renderer.
</p></dd></dl>
<dl>
<dt id="index-delete_002drenderer_0021">Procedure: <strong>delete-renderer!</strong> <em>renderer</em></dt>
<dd><p>Delete the rendering context <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-call_002dwith_002drenderer">Procedure: <strong>call-with-renderer</strong> <em>renderer proc</em></dt>
<dd><p>Call <var>proc</var>, passing it <var>renderer</var> and closing <var>renderer</var> upon exit
of <var>proc</var>.
</p></dd></dl>
<dl>
<dt id="index-clear_002drenderer">Procedure: <strong>clear-renderer</strong> <em>renderer</em></dt>
<dd><p>Clear the rendering target <var>renderer</var> with the current drawing color.
</p></dd></dl>
<dl>
<dt id="index-present_002drenderer">Procedure: <strong>present-renderer</strong> <em>renderer</em></dt>
<dd><p>Display <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-renderer_002dinteger_002dscale">Procedure: <strong>renderer-integer-scale</strong> <em>renderer</em></dt>
<dd><p>Returns <code>#t</code> if <var>renderer</var> currently uses integer scaling and
<code>#f</code> 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.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002dinteger_002dscale_0021">Procedure: <strong>set-renderer-integer-scale!</strong> <em>renderer enable?</em></dt>
<dd><p>If <var>enable?</var> is <code>#t</code>, enable integer scaling, otherwise
disable it.
</p></dd></dl>
<dl>
<dt id="index-renderer_002dlogical_002dsize">Procedure: <strong>renderer-logical-size</strong> <em>renderer</em></dt>
<dd><p>Return the current logical size used by <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002dlogical_002dsize_0021">Procedure: <strong>set-renderer-logical-size!</strong> <em>renderer width height</em></dt>
<dd><p>Set the logical size of <var>renderer</var> to <var>width</var> x <var>height</var>.
</p></dd></dl>
<dl>
<dt id="index-renderer_002dscale">Procedure: <strong>renderer-scale</strong> <em>renderer</em></dt>
<dd><p>Return the scaling factors <code>(X Y)</code> used by <var>renderer</var> to
scale coordinates.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002dscale_0021">Procedure: <strong>set-renderer-scale!</strong> <em>renderer scale-x scale-y</em></dt>
<dd><p>Set the factors by which <var>renderer</var> scales coordinates according
to the scaling factors <var>scale-x</var> and <var>scale-y</var>.
</p></dd></dl>
<dl>
<dt id="index-renderer_002dviewport">Procedure: <strong>renderer-viewport</strong> <em>renderer</em></dt>
<dd><p>Return the rectangle that <var>renderer</var> currently draws on. If the
entire region is used, all values of that rectangle will be 0.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002dviewport_0021">Procedure: <strong>set-renderer-viewport!</strong> <em>renderer rect</em></dt>
<dd><p>Set the drawing area for <var>renderer</var> to <var>rect</var>.
</p></dd></dl>
<dl>
<dt id="index-render_002dcopy">Procedure: <strong>render-copy</strong> <em>renderer texture [#:angle 0] [#:srcrect] [#:dstrect] [#:center]</em></dt>
<dd><p>Copy <var>texture</var> to the rendering target of <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002ddraw_002dcolor_0021">Procedure: <strong>set-renderer-draw-color!</strong> <em>renderer r g b a</em></dt>
<dd><p>Set color of <var>renderer</var> to the 32-bit color defined by the 8-bit
color channels <var>r</var>, <var>g</var>, <var>b</var>, <var>a</var>. Each color channel
value is in the range [0, 255].
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002ddraw_002dblend_002dmode_0021">Procedure: <strong>set-renderer-draw-blend-mode!</strong> <em>renderer blend-mode</em></dt>
<dd><p>Set blend mode of <var>renderer</var> to <var>blend-mode</var>. See <a href="Blend-Modes.html">Blend Modes</a> for more information.
</p></dd></dl>
<dl>
<dt id="index-set_002drenderer_002dtarget_0021">Procedure: <strong>set-renderer-target!</strong> <em>renderer texture</em></dt>
<dd><p>Sets the render target for <var>renderer</var> to <var>texture</var>, making all
comming draw requests redirect to <var>texture</var>.
</p>
<p>Pass <code>#f</code> to reset it to the default target.
</p></dd></dl>
<dl>
<dt id="index-renderer_002dtarget">Procedure: <strong>renderer-target</strong> <em>renderer</em></dt>
<dd><p>Returns the current render target of <var>renderer</var> or <code>#f</code> if
it’s a texture.
</p></dd></dl>
<dl>
<dt id="index-draw_002dline">Procedure: <strong>draw-line</strong> <em>renderer x1 y1 x2 y2</em></dt>
<dd><p>Draw a line from (<var>x1</var>, <var>y1</var>) to (<var>x2</var>, <var>y2</var>) on the
current rendering target of <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-draw_002dlines">Procedure: <strong>draw-lines</strong> <em>renderer points</em></dt>
<dd><p>Draw a series of connected lines from <var>points</var> on the current
rendering target of <var>renderer</var>. Optionally, for best performance,
<var>points</var> may instead be a bytevector packed with signed 32 bit
integers, 2 per point (x and y).
</p></dd></dl>
<dl>
<dt id="index-draw_002dpoint">Procedure: <strong>draw-point</strong> <em>renderer x y</em></dt>
<dd><p>Draw a point at (<var>x</var>, <var>y</var>) on the current rendering target
of <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-draw_002dpoints">Procedure: <strong>draw-points</strong> <em>renderer points</em></dt>
<dd><p>Draw a multiple points from <var>points</var> on the current rendering
target of <var>renderer</var>. Optionally, for best performance,
<var>points</var> may instead be a bytevector packed with signed 32 bit
integers, 2 per point (x and y).
</p></dd></dl>
<dl>
<dt id="index-draw_002drect">Procedure: <strong>draw-rect</strong> <em>renderer rectangle</em></dt>
<dd><p>Draw the outline of <var>rectangle</var> onto renderer.
</p></dd></dl>
<dl>
<dt id="index-draw_002drects">Procedure: <strong>draw-rects</strong> <em>renderer rects</em></dt>
<dd><p>Draw the outline of all rects in the list <var>rects</var> onto
<var>renderer</var>. Optionally, for best performance, <var>rects</var> may
instead be a bytevector packed with signed 32 bit integers, 4 per rect
(x, y, width, height).
</p></dd></dl>
<dl>
<dt id="index-fill_002drect-1">Procedure: <strong>fill-rect</strong> <em>renderer rectangle</em></dt>
<dd><p>Fill <var>rectangle</var> onto <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-fill_002drects">Procedure: <strong>fill-rects</strong> <em>renderer rects</em></dt>
<dd><p>Fill the list <var>rects</var> onto <var>renderer</var>. Optionally, for best
performance, <var>rects</var> may instead be a bytevector packed with
signed 32 bit integers, 4 per rect (x, y, width, height).
</p></dd></dl>
<dl>
<dt id="index-make_002dtexture">Procedure: <strong>make-texture</strong> <em>renderer format access width height</em></dt>
<dd><p>Returns a new texture for <var>renderer</var> with pixel <var>format</var>.
<var>access</var> is one of the symbols:
</p>
<ul>
<li> static, changes rarely, not lockable
</li><li> streaming, changes frequently, lockable
</li><li> target, can be used as a render target
requires that renderer was created with the <code>texture</code> flag.
</li></ul>
</dd></dl>
<dl>
<dt id="index-query_002dtexture">Procedure: <strong>query-texture</strong> <em>texture</em></dt>
<dd><p>Return 4 values for the format, access, width and height of a texture.
</p></dd></dl>
<dl>
<dt id="index-surface_002d_003etexture">Procedure: <strong>surface->texture</strong> <em>renderer surface</em></dt>
<dd><p>Convert <var>surface</var> to a texture suitable for <var>renderer</var>.
</p></dd></dl>
<dl>
<dt id="index-delete_002dtexture_0021">Procedure: <strong>delete-texture!</strong> <em>texture</em></dt>
<dd><p>Free the memory used by <var>texture</var>.
</p></dd></dl>
<dl>
<dt id="index-texture_002dcolor_002dmod">Procedure: <strong>texture-color-mod</strong> <em>texture</em></dt>
<dd><p>Get color mod of <var>texture</var> as a list of the integers.
</p></dd></dl>
<dl>
<dt id="index-texture_002dalpha_002dmod">Procedure: <strong>texture-alpha-mod</strong> <em>texture</em></dt>
<dd><p>Get alpha mod of <var>texture</var> as a single integer.
</p></dd></dl>
<dl>
<dt id="index-set_002dtexture_002dcolor_002dmod_0021">Procedure: <strong>set-texture-color-mod!</strong> <em>texture r g b</em></dt>
<dd><p>Set the color mod of <var>texture</var>.
</p></dd></dl>
<dl>
<dt id="index-set_002dtexture_002dalpha_002dmod_0021">Procedure: <strong>set-texture-alpha-mod!</strong> <em>texture a</em></dt>
<dd><p>Set the alpha mod of <var>texture</var>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Blend-Modes.html" accesskey="n" rel="next">Blend Modes</a>, Previous: <a href="Surfaces.html" accesskey="p" rel="prev">Surfaces</a>, Up: <a href="API-Reference.html" accesskey="u" rel="up">API Reference</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|