first push, simple setup to use opengl
It's all insired in copy/paste style by: https://github.com/Nercury/rust-and-opengl-lessons
This commit is contained in:
commit
cf64bec257
24 changed files with 3139 additions and 0 deletions
11
lib/gl/Cargo.toml
Normal file
11
lib/gl/Cargo.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "gl"
|
||||
version = "0.1.0"
|
||||
authors = ["Nerijus Arlauskas <nercury@gmail.com>"]
|
||||
|
||||
[build-dependencies]
|
||||
gl_generator = "0.9"
|
||||
gl_generator_profiling_struct = "0.1"
|
||||
|
||||
[features]
|
||||
debug = []
|
||||
25
lib/gl/build.rs
Normal file
25
lib/gl/build.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
extern crate gl_generator;
|
||||
extern crate gl_generator_profiling_struct;
|
||||
|
||||
use gl_generator::{Api, Fallbacks, Profile, Registry};
|
||||
use gl_generator_profiling_struct::ProfilingStructGenerator;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let mut file_gl = File::create(&Path::new(&out_dir).join("bindings.rs")).unwrap();
|
||||
|
||||
let registry = Registry::new(
|
||||
Api::Gl,
|
||||
(4, 5),
|
||||
Profile::Core,
|
||||
Fallbacks::All,
|
||||
["GL_NV_command_list"],
|
||||
);
|
||||
|
||||
registry
|
||||
.write_bindings(ProfilingStructGenerator, &mut file_gl)
|
||||
.unwrap();
|
||||
}
|
||||
33
lib/gl/src/lib.rs
Normal file
33
lib/gl/src/lib.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
mod bindings {
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
}
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub use crate::bindings::Gl as InnerGl;
|
||||
pub use crate::bindings::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Gl {
|
||||
inner: Rc<bindings::Gl>,
|
||||
}
|
||||
|
||||
impl Gl {
|
||||
pub fn load_with<F>(loadfn: F) -> Gl
|
||||
where
|
||||
F: FnMut(&'static str) -> *const types::GLvoid,
|
||||
{
|
||||
Gl {
|
||||
inner: Rc::new(bindings::Gl::load_with(loadfn)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Gl {
|
||||
type Target = bindings::Gl;
|
||||
|
||||
fn deref(&self) -> &bindings::Gl {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue