source: project/wiki/eggref/4/glfw3 @ 30706

Last change on this file since 30706 was 30706, checked in by acharlton, 7 years ago
File size: 4.0 KB
Line 
1[[toc:]]
2
3== glfw3
4Bindings to the [[http://www.glfw.org/|GLFW]] OpenGL window and event management library, version 3.X.
5
6=== Requirements
7[[bind]]
8
9=== Documentation
10Direct bindings generated by [[bind]]. Names Scheme-ified, with GLFW prefixes removed. Constants surrounded by {{+}}s (e.g. {{+alpha-bits+}})
11
12Version 3 of GLFW is not backwards compatible with previous major versions of GLFW.
13
14For information regarding the GLFW API, see the official [[http://www.glfw.org/documentation.html|GLFW documentation]].
15
16==== High-level interface
17
18===== make-window
19    (make-window WIDTH HEIGHT NAME
20                     #!key (fullscreen? #f)
21                                 resizable
22                                 visible
23                                 decorated
24                                 red-bits green-bits blue-bits alpha-bits
25                                 depth-bits stencil-bits
26                                 accum-red-bits accum-green-bits accum-blue-bits accum-alpha-bits
27                                 aux-buffers
28                                 samples
29                                 refresh-rate
30                                 sterio
31                                 srgb-capable
32                                 client-api
33                                 context-version-major
34                                 context-version-minor
35                                 context-robustness
36                                 opengl-forward-compat
37                                 opengl-debug-context
38                                 opengl-profile)
39
40Create the window with title string NAME and dimensions WIDTH by HEIGHT. The keys correspond to the available [[http://www.glfw.org/docs/latest/window.html#window_hints|GLFW window hints]]. {{resizable}}, {{visible}}, {{decorated}}, {{sterio}}, {{srgb-capable}}, {{opengl-forward-compat}}, {{opengl-debug-context}} accept boolean arguments, while all other accept either an integer or an appropriate GLFW constant as per the documentation.
41
42===== *window*
43This variable contains the GLFW window object that is created by {{make-window}}.
44
45===== with-window
46<macro>(with-window (WIDTH HEIGHT NAME . KEYS) BODY ...)</macro>
47
48Initializes GLFW, creates a window as per {{make-window}}, and runs BODY before cleaning up. If [[opengl-glew]] has been included in the same file that this macro is used, opengl-glew will also be initialized.
49
50
51=== Example
52This example must be compiled due to the external function definition.
53
54<enscript highlight="scheme">
55(import foreign)
56(use (prefix glfw3 glfw:))
57
58(define-external (keyCallback (c-pointer window)
59                              (int key) (int scancode) (int action) (int mods))
60    void
61  (cond
62   [(and (eq? key glfw:+key-escape+) (eq? action glfw:+press+))
63    (glfw:set-window-should-close *window* 1)]))
64
65(glfw:with-window (640 480 "Example" resizable: #f)
66    (glfw:set-key-callback glfw:*window* #$keyCallback)
67    (let loop ()
68      (glfw:swap-buffers glfw:*window*)
69      (glfw:poll-events)
70      (unless (glfw:window-should-close glfw:*window*)
71        (loop))))
72</enscript>
73
74=== Author
75Alex Charlton
76
77=== Source
78Available on [[https://github.com/AlexCharlton/glfw3-chicken|GitHub]]
79
80=== Changelog
81* 0.2.0: Add {{make-window}}, {{with-window}}
82* 0.1.0
83
84=== Licence
85Copyright (c) 2014, Alexander Charlton
86All rights reserved.
87
88Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
89
90Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
91Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
92THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.