Initial commit - some engine bugs stopping compiling
This commit is contained in:
8
third-party/glad/example/rust/gl-glfw-mx/Cargo.toml
vendored
Normal file
8
third-party/glad/example/rust/gl-glfw-mx/Cargo.toml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gl-glfw"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
glfw = "0.37.0"
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
|
||||
34
third-party/glad/example/rust/gl-glfw-mx/README.md
vendored
Normal file
34
third-party/glad/example/rust/gl-glfw-mx/README.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
Example: gl-glfw-mx
|
||||
================
|
||||
|
||||
|
||||
This is basic example showcasing `glad-gl` in combination with
|
||||
[`glfw`](https://crates.io/crates/glfw). And multiple OpenGL contexts
|
||||
in different windows.
|
||||
|
||||
To run the example use the following command:
|
||||
|
||||
```sh
|
||||
./init.sh && cargo run
|
||||
```
|
||||
|
||||
The `init.sh` script is just a small utility used to generate
|
||||
the `glad-gl` crate into the `build/` directory. The `Cargo.toml`
|
||||
references the dependency using:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
```
|
||||
|
||||
This example is the basic example of the
|
||||
[glfw crate](https://crates.io/crates/glfw) with some
|
||||
OpenGL instructions added and just one additional line
|
||||
to initialize `glad`:
|
||||
|
||||
```rust
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
```
|
||||
|
||||
That's all that is needed to initialize and use OpenGL using `glad`!
|
||||
|
||||
9
third-party/glad/example/rust/gl-glfw-mx/init.sh
vendored
Executable file
9
third-party/glad/example/rust/gl-glfw-mx/init.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASE_PATH="$(dirname $(realpath $0))"
|
||||
|
||||
|
||||
cd "${BASE_PATH}/../../../"
|
||||
|
||||
python -m glad --out-path "${BASE_PATH}/build" --extensions="" --api="gl:core=3.3" rust --mx
|
||||
|
||||
63
third-party/glad/example/rust/gl-glfw-mx/src/main.rs
vendored
Normal file
63
third-party/glad/example/rust/gl-glfw-mx/src/main.rs
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
extern crate glfw;
|
||||
extern crate glad_gl;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use glfw::{Action, Context, Key};
|
||||
use glad_gl::gl;
|
||||
|
||||
|
||||
struct Window {
|
||||
source: glfw::Window,
|
||||
events: Receiver<(f64, glfw::WindowEvent)>,
|
||||
gl: gl::Gl
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
||||
|
||||
let mut w1 = create_window(&mut glfw);
|
||||
let mut w2 = create_window(&mut glfw);
|
||||
|
||||
while !w1.source.should_close() && !w2.source.should_close() {
|
||||
glfw.poll_events();
|
||||
|
||||
draw(&mut w1);
|
||||
draw(&mut w2);
|
||||
}
|
||||
}
|
||||
|
||||
fn create_window(glfw: &mut glfw::Glfw) -> Window {
|
||||
let (mut window, events) = glfw
|
||||
.create_window(300, 300, "[glad] Rust - OpenGL with GLFW", glfw::WindowMode::Windowed)
|
||||
.expect("Failed to create GLFW window.");
|
||||
|
||||
window.set_key_polling(true);
|
||||
window.make_current();
|
||||
|
||||
let gl = gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
|
||||
Window {
|
||||
source: window, events, gl
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(window: &mut Window) {
|
||||
for (_, event) in glfw::flush_messages(&window.events) {
|
||||
handle_window_event(&mut window.source, event);
|
||||
}
|
||||
|
||||
window.source.make_current();
|
||||
unsafe {
|
||||
window.gl.ClearColor(0.7, 0.9, 0.1, 1.0);
|
||||
window.gl.Clear(gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
window.source.swap_buffers();
|
||||
}
|
||||
|
||||
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||
match event {
|
||||
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
|
||||
window.set_should_close(true)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
8
third-party/glad/example/rust/gl-glfw/Cargo.toml
vendored
Normal file
8
third-party/glad/example/rust/gl-glfw/Cargo.toml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gl-glfw"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
glfw = "0.37.0"
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
|
||||
33
third-party/glad/example/rust/gl-glfw/README.md
vendored
Normal file
33
third-party/glad/example/rust/gl-glfw/README.md
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
Example: gl-glfw
|
||||
================
|
||||
|
||||
|
||||
This is basic example showcasing `glad-gl` in combination with
|
||||
[`glfw`](https://crates.io/crates/glfw).
|
||||
|
||||
To run the example use the following command:
|
||||
|
||||
```sh
|
||||
./init.sh && cargo run
|
||||
```
|
||||
|
||||
The `init.sh` script is just a small utility used to generate
|
||||
the `glad-gl` crate into the `build/` directory. The `Cargo.toml`
|
||||
references the dependency using:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
```
|
||||
|
||||
This example is the basic example of the
|
||||
[glfw crate](https://crates.io/crates/glfw) with some
|
||||
OpenGL instructions added and just one additional line
|
||||
to initialize `glad`:
|
||||
|
||||
```rust
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
```
|
||||
|
||||
That's all that is needed to initialize and use OpenGL using `glad`!
|
||||
|
||||
9
third-party/glad/example/rust/gl-glfw/init.sh
vendored
Executable file
9
third-party/glad/example/rust/gl-glfw/init.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASE_PATH="$(dirname $(realpath $0))"
|
||||
|
||||
|
||||
cd "${BASE_PATH}/../../../"
|
||||
|
||||
python -m glad --out-path "${BASE_PATH}/build" --extensions="" --api="gl:core=3.3" rust
|
||||
|
||||
40
third-party/glad/example/rust/gl-glfw/src/main.rs
vendored
Normal file
40
third-party/glad/example/rust/gl-glfw/src/main.rs
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
extern crate glfw;
|
||||
extern crate glad_gl;
|
||||
use glfw::{Action, Context, Key};
|
||||
use glad_gl::gl;
|
||||
|
||||
|
||||
fn main() {
|
||||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
||||
|
||||
let (mut window, events) = glfw.create_window(300, 300, "[glad] Rust - OpenGL with GLFW", glfw::WindowMode::Windowed)
|
||||
.expect("Failed to create GLFW window.");
|
||||
|
||||
window.set_key_polling(true);
|
||||
window.make_current();
|
||||
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
|
||||
while !window.should_close() {
|
||||
glfw.poll_events();
|
||||
for (_, event) in glfw::flush_messages(&events) {
|
||||
handle_window_event(&mut window, event);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
gl::ClearColor(0.7, 0.9, 0.1, 1.0);
|
||||
gl::Clear(gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
window.swap_buffers();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||
match event {
|
||||
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
|
||||
window.set_should_close(true)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user