Skip to content

Commit

Permalink
Named buffer storage (#338)
Browse files Browse the repository at this point in the history
* Add function call for NamedBufferStorage

* Fix webgl and formatting

* Fix formatting

---------

Co-authored-by: dhyces <10985914+dhyces@users.noreply.github.com>
  • Loading branch information
grovesNL and dhyces authored Feb 23, 2025
1 parent ac114b8 commit aa4238a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ pub trait HasContext: __private::Sealed {

unsafe fn buffer_storage(&self, target: u32, size: i32, data: Option<&[u8]>, flags: u32);

unsafe fn named_buffer_storage(
&self,
target: Self::Buffer,
size: i32,
data: Option<&[u8]>,
flags: u32,
);

unsafe fn check_framebuffer_status(&self, target: u32) -> u32;

unsafe fn check_named_framebuffer_status(
Expand Down
11 changes: 11 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,17 @@ impl HasContext for Context {
gl.BufferStorageEXT(target, size, data, flags);
}
}
unsafe fn named_buffer_storage(
&self,
buffer: Self::Buffer,
size: i32,
data: Option<&[u8]>,
flags: u32,
) {
let gl = &self.raw;
let data = data.map(|p| p.as_ptr()).unwrap_or(std::ptr::null()) as *const std::ffi::c_void;
gl.NamedBufferStorage(buffer.0.get(), size as isize, data, flags);
}

unsafe fn check_framebuffer_status(&self, target: u32) -> u32 {
let gl = &self.raw;
Expand Down
10 changes: 10 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,16 @@ impl HasContext for Context {
panic!("Buffer storage is not supported");
}

unsafe fn named_buffer_storage(
&self,
buffer: Self::Buffer,
size: i32,
data: Option<&[u8]>,
flags: u32,
) {
panic!("Named buffer storage is not supported");
}

unsafe fn check_framebuffer_status(&self, target: u32) -> u32 {
match self.raw {
RawRenderingContext::WebGl1(ref gl) => gl.check_framebuffer_status(target),
Expand Down

0 comments on commit aa4238a

Please # to comment.