-
Notifications
You must be signed in to change notification settings - Fork 544
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
Changes from 2 commits
ac794d0
7138ffc
05b4a12
d2e6078
dfce190
bbacd21
6f7e15c
9a0953b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,4 +145,4 @@ image = "0.13" | |
winit = "0.6" | ||
|
||
[target.x86_64-unknown-linux-gnu.dev-dependencies] | ||
glfw = "0.12" | ||
glfw = "0.14" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,11 @@ 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I mean, we should bump the version of |
||
gfx = "0.15" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should go to |
||
gfx_core = { path = "../../core", version = "0.7" } | ||
gfx_device_gl = { path = "../../backend/gl", version = "0.14" } | ||
|
||
[[example]] | ||
name = "window" | ||
path = "examples/window/main.rs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's simplify it by placing the example as |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- | ||
Copyright 2014 The Gfx-rs Developers. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# Gfx-rs + GLFW Example | ||
|
||
Basic window with glfw. For drawing code, refer to main triangle example. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2015 The Gfx-rs Developers. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
extern crate gfx; | ||
extern crate gfx_window_glfw; | ||
extern crate glfw; | ||
|
||
use glfw::{Action, Context, Key}; | ||
|
||
pub fn main() { | ||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS) | ||
.ok() | ||
.expect("Failed to initialize GLFW"); | ||
|
||
glfw.window_hint(glfw::WindowHint::ContextVersion(3, 2)); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. let's change the title here |
||
.expect("Failed to create GLFW window."); | ||
|
||
window.set_key_polling(true); | ||
window.set_close_polling(true); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. let's add a |
||
let mut running = true; | ||
while running { | ||
glfw.poll_events(); | ||
|
||
for (_, event) in glfw::flush_messages(&events) { | ||
match event { | ||
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => running = false, | ||
glfw::WindowEvent::Close => running = false, | ||
_ => {}, | ||
} | ||
} | ||
|
||
window.swap_buffers(); | ||
} | ||
} |
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?