[Bf-blender-cvs] [49e0eff] temp_viewport_fx_merge: fix VAOs on Mac legacy context
Mike Erwin
noreply at git.blender.org
Thu Apr 2 02:29:17 CEST 2015
Commit: 49e0eff55d64a92039b74c6d979830b0b01c4e41
Author: Mike Erwin
Date: Wed Apr 1 20:13:45 2015 -0400
Branches: temp_viewport_fx_merge
https://developer.blender.org/rB49e0eff55d64a92039b74c6d979830b0b01c4e41
fix VAOs on Mac legacy context
Was causing crash on launch.
GLEW gives us glBindVertexArray and friends but sets them to NULL,
since Apple uses GL_APPLE_vertex_array_object instead of
GL_ARB_vertex_array_object. The ARB version evolved from the APPLE
version and they’re used in exactly the same way, so I aliased them to
keep our VAO code simple.
===================================================================
M source/blender/gpu/GPU_glew.h
===================================================================
diff --git a/source/blender/gpu/GPU_glew.h b/source/blender/gpu/GPU_glew.h
index 9421786..8196fec 100644
--- a/source/blender/gpu/GPU_glew.h
+++ b/source/blender/gpu/GPU_glew.h
@@ -34,4 +34,39 @@
#include "glew-mx.h"
+#ifdef __APPLE__
+/* Vertex Array Objects are part of OpenGL 3.0, or these extensions:
+ *
+ * GL_APPLE_vertex_array_object
+ * ^-- universally supported on Mac, widely supported on Linux (Mesa)
+ * GL_ARB_vertex_array_object
+ * ^-- widely supported on Windows & vendors' Linux drivers
+ *
+ * The ARB extension differs from the APPLE one in that client
+ * memory cannot be accessed through a non-zero vertex array object. It also
+ * differs in that vertex array objects are explicitly not sharable between
+ * contexts.
+ * (in other words, the ARB version of VAOs *must* use VBOs for vertex data)
+ *
+ * Called and used the exact same way, so alias to unify our VAO code.
+ *
+ * Not needed for GL >= 3.0
+ */
+
+# undef glIsVertexArray
+# define glIsVertexArray glIsVertexArrayAPPLE
+
+# undef glBindVertexArray
+# define glBindVertexArray glBindVertexArrayAPPLE
+
+# undef glGenVertexArrays
+# define glGenVertexArrays glGenVertexArraysAPPLE
+
+# undef glDeleteVertexArrays
+# define glDeleteVertexArrays glDeleteVertexArraysAPPLE
+
+/* TODO: a better workaround? */
+
+#endif /* __APPLE__ */
+
#endif /* __GPU_GLEW_H__ */
More information about the Bf-blender-cvs
mailing list