Skip to content

Commit

Permalink
Merge #13
Browse files Browse the repository at this point in the history
13: Add support for pixel buffer offset in get_tex_image r=grovesNL a=kyren

Necessary for this gfx PR: gfx-rs/gfx#2822

Co-authored-by: kyren <kerriganw@gmail.com>
  • Loading branch information
bors[bot] and kyren committed Jun 13, 2019
2 parents 91ee117 + 69762be commit 33e3d63
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub trait Context {

unsafe fn get_shader_info_log(&self, shader: Self::Shader) -> String;

unsafe fn get_tex_image(
unsafe fn get_tex_image_u8_slice(
&self,
target: u32,
level: i32,
Expand All @@ -114,6 +114,15 @@ pub trait Context {
pixels: Option<&[u8]>,
);

unsafe fn get_tex_image_pixel_buffer_offset(
&self,
target: u32,
level: i32,
format: u32,
ty: u32,
pixel_buffer_offset: i32,
);

unsafe fn create_program(&self) -> Result<Self::Program, String>;

unsafe fn delete_program(&self, program: Self::Program);
Expand Down
20 changes: 19 additions & 1 deletion src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl super::Context for Context {
}
}

unsafe fn get_tex_image(
unsafe fn get_tex_image_u8_slice(
&self,
target: u32,
level: i32,
Expand All @@ -137,6 +137,24 @@ impl super::Context for Context {
);
}

unsafe fn get_tex_image_pixel_buffer_offset(
&self,
target: u32,
level: i32,
format: u32,
ty: u32,
pixel_buffer_offset: i32,
) {
let gl = &self.raw;
gl.GetTexImage(
target,
level,
format,
ty,
pixel_buffer_offset as *mut std::ffi::c_void,
);
}

unsafe fn create_program(&self) -> Result<Self::Program, String> {
let gl = &self.raw;
Ok(gl.CreateProgram())
Expand Down
13 changes: 12 additions & 1 deletion src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl super::Context for Context {
.unwrap_or_else(|| String::from(""))
}

unsafe fn get_tex_image(
unsafe fn get_tex_image_u8_slice(
&self,
_target: u32,
_level: i32,
Expand All @@ -243,6 +243,17 @@ impl super::Context for Context {
panic!("Get tex image is not supported");
}

unsafe fn get_tex_image_pixel_buffer_offset(
&self,
_target: u32,
_level: i32,
_format: u32,
_ty: u32,
_pixel_buffer_offset: i32,
) {
panic!("Get tex image is not supported");
}

unsafe fn create_program(&self) -> Result<Self::Program, String> {
let raw_program = match self.raw {
RawRenderingContext::WebGl1(ref gl) => gl.create_program(),
Expand Down

0 comments on commit 33e3d63

Please sign in to comment.