Skip to content

Commit

Permalink
Add glNamedFramebufferReadBuffer and glNamedFramebufferDrawBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Aug 9, 2024
1 parent cfc0b90 commit ad84650
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,12 @@ pub trait HasContext: __private::Sealed {

unsafe fn draw_buffer(&self, buffer: u32);

unsafe fn named_framebuffer_draw_buffer(
&self,
framebuffer: Option<Self::Framebuffer>,
draw_buffer: u32,
);

unsafe fn draw_buffers(&self, buffers: &[u32]);

unsafe fn draw_elements(&self, mode: u32, count: i32, element_type: u32, offset: i32);
Expand Down Expand Up @@ -1623,6 +1629,12 @@ pub trait HasContext: __private::Sealed {

unsafe fn read_buffer(&self, src: u32);

unsafe fn named_framebuffer_read_buffer(
&self,
framebuffer: Option<Self::Framebuffer>,
src: u32,
);

unsafe fn read_pixels(
&self,
x: i32,
Expand Down
18 changes: 18 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,15 @@ impl HasContext for Context {
gl.DrawBuffer(draw_buffer);
}

unsafe fn named_framebuffer_draw_buffer(
&self,
framebuffer: Option<Self::Framebuffer>,
draw_buffer: u32,
) {
let gl = &self.raw;
gl.NamedFramebufferDrawBuffer(framebuffer.map(|f| f.0.get()).unwrap_or(0), draw_buffer);
}

unsafe fn draw_buffers(&self, buffers: &[u32]) {
let gl = &self.raw;
gl.DrawBuffers(buffers.len() as i32, buffers.as_ptr());
Expand Down Expand Up @@ -3703,6 +3712,15 @@ impl HasContext for Context {
gl.ReadBuffer(src);
}

unsafe fn named_framebuffer_read_buffer(
&self,
framebuffer: Option<Self::Framebuffer>,
src: u32,
) {
let gl = &self.raw;
gl.NamedFramebufferReadBuffer(framebuffer.map(|f| f.0.get()).unwrap_or(0), src);
}

unsafe fn read_pixels(
&self,
x: i32,
Expand Down
16 changes: 16 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2986,6 +2986,14 @@ impl HasContext for Context {
}
}

unsafe fn named_framebuffer_draw_buffer(
&self,
_framebuffer: Option<Self::Framebuffer>,
_draw_buffer: u32,
) {
panic!("Named framebuffers are not supported");
}

unsafe fn draw_buffers(&self, buffers: &[u32]) {
match self.raw {
RawRenderingContext::WebGl1(ref _gl) => {
Expand Down Expand Up @@ -5204,6 +5212,14 @@ impl HasContext for Context {
}
}

unsafe fn named_framebuffer_read_buffer(
&self,
_framebuffer: Option<Self::Framebuffer>,
_src: u32,
) {
panic!("Named framebuffers are not supported");
}

unsafe fn read_pixels(
&self,
x: i32,
Expand Down

0 comments on commit ad84650

Please sign in to comment.