@@ -16,21 +16,21 @@ First we turn on SDL itself:
16
16
use beryllium :: * ;
17
17
18
18
fn main () {
19
- let sdl = SDL :: init (InitFlags :: Everything ) . expect ( " couldn't start SDL " );
19
+ et sdl = Sdl :: init (init :: InitFlags :: EVERYTHING );
20
20
```
21
21
22
22
Then we set some attributes for the [ OpenGL
23
23
Context] ( https://www.khronos.org/opengl/wiki/OpenGL_Context ) that we want to
24
24
use:
25
25
26
26
``` rust
27
- sdl . gl_set_attribute ( SdlGlAttr :: MajorVersion , 3 ). unwrap ();
28
- sdl . gl_set_attribute ( SdlGlAttr :: MinorVersion , 3 ). unwrap ();
29
- sdl . gl_set_attribute ( SdlGlAttr :: Profile , GlProfile :: Core ). unwrap ();
27
+ sdl . set_gl_context_major_version ( 3 ). unwrap ();
28
+ sdl . set_gl_context_major_version ( 3 ). unwrap ();
29
+ sdl . set_gl_profile ( video :: GlProfile :: Core ). unwrap ();
30
30
#[cfg(target_os = " macos" )]
31
31
{
32
32
sdl
33
- . gl_set_attribute ( SdlGlAttr :: Flags , ContextFlag :: ForwardCompatible )
33
+ . set_gl_context_flags ( video :: GlContextFlags :: FORWARD_COMPATIBLE )
34
34
. unwrap ();
35
35
}
36
36
```
@@ -55,14 +55,17 @@ sticks the window and the GL Context together as a single thing (`glutin` also
55
55
works this way, I don't know about ` glfw ` ).
56
56
57
57
``` rust
58
+ let win_args = video :: CreateWinArgs {
59
+ title : WINDOW_TITLE ,
60
+ width : 800 ,
61
+ height : 600 ,
62
+ allow_high_dpi : true ,
63
+ borderless : false ,
64
+ resizable : false ,
65
+ };
66
+
58
67
let _win = sdl
59
- . create_gl_window (
60
- " Hello Window" ,
61
- WindowPosition :: Centered ,
62
- 800 ,
63
- 600 ,
64
- WindowFlags :: Shown ,
65
- )
68
+ . create_gl_window (win_args )
66
69
. expect (" couldn't make a window and context" );
67
70
```
68
71
@@ -79,11 +82,11 @@ pressed Alt+F4, etc) and then quit when that happens.
79
82
``` rust
80
83
'main_loop : loop {
81
84
// handle events this frame
82
- while let Some (event ) = sdl . poll_events (). and_then ( Result :: ok ) {
83
- match event {
84
- Event :: Quit ( _ ) => break 'main_loop ,
85
- _ => (),
86
- }
85
+ while let Some (event ) = sdl . poll_events () {
86
+ match event {
87
+ ( events :: Event :: Quit , _ ) => break 'main_loop ,
88
+ _ => (),
89
+ }
87
90
}
88
91
// now the events are clear
89
92
0 commit comments