pub struct ContextBuilder { /* private fields */ }
Expand description
The entry point of the ds2d
library that sets up the various subsystems,
and in particular a window with a graphics context.
Implementations§
Source§impl ContextBuilder
impl ContextBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/hello_world.rs (line 24)
21fn main() {
22 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
23
24 let (event_loop, context) = match ds2d::ContextBuilder::new()
25 .debug(true)
26 .title("Hello World!")
27 .build()
28 {
29 Ok(ok) => ok,
30 Err(err) => {
31 error!("Could not create context: {:?}", err);
32 std::process::exit(1);
33 }
34 };
35
36 let game = HelloGame;
37
38 ds2d::run(event_loop, context, game)
39}
More examples
examples/input_keyboard.rs (line 44)
41fn main() {
42 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
43
44 let (event_loop, context) = match ds2d::ContextBuilder::new()
45 .debug(true)
46 .title("Hello World!")
47 .build()
48 {
49 Ok(ok) => ok,
50 Err(err) => {
51 error!("Could not create context: {:?}", err);
52 std::process::exit(1);
53 }
54 };
55
56 let game = InputGame::new();
57
58 ds2d::run(event_loop, context, game)
59}
examples/input_mouse.rs (line 38)
35fn main() {
36 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
37
38 let (event_loop, context) = match ds2d::ContextBuilder::new()
39 .debug(true)
40 .title("Hello World!")
41 .build()
42 {
43 Ok(ok) => ok,
44 Err(err) => {
45 error!("Could not create context: {:?}", err);
46 std::process::exit(1);
47 }
48 };
49
50 let game = InputGame::new();
51
52 ds2d::run(event_loop, context, game)
53}
Sourcepub fn title<T: Into<String>>(self, title: T) -> Self
pub fn title<T: Into<String>>(self, title: T) -> Self
Set the title of the game window.
Examples found in repository?
examples/hello_world.rs (line 26)
21fn main() {
22 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
23
24 let (event_loop, context) = match ds2d::ContextBuilder::new()
25 .debug(true)
26 .title("Hello World!")
27 .build()
28 {
29 Ok(ok) => ok,
30 Err(err) => {
31 error!("Could not create context: {:?}", err);
32 std::process::exit(1);
33 }
34 };
35
36 let game = HelloGame;
37
38 ds2d::run(event_loop, context, game)
39}
More examples
examples/input_keyboard.rs (line 46)
41fn main() {
42 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
43
44 let (event_loop, context) = match ds2d::ContextBuilder::new()
45 .debug(true)
46 .title("Hello World!")
47 .build()
48 {
49 Ok(ok) => ok,
50 Err(err) => {
51 error!("Could not create context: {:?}", err);
52 std::process::exit(1);
53 }
54 };
55
56 let game = InputGame::new();
57
58 ds2d::run(event_loop, context, game)
59}
examples/input_mouse.rs (line 40)
35fn main() {
36 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
37
38 let (event_loop, context) = match ds2d::ContextBuilder::new()
39 .debug(true)
40 .title("Hello World!")
41 .build()
42 {
43 Ok(ok) => ok,
44 Err(err) => {
45 error!("Could not create context: {:?}", err);
46 std::process::exit(1);
47 }
48 };
49
50 let game = InputGame::new();
51
52 ds2d::run(event_loop, context, game)
53}
Sourcepub fn logical_size(self, size: LogicalSize<f64>) -> Self
pub fn logical_size(self, size: LogicalSize<f64>) -> Self
Set the logical size of the game window (before being scaled by the DPI factor). TODO: is there a way of providing a physical size for initialization?
Sourcepub fn debug(self, debug: bool) -> Self
pub fn debug(self, debug: bool) -> Self
Enable additional debug checks and output.
Defaults to cfg!(debug_assertions)
.
Examples found in repository?
examples/hello_world.rs (line 25)
21fn main() {
22 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
23
24 let (event_loop, context) = match ds2d::ContextBuilder::new()
25 .debug(true)
26 .title("Hello World!")
27 .build()
28 {
29 Ok(ok) => ok,
30 Err(err) => {
31 error!("Could not create context: {:?}", err);
32 std::process::exit(1);
33 }
34 };
35
36 let game = HelloGame;
37
38 ds2d::run(event_loop, context, game)
39}
More examples
examples/input_keyboard.rs (line 45)
41fn main() {
42 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
43
44 let (event_loop, context) = match ds2d::ContextBuilder::new()
45 .debug(true)
46 .title("Hello World!")
47 .build()
48 {
49 Ok(ok) => ok,
50 Err(err) => {
51 error!("Could not create context: {:?}", err);
52 std::process::exit(1);
53 }
54 };
55
56 let game = InputGame::new();
57
58 ds2d::run(event_loop, context, game)
59}
examples/input_mouse.rs (line 39)
35fn main() {
36 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
37
38 let (event_loop, context) = match ds2d::ContextBuilder::new()
39 .debug(true)
40 .title("Hello World!")
41 .build()
42 {
43 Ok(ok) => ok,
44 Err(err) => {
45 error!("Could not create context: {:?}", err);
46 std::process::exit(1);
47 }
48 };
49
50 let game = InputGame::new();
51
52 ds2d::run(event_loop, context, game)
53}
Sourcepub fn build(self) -> Result<(EventLoop<()>, Context), InitError>
pub fn build(self) -> Result<(EventLoop<()>, Context), InitError>
Create a window with an OpenGL context, and the corresponding event loop.
The returned ds2d::Context
can be used for initializing the Game state
before starting the game loop.
Examples found in repository?
examples/hello_world.rs (line 27)
21fn main() {
22 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
23
24 let (event_loop, context) = match ds2d::ContextBuilder::new()
25 .debug(true)
26 .title("Hello World!")
27 .build()
28 {
29 Ok(ok) => ok,
30 Err(err) => {
31 error!("Could not create context: {:?}", err);
32 std::process::exit(1);
33 }
34 };
35
36 let game = HelloGame;
37
38 ds2d::run(event_loop, context, game)
39}
More examples
examples/input_keyboard.rs (line 47)
41fn main() {
42 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
43
44 let (event_loop, context) = match ds2d::ContextBuilder::new()
45 .debug(true)
46 .title("Hello World!")
47 .build()
48 {
49 Ok(ok) => ok,
50 Err(err) => {
51 error!("Could not create context: {:?}", err);
52 std::process::exit(1);
53 }
54 };
55
56 let game = InputGame::new();
57
58 ds2d::run(event_loop, context, game)
59}
examples/input_mouse.rs (line 41)
35fn main() {
36 stderrlog::new().quiet(false).verbosity(5).init().unwrap();
37
38 let (event_loop, context) = match ds2d::ContextBuilder::new()
39 .debug(true)
40 .title("Hello World!")
41 .build()
42 {
43 Ok(ok) => ok,
44 Err(err) => {
45 error!("Could not create context: {:?}", err);
46 std::process::exit(1);
47 }
48 };
49
50 let game = InputGame::new();
51
52 ds2d::run(event_loop, context, game)
53}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextBuilder
impl RefUnwindSafe for ContextBuilder
impl Send for ContextBuilder
impl Sync for ContextBuilder
impl Unpin for ContextBuilder
impl UnwindSafe for ContextBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more