Skip to content

Commit

Permalink
[GL] Add support for glVertexAttribIPointer (support signed/unsigned …
Browse files Browse the repository at this point in the history
…byte, short, int attributes)
  • Loading branch information
eloraiby authored and not-fl3 committed Jun 22, 2024
1 parent fbadb64 commit a359a34
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
3 changes: 3 additions & 0 deletions js/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ var importObject = {
glVertexAttribPointer: function (index, size, type, normalized, stride, ptr) {
gl.vertexAttribPointer(index, size, type, !!normalized, stride, ptr);
},
glVertexAttribIPointer: function (index, size, type, stride, ptr) {
gl.vertexAttribIPointer(index, size, type, stride, ptr);
},
glGetUniformLocation: function (program, name) {
GL.validateGLObjectID(GL.programs, program, 'glGetUniformLocation', 'program');
name = UTF8ToString(name);
Expand Down
26 changes: 18 additions & 8 deletions src/graphics/gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,14 +1317,24 @@ impl RenderingBackend for GlContext {
.bind_buffer(GL_ARRAY_BUFFER, vb.gl_buf, vb.index_type);

unsafe {
glVertexAttribPointer(
attr_index as GLuint,
attribute.size,
attribute.type_,
GL_FALSE as u8,
attribute.stride,
attribute.offset as *mut _,
);
match attribute.type_ {
GL_INT | GL_UNSIGNED_INT | GL_SHORT | GL_UNSIGNED_SHORT
| GL_UNSIGNED_BYTE | GL_BYTE => glVertexAttribIPointer(
attr_index as GLuint,
attribute.size,
attribute.type_,
attribute.stride,
attribute.offset as *mut _,
),
_ => glVertexAttribPointer(
attr_index as GLuint,
attribute.size,
attribute.type_,
GL_FALSE as u8,
attribute.stride,
attribute.offset as *mut _,
),
}
if self.features.instancing {
glVertexAttribDivisor(attr_index as GLuint, attribute.divisor as u32);
}
Expand Down
7 changes: 7 additions & 0 deletions src/native/gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,13 @@ gl_loader!(
stride: GLsizei,
pointer: *const ::std::os::raw::c_void
) -> (),
fn glVertexAttribIPointer(
index: GLuint,
size: GLint,
type_: GLenum,
stride: GLsizei,
pointer: *const ::std::os::raw::c_void
) -> (),
fn glDisable(cap: GLenum) -> (),
fn glColorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) -> (),
fn glBindBuffer(target: GLenum, buffer: GLuint) -> (),
Expand Down
9 changes: 9 additions & 0 deletions src/native/wasm/webgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,15 @@ extern "C" {
pointer: *const ::std::os::raw::c_void,
);
}
extern "C" {
pub fn glVertexAttribIPointer(
index: GLuint,
size: GLint,
type_: GLenum,
stride: GLsizei,
pointer: *const ::std::os::raw::c_void,
);
}
extern "C" {
pub fn glViewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei);
}
Expand Down

0 comments on commit a359a34

Please sign in to comment.