New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add amethyst_context crate #63

Merged
merged 4 commits into from Jul 1, 2016

Conversation

Projects
None yet
5 participants
@nchashch
Member

nchashch commented Jun 23, 2016

Add Context struct which owns all global resources e.g. Window, RenderingContext, AudioContext, Logger, AssetManager, NetworkManager, etc.

Context is created from Config (it is an amethyst_config sturct which holds subconfigs for particular resources) and Rc<RefCell<Context>> is passed to every party requiring access to the context (see examples/window.rs).

Currently Context only contains a Window and a RenderingContext (struct containing device, factory, render targets and an amethyst_renderer::Renderer).

Potentially it can be used for event handling (passing an Rc<RefCell<Context>> to Application and polling events from it in Applcation::advance_frame).

It should close #54

nchashch added some commits Jun 23, 2016

Add amethyst_context crate
Allows windowing support
@kvark

This comment has been minimized.

Show comment
Hide comment
@kvark

kvark Jun 23, 2016

Member

Looks good to me. Summoning @ebkalderon , @csherratt , @Aceeri and whoever else interested!

Member

kvark commented Jun 23, 2016

Looks good to me. Summoning @ebkalderon , @csherratt , @Aceeri and whoever else interested!

src/context/src/rendering_context.rs
+ .with_visibility(visibility);
+
+ match display_config.min_dimensions {
+ Some ((w, h)) => builder = builder.with_dimensions(w, h),

This comment has been minimized.

@palodequeso

palodequeso Jun 23, 2016

Contributor

Why not combine line 56's some block into this one?

@palodequeso

palodequeso Jun 23, 2016

Contributor

Why not combine line 56's some block into this one?

This comment has been minimized.

@nchashch

nchashch Jun 23, 2016

Member

It is an error, on line 51 display_config.min_dimensions should be display_config.dimensions, thanks for pointing it out!

@nchashch

nchashch Jun 23, 2016

Member

It is an error, on line 51 display_config.min_dimensions should be display_config.dimensions, thanks for pointing it out!

This comment has been minimized.

@palodequeso

palodequeso Jun 23, 2016

Contributor

Wee, I was useful!

@palodequeso

palodequeso Jun 23, 2016

Contributor

Wee, I was useful!

@palodequeso

This comment has been minimized.

Show comment
Hide comment
@palodequeso

palodequeso Jun 23, 2016

Contributor

I had one small nit-pick, but I still consider myself a rust beginner, so there may be a really good reason for not doing what I suggested.

Contributor

palodequeso commented Jun 23, 2016

I had one small nit-pick, but I still consider myself a rust beginner, so there may be a really good reason for not doing what I suggested.

@palodequeso

This comment has been minimized.

Show comment
Hide comment
@palodequeso

palodequeso Jun 23, 2016

Contributor

+1

Contributor

palodequeso commented Jun 23, 2016

+1

@White-Oak

This comment has been minimized.

Show comment
Hide comment
@White-Oak

White-Oak Jun 23, 2016

Contributor

Seems good, but should be kept in mind that there are other than GL contexts :)

Contributor

White-Oak commented Jun 23, 2016

Seems good, but should be kept in mind that there are other than GL contexts :)

@palodequeso

This comment has been minimized.

Show comment
Hide comment
@palodequeso

palodequeso Jun 24, 2016

Contributor

Seems good, but should be kept in mind that there are other than GL contexts :)

Agreed.

Contributor

palodequeso commented Jun 24, 2016

Seems good, but should be kept in mind that there are other than GL contexts :)

Agreed.

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Jun 25, 2016

Member

Looks good to me, the GL context problem should probably be handled separately in the amethyst_renderer crate with some sort of Window trait over glutin/glfw/sdl/dx11/metal stuff.

Member

Aceeri commented Jun 25, 2016

Looks good to me, the GL context problem should probably be handled separately in the amethyst_renderer crate with some sort of Window trait over glutin/glfw/sdl/dx11/metal stuff.

src/context/src/rendering_context.rs
+ .with_multisampling(multisampling)
+ .with_visibility(visibility);
+
+ match display_config.dimensions {

This comment has been minimized.

@Aceeri

Aceeri Jun 25, 2016

Member

Since the None branch never actually does something, I think it might be better to just make this a

if let Some((w, h)) = display_config.dimensions {
    builder = builder.with_dimensions(w, h);
}
@Aceeri

Aceeri Jun 25, 2016

Member

Since the None branch never actually does something, I think it might be better to just make this a

if let Some((w, h)) = display_config.dimensions {
    builder = builder.with_dimensions(w, h);
}
+ struct DisplayConfig {
+ pub title: String = "Amethyst game".to_string(),
+ pub fullscreen: bool = false,
+ pub dimensions: Option<(u32, u32)> = None,

This comment has been minimized.

@Aceeri

Aceeri Jun 26, 2016

Member

May want to change this to just (u32, u32) instead of an Option, since otherwise it would be defaulted to None and the window won't know what the default resolution is.

@Aceeri

Aceeri Jun 26, 2016

Member

May want to change this to just (u32, u32) instead of an Option, since otherwise it would be defaulted to None and the window won't know what the default resolution is.

This comment has been minimized.

@nchashch

nchashch Jun 26, 2016

Member

I think it should be an Option for ergonomics reasons. If display_config.dimensions is an Option then it is possible to get a Window in fullscreen with native resolution just by passing null to display_config.dimensions field, and if it is not in fullscreen then it will just default to some arbituary dimensions.

If display_config.dimensions is not an Option then in fullscreen resolution would be set to some hard coded value that doesn't necessarily match the native resolution in case if the proper resolution is not set in the config. Which might be unexpected.

@nchashch

nchashch Jun 26, 2016

Member

I think it should be an Option for ergonomics reasons. If display_config.dimensions is an Option then it is possible to get a Window in fullscreen with native resolution just by passing null to display_config.dimensions field, and if it is not in fullscreen then it will just default to some arbituary dimensions.

If display_config.dimensions is not an Option then in fullscreen resolution would be set to some hard coded value that doesn't necessarily match the native resolution in case if the proper resolution is not set in the config. Which might be unexpected.

This comment has been minimized.

@Aceeri

Aceeri Jun 26, 2016

Member

True, forgot that setting dimensions when in exclusive mode might create some problems.

@Aceeri

Aceeri Jun 26, 2016

Member

True, forgot that setting dimensions when in exclusive mode might create some problems.

@kvark

This comment has been minimized.

Show comment
Hide comment
@kvark

kvark Jul 1, 2016

Member

Looks like everyone is happy. Merging.

Member

kvark commented Jul 1, 2016

Looks like everyone is happy. Merging.

@kvark kvark merged commit df9e449 into amethyst:develop Jul 1, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@nchashch nchashch deleted the nchashch:windowing branch Jul 12, 2016

@nchashch nchashch referenced this pull request Jul 16, 2016

Closed

Windowing Support #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment