aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-11-05 15:22:21 +0100
committerTomaka17 <pierre.krieger1708@gmail.com>2014-11-05 15:32:01 +0100
commit7ce851dad9102c28ee2fd372ed9fd62e73364da9 (patch)
tree54f1b395234484522b34994b2d4ae36292d916af /examples
parent2e44edea60a19919be467a1228ae971e7b988fec (diff)
downloadglutin-7ce851dad9102c28ee2fd372ed9fd62e73364da9.tar.gz
glutin-7ce851dad9102c28ee2fd372ed9fd62e73364da9.zip
Update for changes in gl-rs
Diffstat (limited to 'examples')
-rw-r--r--examples/support/mod.rs66
1 files changed, 35 insertions, 31 deletions
diff --git a/examples/support/mod.rs b/examples/support/mod.rs
index 1e61165..eb27d23 100644
--- a/examples/support/mod.rs
+++ b/examples/support/mod.rs
@@ -31,7 +31,7 @@ pub struct Context {
}
pub fn load(window: &glutin::Window) -> Context {
- let gl = gl::Gl::load_with(|symbol| window.get_proc_address(symbol));
+ let gl = gl::Gl::load(window);
let version = {
use std::c_str::CString;
@@ -46,42 +46,46 @@ pub fn load(window: &glutin::Window) -> Context {
impl Context {
#[cfg(not(target_os = "android"))]
pub fn draw_frame(&self, color: (f32, f32, f32, f32)) {
- self.gl.ClearColor(color.0, color.1, color.2, color.3);
- self.gl.Clear(gl::COLOR_BUFFER_BIT);
-
- self.gl.Begin(gl::TRIANGLES);
- self.gl.Color3f(1.0, 0.0, 0.0);
- self.gl.Vertex2f(-0.5, -0.5);
- self.gl.Color3f(0.0, 1.0, 0.0);
- self.gl.Vertex2f(0.0, 0.5);
- self.gl.Color3f(0.0, 0.0, 1.0);
- self.gl.Vertex2f(0.5, -0.5);
- self.gl.End();
-
- self.gl.Flush();
+ unsafe {
+ self.gl.ClearColor(color.0, color.1, color.2, color.3);
+ self.gl.Clear(gl::COLOR_BUFFER_BIT);
+
+ self.gl.Begin(gl::TRIANGLES);
+ self.gl.Color3f(1.0, 0.0, 0.0);
+ self.gl.Vertex2f(-0.5, -0.5);
+ self.gl.Color3f(0.0, 1.0, 0.0);
+ self.gl.Vertex2f(0.0, 0.5);
+ self.gl.Color3f(0.0, 0.0, 1.0);
+ self.gl.Vertex2f(0.5, -0.5);
+ self.gl.End();
+
+ self.gl.Flush();
+ }
}
#[cfg(target_os = "android")]
pub fn draw_frame(&self, color: (f32, f32, f32, f32)) {
- self.gl.ClearColor(color.0, color.1, color.2, color.3);
- self.gl.Clear(gl::COLOR_BUFFER_BIT);
-
- self.gl.EnableClientState(gl::VERTEX_ARRAY);
- self.gl.EnableClientState(gl::COLOR_ARRAY);
-
unsafe {
- use std::mem;
- self.gl.VertexPointer(2, gl::FLOAT, (mem::size_of::<f32>() * 5) as i32,
- mem::transmute(VERTEX_DATA.as_slice().as_ptr()));
- self.gl.ColorPointer(3, gl::FLOAT, (mem::size_of::<f32>() * 5) as i32,
- mem::transmute(VERTEX_DATA.as_slice().as_ptr().offset(2)));
+ self.gl.ClearColor(color.0, color.1, color.2, color.3);
+ self.gl.Clear(gl::COLOR_BUFFER_BIT);
+
+ self.gl.EnableClientState(gl::VERTEX_ARRAY);
+ self.gl.EnableClientState(gl::COLOR_ARRAY);
+
+ unsafe {
+ use std::mem;
+ self.gl.VertexPointer(2, gl::FLOAT, (mem::size_of::<f32>() * 5) as i32,
+ mem::transmute(VERTEX_DATA.as_slice().as_ptr()));
+ self.gl.ColorPointer(3, gl::FLOAT, (mem::size_of::<f32>() * 5) as i32,
+ mem::transmute(VERTEX_DATA.as_slice().as_ptr().offset(2)));
+ }
+
+ self.gl.DrawArrays(gl::TRIANGLES, 0, 3);
+ self.gl.DisableClientState(gl::VERTEX_ARRAY);
+ self.gl.DisableClientState(gl::COLOR_ARRAY);
+
+ self.gl.Flush();
}
-
- self.gl.DrawArrays(gl::TRIANGLES, 0, 3);
- self.gl.DisableClientState(gl::VERTEX_ARRAY);
- self.gl.DisableClientState(gl::COLOR_ARRAY);
-
- self.gl.Flush();
}
}