Skip to content

Commit 0e9f924

Browse files
authored
Updates 1.1 according to most recent version of beryllium (#10)
* Update 000-creating-a-window.md for beryllium 0.12.3 * Update 000-creating-a-window.md
1 parent 3a1e850 commit 0e9f924

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

book-src/basics/000-creating-a-window.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ First we turn on SDL itself:
1616
use beryllium::*;
1717

1818
fn main() {
19-
let sdl = SDL::init(InitFlags::Everything).expect("couldn't start SDL");
19+
et sdl = Sdl::init(init::InitFlags::EVERYTHING);
2020
```
2121

2222
Then we set some attributes for the [OpenGL
2323
Context](https://www.khronos.org/opengl/wiki/OpenGL_Context) that we want to
2424
use:
2525

2626
```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();
3030
#[cfg(target_os = "macos")]
3131
{
3232
sdl
33-
.gl_set_attribute(SdlGlAttr::Flags, ContextFlag::ForwardCompatible)
33+
.set_gl_context_flags(video::GlContextFlags::FORWARD_COMPATIBLE)
3434
.unwrap();
3535
}
3636
```
@@ -55,14 +55,17 @@ sticks the window and the GL Context together as a single thing (`glutin` also
5555
works this way, I don't know about `glfw`).
5656

5757
```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+
5867
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)
6669
.expect("couldn't make a window and context");
6770
```
6871

@@ -79,11 +82,11 @@ pressed Alt+F4, etc) and then quit when that happens.
7982
```rust
8083
'main_loop: loop {
8184
// 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+
}
8790
}
8891
// now the events are clear
8992

0 commit comments

Comments
 (0)