Skip to content

Commit

Permalink
Add get_renderbuffer_parameter_i32
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Oct 24, 2024
1 parent ea9fee4 commit 2e05eff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@ pub trait HasContext: __private::Sealed {

unsafe fn get_parameter_vertex_array(&self, parameter: u32) -> Option<Self::VertexArray>;

unsafe fn get_renderbuffer_parameter_i32(&self, target: u32, parameter: u32) -> i32;

unsafe fn get_framebuffer_parameter_i32(&self, target: u32, parameter: u32) -> i32;

unsafe fn get_named_framebuffer_parameter_i32(
Expand Down
7 changes: 7 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,13 @@ impl HasContext for Context {
self.get_parameter_gl_name(parameter).map(NativeVertexArray)
}

unsafe fn get_renderbuffer_parameter_i32(&self, target: u32, parameter: u32) -> i32 {
let gl = &self.raw;
let mut value = 0;
gl.GetRenderbufferParameteriv(target, parameter, &mut value);
value
}

unsafe fn get_framebuffer_parameter_i32(&self, target: u32, parameter: u32) -> i32 {
let gl = &self.raw;
let mut value = 0;
Expand Down
12 changes: 12 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3643,6 +3643,18 @@ impl HasContext for Context {
panic!("Get framebuffer parameter is not supported");
}

unsafe fn get_renderbuffer_parameter_i32(&self, target: u32, parameter: u32) -> i32 {
match self.raw {
RawRenderingContext::WebGl1(ref gl) => gl.get_renderbuffer_parameter(target, parameter),
RawRenderingContext::WebGl2(ref gl) => gl.get_renderbuffer_parameter(target, parameter),
}
.as_f64()
.map(|v| v as i32)
// Errors will be caught by the browser or through `get_error`
// so return a default instead
.unwrap_or(0)
}

unsafe fn get_named_framebuffer_parameter_i32(
&self,
_framebuffer: Option<Self::Framebuffer>,
Expand Down

0 comments on commit 2e05eff

Please sign in to comment.