-
Notifications
You must be signed in to change notification settings - Fork 545
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
Conversation
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. |
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? |
@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:
How does this sound to you? |
@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! |
@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". |
There was a problem hiding this 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 ;)
src/window/glfw/Cargo.toml
Outdated
@@ -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" |
There was a problem hiding this comment.
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]
src/window/glfw/Cargo.toml
Outdated
|
||
[[example]] | ||
name = "window" | ||
path = "examples/window/main.rs" |
There was a problem hiding this comment.
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); | ||
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/window/glfw/examples/window.rs
Outdated
@@ -0,0 +1,55 @@ | |||
// Copyright 2015 The Gfx-rs Developers. |
There was a problem hiding this comment.
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!
src/window/glfw/Cargo.toml
Outdated
gfx_core = { path = "../../core", version = "0.7" } | ||
gfx_device_gl = { path = "../../backend/gl", version = "0.14" } | ||
|
||
[dev-dependencies] | ||
gfx = "0.15" |
There was a problem hiding this comment.
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
There was a problem hiding this 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" |
There was a problem hiding this comment.
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
src/window/glfw/Cargo.toml
Outdated
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" } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There is one small fix needed in the root Cargo.toml now to point to gfx_window_glfw 0.15 |
Should be good now :) |
Thanks! 🤞 |
This looks like a bug :( I can repro it on my machine. |
Here is the bug: rust-lang/cargo#860 |
Thanks @Haggus for finding the issue! I commented on there. |
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>
GLFW triangle example from #1199