Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/device/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ authors = [
name = "device"
path = "lib.rs"

[dependencies.gl_generator]
git = "https://github.com/bjz/gl-rs.git"
[dependencies.gl]
path = "../gl_device/gl/"
12 changes: 6 additions & 6 deletions src/device/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
#[phase(plugin, link)] extern crate log;
extern crate libc;

// when cargo is ready, re-enable the cfgs
/* #[cfg(gl)] */ pub use self::gl as back;
/* #[cfg(gl)] */ pub use gl::GlDevice;
/* #[cfg(gl)] */ pub use gl::draw::GlCommandBuffer;
// #[cfg(d3d11)] ... // TODO
// TODO: Remove these exports once `gl_device` becomes a separate crate.
pub use self::gl_device as back;

use std::mem;

Expand All @@ -43,7 +40,10 @@ pub mod shade;
pub mod state;
pub mod target;
pub mod tex;
/* #[cfg(gl)] */ mod gl;

// TODO: This will become a separate crate once associated items are implemented
// in rustc and subsequently used in the `Device` trait.
/* #[cfg(gl)] */ #[path = "../gl_device/lib.rs"] pub mod gl_device;

/// Draw vertex count.
pub type VertexCount = u32;
Expand Down
5 changes: 3 additions & 2 deletions src/gfx/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ pub use render::state::{DrawState, BlendAdditive, BlendAlpha};
pub use render::shade;
pub use render::target::{Frame, Plane, PlaneEmpty, PlaneSurface, PlaneTexture};
pub use device::Device;
// when cargo is ready, re-enable the cfgs
/* #[cfg(gl)] */ pub use device::{GlDevice, GlCommandBuffer};
pub use device::{attrib, state, tex};
pub use device::{BufferHandle, BufferInfo, RawBufferHandle, ShaderHandle,
ProgramHandle, SurfaceHandle, TextureHandle};
Expand All @@ -56,3 +54,6 @@ pub use device::shade::{UniformValue,
ValueF32Matrix2, ValueF32Matrix3, ValueF32Matrix4};
pub use device::shade::{ShaderSource, StaticBytes, OwnedBytes, ProgramInfo};
pub use device::target::{Color, ClearData, Layer, Level};

// TODO: Remove this re-export once `gl_device` becomes a separate crate.
pub use device::gl_device::{GlDevice, GlCommandBuffer};
File renamed without changes.
13 changes: 13 additions & 0 deletions src/gl_device/gl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]

name = "gl"
version = "0.1.0"
authors = [
]

[lib]
name = "gl"
path = "lib.rs"

[dependencies.gl_generator]
git = "https://github.com/bjz/gl-rs.git"
30 changes: 30 additions & 0 deletions src/gl_device/gl/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

#![crate_name = "gl"]
#![comment = "An OpenGL loader tailored to gfx-rs's needs."]
#![license = "ASL2"]
#![crate_type = "lib"]

#![feature(phase)]

//! An OpenGL loader generated by [gl-rs](https://github.com/bjz/gl-rs).
//!
//! This is useful for directly accessing the underlying OpenGL API via the
//! `GlDevice::with_gl` method. It is also used internally by the `GlDevice`
//! implementation.

#[phase(plugin)] extern crate gl_generator;

generate_gl_bindings!("gl", "core", "4.5", "struct", [ "GL_EXT_texture_filter_anisotropic" ])
File renamed without changes.
22 changes: 10 additions & 12 deletions src/device/gl/mod.rs → src/gl_device/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! OpenGL implementation of a device, striving to support OpenGL 2.0 with at least VAOs, but using
//! newer extensions when available.
//! OpenGL implementation of a device, striving to support OpenGL 2.0 with at
//! least VAOs, but using newer extensions when available.

#![allow(missing_doc)]
#![experimental]

#[phase(plugin)] extern crate gl_generator;
extern crate libc;
extern crate gl;

use log;

Expand All @@ -28,18 +28,15 @@ use attrib;
use Device;
use blob::{Blob, RefBlobCast};

pub use self::draw::GlCommandBuffer;
pub use self::info::{Info, PlatformName, Version};

pub mod draw;
mod draw;
mod shade;
mod state;
mod tex;
mod info;

mod gl {
generate_gl_bindings!("gl", "core", "4.5", "struct", [ "GL_EXT_texture_filter_anisotropic" ])
}

pub type Buffer = gl::types::GLuint;
pub type ArrayBuffer = gl::types::GLuint;
pub type Shader = gl::types::GLuint;
Expand Down Expand Up @@ -132,8 +129,9 @@ impl GlDevice {
}
}

/// Access the GL directly using a closure
pub fn with_gl(&mut self, fun: |&gl::Gl|) {
/// Access the OpenGL directly via a closure. OpenGL types and enumerations
/// can be found in the `gl` crate.
pub unsafe fn with_gl(&mut self, fun: |&gl::Gl|) {
self.reset_state();
fun(&self.gl);
}
Expand Down Expand Up @@ -423,7 +421,7 @@ impl GlDevice {
}
}

impl Device<draw::GlCommandBuffer> for GlDevice {
impl Device<GlCommandBuffer> for GlDevice {
fn get_capabilities<'a>(&'a self) -> &'a ::Capabilities {
&self.caps
}
Expand All @@ -434,7 +432,7 @@ impl Device<draw::GlCommandBuffer> for GlDevice {
}
}

fn submit(&mut self, cb: &draw::GlCommandBuffer) {
fn submit(&mut self, cb: &GlCommandBuffer) {
self.reset_state();
for com in cb.iter() {
self.process(com);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.