Skip to content
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

Resource management #144

Merged
merged 5 commits into from
Jul 30, 2014
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.DS_Store
/doc/
/examples/
/examples/*/target/
/lib/
/test/
target/
19 changes: 19 additions & 0 deletions src/device/gl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,25 @@ impl super::ApiBackEnd for GlBackEnd {
}
self.check();
},
// Resource deletion
super::DeleteBuffer(name) => unsafe {
gl::DeleteBuffers(1, &name);
},
super::DeleteShader(name) => {
gl::DeleteShader(name);
},
super::DeleteProgram(name) => {
gl::DeleteProgram(name);
},
super::DeleteSurface(name) => unsafe {
gl::DeleteRenderbuffers(1, &name);
},
super::DeleteTexture(name) => unsafe {
gl::DeleteTextures(1, &name);
},
super::DeleteSampler(name) => unsafe {
gl::DeleteSamplers(1, &name);
},
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/device/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ pub enum CastRequest {
UpdateTexture(tex::TextureKind, dev::Texture, tex::ImageInfo, Box<Blob + Send>),
Draw(VertexCount, VertexCount),
DrawIndexed(IndexCount, IndexCount),
/// Resource deletion
DeleteBuffer(dev::Buffer),
DeleteShader(dev::Shader),
DeleteProgram(dev::Program),
DeleteSurface(dev::Surface),
DeleteTexture(dev::Texture),
DeleteSampler(dev::Sampler),
}

/// Reply to a `Call`
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern crate device;
extern crate render;

// public re-exports
pub use render::{BufferHandle, SurfaceHandle, TextureHandle, SamplerHandle, ProgramHandle, EnvirHandle};
pub use render::{BufferHandle, ShaderHandle, ProgramHandle, SurfaceHandle, TextureHandle, SamplerHandle};
pub use render::Renderer;
pub use render::mesh::{Attribute, Mesh, VertexFormat, Slice, VertexSlice, IndexSlice};
pub use render::state::{DrawState, BlendAdditive, BlendAlpha};
Expand Down
3 changes: 2 additions & 1 deletion src/gfx_macros_test/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#[phase(plugin)]
extern crate gfx_macros;
extern crate gfx;
extern crate render;

#[test]
fn test_vertex_format() {
Expand All @@ -35,7 +36,7 @@ fn test_vertex_format() {
a3: f64,
}

let buf = 0 as gfx::BufferHandle;
let buf = render::Renderer::create_fake_buffer();
let mesh = gfx::Mesh::from::<MyVertex>(buf, 0);
let stride = 22 as a::Stride;

Expand Down
Loading