Skip to content

Commit

Permalink
Add and use GL_APPLE_vertex_array_object as fallback on apple devices
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev committed Nov 1, 2024
1 parent a18ac67 commit 0d1e3ac
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 0 deletions.
1 change: 1 addition & 0 deletions generate-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ gl_extensions=(
GL_KHR_parallel_shader_compile
GL_ARB_parallel_shader_compile
GL_OES_vertex_array_object
GL_APPLE_vertex_array_object
)
printf -v gl_extensions_comma_joined '%s,' "${gl_extensions[@]}"

Expand Down
163 changes: 163 additions & 0 deletions src/gl46.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! Generated by [phosphorus](https://docs.rs/phosphorus/0.0.22/phosphorus/).
//!
//! Included Extensions (activate via cargo feature):
//! * `GL_APPLE_vertex_array_object`
//! * `GL_ARB_base_instance`
//! * `GL_ARB_buffer_storage`
//! * `GL_ARB_compute_shader`
Expand Down Expand Up @@ -4343,6 +4344,8 @@ pub mod enums {
#[doc = "`GL_VERTEX_ARRAY_BINDING: GLenum = 0x85B5`"]
#[doc = "* **Group:** GetPName"]
pub const GL_VERTEX_ARRAY_BINDING: GLenum = 0x85B5;
#[doc = "`GL_VERTEX_ARRAY_BINDING_APPLE: GLenum = 0x85B5`"]
pub const GL_VERTEX_ARRAY_BINDING_APPLE: GLenum = 0x85B5;
#[doc = "`GL_VERTEX_ARRAY_BINDING_OES: GLenum = 0x85B5`"]
pub const GL_VERTEX_ARRAY_BINDING_OES: GLenum = 0x85B5;
#[doc = "`GL_VERTEX_ARRAY_KHR: GLenum = 0x8074`"]
Expand Down Expand Up @@ -4881,6 +4884,9 @@ pub mod struct_commands {
self.BindTextures_load_with_dyn(get_proc_address);
self.BindTransformFeedback_load_with_dyn(get_proc_address);
self.BindVertexArray_load_with_dyn(get_proc_address);
{
self.BindVertexArrayAPPLE_load_with_dyn(get_proc_address);
}
{
self.BindVertexArrayOES_load_with_dyn(get_proc_address);
}
Expand Down Expand Up @@ -5003,6 +5009,9 @@ pub mod struct_commands {
self.DeleteTextures_load_with_dyn(get_proc_address);
self.DeleteTransformFeedbacks_load_with_dyn(get_proc_address);
self.DeleteVertexArrays_load_with_dyn(get_proc_address);
{
self.DeleteVertexArraysAPPLE_load_with_dyn(get_proc_address);
}
{
self.DeleteVertexArraysOES_load_with_dyn(get_proc_address);
}
Expand Down Expand Up @@ -5080,6 +5089,9 @@ pub mod struct_commands {
self.GenTextures_load_with_dyn(get_proc_address);
self.GenTransformFeedbacks_load_with_dyn(get_proc_address);
self.GenVertexArrays_load_with_dyn(get_proc_address);
{
self.GenVertexArraysAPPLE_load_with_dyn(get_proc_address);
}
{
self.GenVertexArraysOES_load_with_dyn(get_proc_address);
}
Expand Down Expand Up @@ -5260,6 +5272,9 @@ pub mod struct_commands {
self.IsTexture_load_with_dyn(get_proc_address);
self.IsTransformFeedback_load_with_dyn(get_proc_address);
self.IsVertexArray_load_with_dyn(get_proc_address);
{
self.IsVertexArrayAPPLE_load_with_dyn(get_proc_address);
}
{
self.IsVertexArrayOES_load_with_dyn(get_proc_address);
}
Expand Down Expand Up @@ -6714,6 +6729,41 @@ pub mod struct_commands {
pub fn BindVertexArray_is_loaded(&self) -> bool {
!self.glBindVertexArray_p.load(RELAX).is_null()
}
/// [glBindVertexArrayAPPLE](http://docs.gl/gl4/glBindVertexArrayAPPLE)(array)
#[cfg_attr(feature = "inline", inline)]
#[cfg_attr(feature = "inline_always", inline(always))]
pub unsafe fn BindVertexArrayAPPLE(&self, array: GLuint) {
#[cfg(all(debug_assertions, feature = "debug_trace_calls"))]
{
trace!("calling gl.BindVertexArrayAPPLE({:?});", array);
}
let out = call_atomic_ptr_1arg(
"glBindVertexArrayAPPLE",
&self.glBindVertexArrayAPPLE_p,
array,
);
#[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))]
{
self.automatic_glGetError("glBindVertexArrayAPPLE");
}
out
}
#[doc(hidden)]
pub unsafe fn BindVertexArrayAPPLE_load_with_dyn(
&self,
get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void,
) -> bool {
load_dyn_name_atomic_ptr(
get_proc_address,
b"glBindVertexArrayAPPLE\0",
&self.glBindVertexArrayAPPLE_p,
)
}
#[inline]
#[doc(hidden)]
pub fn BindVertexArrayAPPLE_is_loaded(&self) -> bool {
!self.glBindVertexArrayAPPLE_p.load(RELAX).is_null()
}
/// [glBindVertexArrayOES](http://docs.gl/gl4/glBindVertexArrayOES)(array)
/// * alias of: [`glBindVertexArray`]
#[cfg_attr(feature = "inline", inline)]
Expand Down Expand Up @@ -11511,6 +11561,44 @@ pub mod struct_commands {
pub fn DeleteVertexArrays_is_loaded(&self) -> bool {
!self.glDeleteVertexArrays_p.load(RELAX).is_null()
}
/// [glDeleteVertexArraysAPPLE](http://docs.gl/gl4/glDeleteVertexArraysAPPLE)(n, arrays)
/// * `arrays` len: n
/// * alias of: [`glDeleteVertexArrays`]
#[cfg_attr(feature = "inline", inline)]
#[cfg_attr(feature = "inline_always", inline(always))]
pub unsafe fn DeleteVertexArraysAPPLE(&self, n: GLsizei, arrays: *const GLuint) {
#[cfg(all(debug_assertions, feature = "debug_trace_calls"))]
{
trace!("calling gl.DeleteVertexArraysAPPLE({:?}, {:p});", n, arrays);
}
let out = call_atomic_ptr_2arg(
"glDeleteVertexArraysAPPLE",
&self.glDeleteVertexArraysAPPLE_p,
n,
arrays,
);
#[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))]
{
self.automatic_glGetError("glDeleteVertexArraysAPPLE");
}
out
}
#[doc(hidden)]
pub unsafe fn DeleteVertexArraysAPPLE_load_with_dyn(
&self,
get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void,
) -> bool {
load_dyn_name_atomic_ptr(
get_proc_address,
b"glDeleteVertexArraysAPPLE\0",
&self.glDeleteVertexArraysAPPLE_p,
)
}
#[inline]
#[doc(hidden)]
pub fn DeleteVertexArraysAPPLE_is_loaded(&self) -> bool {
!self.glDeleteVertexArraysAPPLE_p.load(RELAX).is_null()
}
/// [glDeleteVertexArraysOES](http://docs.gl/gl4/glDeleteVertexArraysOES)(n, arrays)
/// * `arrays` len: n
/// * alias of: [`glDeleteVertexArrays`]
Expand Down Expand Up @@ -14231,6 +14319,44 @@ pub mod struct_commands {
pub fn GenVertexArrays_is_loaded(&self) -> bool {
!self.glGenVertexArrays_p.load(RELAX).is_null()
}
/// [glGenVertexArraysAPPLE](http://docs.gl/gl4/glGenVertexArraysAPPLE)(n, arrays)
/// * `arrays` len: n
/// * alias of: [`glGenVertexArrays`]
#[cfg_attr(feature = "inline", inline)]
#[cfg_attr(feature = "inline_always", inline(always))]
pub unsafe fn GenVertexArraysAPPLE(&self, n: GLsizei, arrays: *mut GLuint) {
#[cfg(all(debug_assertions, feature = "debug_trace_calls"))]
{
trace!("calling gl.GenVertexArraysAPPLE({:?}, {:p});", n, arrays);
}
let out = call_atomic_ptr_2arg(
"glGenVertexArraysAPPLE",
&self.glGenVertexArraysAPPLE_p,
n,
arrays,
);
#[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))]
{
self.automatic_glGetError("glGenVertexArraysAPPLE");
}
out
}
#[doc(hidden)]
pub unsafe fn GenVertexArraysAPPLE_load_with_dyn(
&self,
get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void,
) -> bool {
load_dyn_name_atomic_ptr(
get_proc_address,
b"glGenVertexArraysAPPLE\0",
&self.glGenVertexArraysAPPLE_p,
)
}
#[inline]
#[doc(hidden)]
pub fn GenVertexArraysAPPLE_is_loaded(&self) -> bool {
!self.glGenVertexArraysAPPLE_p.load(RELAX).is_null()
}
/// [glGenVertexArraysOES](http://docs.gl/gl4/glGenVertexArraysOES)(n, arrays)
/// * `arrays` len: n
/// * alias of: [`glGenVertexArrays`]
Expand Down Expand Up @@ -21724,6 +21850,39 @@ pub mod struct_commands {
pub fn IsVertexArray_is_loaded(&self) -> bool {
!self.glIsVertexArray_p.load(RELAX).is_null()
}
/// [glIsVertexArrayAPPLE](http://docs.gl/gl4/glIsVertexArrayAPPLE)(array)
/// * alias of: [`glIsVertexArray`]
#[cfg_attr(feature = "inline", inline)]
#[cfg_attr(feature = "inline_always", inline(always))]
pub unsafe fn IsVertexArrayAPPLE(&self, array: GLuint) -> GLboolean {
#[cfg(all(debug_assertions, feature = "debug_trace_calls"))]
{
trace!("calling gl.IsVertexArrayAPPLE({:?});", array);
}
let out =
call_atomic_ptr_1arg("glIsVertexArrayAPPLE", &self.glIsVertexArrayAPPLE_p, array);
#[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))]
{
self.automatic_glGetError("glIsVertexArrayAPPLE");
}
out
}
#[doc(hidden)]
pub unsafe fn IsVertexArrayAPPLE_load_with_dyn(
&self,
get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void,
) -> bool {
load_dyn_name_atomic_ptr(
get_proc_address,
b"glIsVertexArrayAPPLE\0",
&self.glIsVertexArrayAPPLE_p,
)
}
#[inline]
#[doc(hidden)]
pub fn IsVertexArrayAPPLE_is_loaded(&self) -> bool {
!self.glIsVertexArrayAPPLE_p.load(RELAX).is_null()
}
/// [glIsVertexArrayOES](http://docs.gl/gl4/glIsVertexArrayOES)(array)
/// * alias of: [`glIsVertexArray`]
#[cfg_attr(feature = "inline", inline)]
Expand Down Expand Up @@ -36441,6 +36600,7 @@ pub mod struct_commands {
glBindTextures_p: APcv,
glBindTransformFeedback_p: APcv,
glBindVertexArray_p: APcv,
glBindVertexArrayAPPLE_p: APcv,
glBindVertexArrayOES_p: APcv,
glBindVertexBuffer_p: APcv,
glBindVertexBuffers_p: APcv,
Expand Down Expand Up @@ -36543,6 +36703,7 @@ pub mod struct_commands {
glDeleteTextures_p: APcv,
glDeleteTransformFeedbacks_p: APcv,
glDeleteVertexArrays_p: APcv,
glDeleteVertexArraysAPPLE_p: APcv,
glDeleteVertexArraysOES_p: APcv,
glDepthFunc_p: APcv,
glDepthMask_p: APcv,
Expand Down Expand Up @@ -36610,6 +36771,7 @@ pub mod struct_commands {
glGenTextures_p: APcv,
glGenTransformFeedbacks_p: APcv,
glGenVertexArrays_p: APcv,
glGenVertexArraysAPPLE_p: APcv,
glGenVertexArraysOES_p: APcv,
glGenerateMipmap_p: APcv,
glGenerateTextureMipmap_p: APcv,
Expand Down Expand Up @@ -36772,6 +36934,7 @@ pub mod struct_commands {
glIsTexture_p: APcv,
glIsTransformFeedback_p: APcv,
glIsVertexArray_p: APcv,
glIsVertexArrayAPPLE_p: APcv,
glIsVertexArrayOES_p: APcv,
glLineWidth_p: APcv,
glLinkProgram_p: APcv,
Expand Down
9 changes: 9 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,10 @@ impl HasContext for Context {
if gl.GenVertexArrays_is_loaded() {
gl.GenVertexArrays(1, &mut vertex_array);
} else {
#[cfg(not(target_vendor = "apple"))]
gl.GenVertexArraysOES(1, &mut vertex_array);
#[cfg(target_vendor = "apple")]
gl.GenVertexArraysAPPLE(1, &mut vertex_array);
}
NonZeroU32::new(vertex_array)
.map(NativeVertexArray)
Expand All @@ -1291,7 +1294,10 @@ impl HasContext for Context {
if gl.DeleteVertexArrays_is_loaded() {
gl.DeleteVertexArrays(1, &vertex_array.0.get());
} else {
#[cfg(not(target_vendor = "apple"))]
gl.DeleteVertexArraysOES(1, &vertex_array.0.get());
#[cfg(target_vendor = "apple")]
gl.DeleteVertexArraysAPPLE(1, &vertex_array.0.get());
}
}

Expand All @@ -1300,7 +1306,10 @@ impl HasContext for Context {
if gl.BindVertexArray_is_loaded() {
gl.BindVertexArray(vertex_array.map(|va| va.0.get()).unwrap_or(0));
} else {
#[cfg(not(target_vendor = "apple"))]
gl.BindVertexArrayOES(vertex_array.map(|va| va.0.get()).unwrap_or(0));
#[cfg(target_vendor = "apple")]
gl.BindVertexArrayAPPLE(vertex_array.map(|va| va.0.get()).unwrap_or(0));
}
}

Expand Down

0 comments on commit 0d1e3ac

Please sign in to comment.