Skip to content
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

Triangle example using GLFW #1258

Merged
merged 8 commits into from
May 11, 2017
Merged

Triangle example using GLFW #1258

merged 8 commits into from
May 11, 2017

Conversation

Haggus
Copy link
Contributor

@Haggus Haggus commented May 8, 2017

GLFW triangle example from #1199

@kvark
Copy link
Member

kvark commented May 8, 2017

The problem here is minimizing the code duplication with existing code. This PR copies a lot of stuff (code, screenshot, shaders, etc). I wonder if we can have everything as optional code paths inside the same triangle example.

@Haggus
Copy link
Contributor Author

Haggus commented May 8, 2017

Oh, I thought that was the point. To make the triangle example use glfw, and make it as close to glutin implementation as possible :)

By "optional code paths", do you mean having triangle examples share the same assets?

@kvark
Copy link
Member

kvark commented May 9, 2017

@Haggus I'm sorry, there is a lot of discussion context between me and @icefoxen that got lost and not expressed in the original issue. I believe there is a solution that would require minimum code/maintenance and would be helpful for anyone choosing GLFW/SDL. This solution is to:

  1. Have the examples to be inside the corresponding window backend folders (src/window/glfw/examples/)
  2. Don't draw anything, just clear the screen. We can have a comment referring to the triangle example for the actual drawing code, it's not going to be any different.

How does this sound to you?

@Haggus
Copy link
Contributor Author

Haggus commented May 9, 2017

@kvark that sounds good. I don't mind changing it, so if this is how you guys want it, then it's OK with me. I'll submit changes as soon as I can!

@Haggus
Copy link
Contributor Author

Haggus commented May 10, 2017

@kvark let me know what you think about these changes.

Also, now that I think about it, this example should probably be called "GLFW Example".

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! We are almost there ;)

@@ -28,6 +28,11 @@ documentation = "https://docs.rs/gfx_window_glfw"
name = "gfx_window_glfw"

[dependencies]
glfw = "0.13"
glfw = "0.14"
gfx = "0.15"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go to [dev-dependencies]


[[example]]
name = "window"
path = "examples/window/main.rs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's simplify it by placing the example as examples/window.rs, so that you don't even need this path= line here

window.make_current();
glfw.set_error_callback(glfw::FAIL_ON_ERRORS);
let (_, _, _, _) = gfx_window_glfw::init(&mut window);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a //Note: actual drawing code is no different from the triangle example, or any other.

glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));

let (mut window, events) = glfw.create_window(1024, 768, "Triangle example", glfw::WindowMode::Windowed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change the title here

@Haggus
Copy link
Contributor Author

Haggus commented May 10, 2017

Should be good now. Let me know if you'd like any other changes! :)

Cargo.toml Outdated
@@ -145,4 +145,4 @@ image = "0.13"
winit = "0.6"

[target.x86_64-unknown-linux-gnu.dev-dependencies]
glfw = "0.12"
glfw = "0.14"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't know why it's even here? gfx_app doesn't use glfw or SDL anyway.
Let's remove it?

@@ -28,6 +28,9 @@ documentation = "https://docs.rs/gfx_window_glfw"
name = "gfx_window_glfw"

[dependencies]
glfw = "0.13"
glfw = "0.14"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs a version bump for this crate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 0.14 the latest version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we should bump the version of gfx_window_glfw to 0.15, given that dependency change

@@ -0,0 +1,55 @@
// Copyright 2015 The Gfx-rs Developers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are 2 years in the future, yay!

gfx_core = { path = "../../core", version = "0.7" }
gfx_device_gl = { path = "../../backend/gl", version = "0.14" }

[dev-dependencies]
gfx = "0.15"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, you need to provide both the local path and the version, similar to the dependencies above

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful, thank you!

@@ -28,6 +28,9 @@ documentation = "https://docs.rs/gfx_window_glfw"
name = "gfx_window_glfw"

[dependencies]
glfw = "0.13"
glfw = "0.14"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we should bump the version of gfx_window_glfw to 0.15, given that dependency change

gfx_core = { path = "../../core", version = "0.7" }
gfx_device_gl = { path = "../../backend/gl", version = "0.14" }

[dev-dependencies]
gfx = { path = "../../../src/render", version = "0.15" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assume you can go with "../../render". It still doesn't explain why travis fails to compile. Does it compile for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I do "../../render", it doesn't compile for me. With "src" it does without issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did "cargo clean", it recompiled and works.

@kvark
Copy link
Member

kvark commented May 10, 2017

There is one small fix needed in the root Cargo.toml now to point to gfx_window_glfw 0.15

@Haggus
Copy link
Contributor Author

Haggus commented May 10, 2017

Should be good now :)

@kvark
Copy link
Member

kvark commented May 10, 2017

Thanks! 🤞

@kvark
Copy link
Member

kvark commented May 10, 2017

This looks like a bug :( I can repro it on my machine. cargo test -p gfx_window_glfw doesn't use dev-dependencies section for some reason. I propose to move it into the regular dependencies, but add a //TODO note mentioning the problem. Also, the path should really just be "../../render".

@Haggus
Copy link
Contributor Author

Haggus commented May 10, 2017

Here is the bug: rust-lang/cargo#860

@kvark
Copy link
Member

kvark commented May 10, 2017

Thanks @Haggus for finding the issue! I commented on there.

@kvark kvark merged commit 82f2878 into gfx-rs:master May 11, 2017
adamnemecek pushed a commit to adamnemecek/gfx that referenced this pull request Apr 1, 2021
1258: Lint all the things r=kvark a=kvark

**Connections**
Fixes gfx-rs#1250

**Description**
Refactors the code to satisfy the linter, configures it, and enables on CI.

**Testing**
`cargo clippy` saves the dau

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants