Page MenuHome
Paste P450

BGL address argument.
ArchivedPublic

Authored by Porteries Tristan (panzergame) on Mar 5 2017, 9:38 AM.
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 3ea1022..d222340 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -152,6 +152,26 @@
#define GLcharP_ref(number) &BGL_bufferType, &bgl_buffer##number
#define GLcharP_def(number) Buffer *bgl_buffer##number
+static int addr_converter(PyObject *pyobj, void **addr)
+{
+ if (PyObject_TypeCheck(pyobj, &BGL_bufferType)) {
+ *addr = ((Buffer *)pyobj)->buf.asvoid;
+ return true;
+ }
+ else if (PyLong_Check(pyobj)) {
+ *addr = (void *)PyLong_AsLong(pyobj);
+ return true;
+ }
+
+ PyErr_SetString(PyExc_TypeError, "buffer or integer excepted");
+ return false;
+}
+
+#define GLaddrP_str "O&"
+#define GLaddrP_var(num) bgl_var##num
+#define GLaddrP_ref(num) addr_converter, &bgl_var##num
+#define GLaddrP_def(num) void *GLaddrP_var(num)
+
#if 0
#define buffer_str "O!"
#define buffer_var(number) (bgl_buffer##number)->buf.asvoid
@@ -1340,7 +1360,7 @@ BGL_Wrap(Viewport, void, (GLint, GLint, GLsizei, GLsizei))
BGL_Wrap(AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP))
BGL_Wrap(ArrayElement, void, (GLint))
BGL_Wrap(BindTexture, void, (GLenum, GLuint))
-BGL_Wrap(ColorPointer, void, (GLint, GLenum, GLsizei, GLvoidP))
+BGL_Wrap(ColorPointer, void, (GLint, GLenum, GLsizei, GLaddrP))
BGL_Wrap(CopyTexImage1D, void, (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))
BGL_Wrap(CopyTexImage2D, void, (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))
BGL_Wrap(CopyTexSubImage1D, void, (GLenum, GLint, GLint, GLint, GLint, GLsizei))
@@ -1348,30 +1368,30 @@ BGL_Wrap(CopyTexSubImage2D, void, (GLenum, GLint, GLint, GLint, GLi
BGL_Wrap(DeleteTextures, void, (GLsizei, GLuintP))
BGL_Wrap(DisableClientState, void, (GLenum))
BGL_Wrap(DrawArrays, void, (GLenum, GLint, GLsizei))
-BGL_Wrap(DrawElements, void, (GLenum, GLsizei, GLenum, GLvoidP))
-BGL_Wrap(EdgeFlagPointer, void, (GLsizei, GLvoidP))
+BGL_Wrap(DrawElements, void, (GLenum, GLsizei, GLenum, GLaddrP))
+BGL_Wrap(EdgeFlagPointer, void, (GLsizei, GLaddrP))
BGL_Wrap(EnableClientState, void, (GLenum))
BGL_Wrap(GenTextures, void, (GLsizei, GLuintP))
BGL_Wrap(GetPointerv, void, (GLenum, GLvoidP))
-BGL_Wrap(IndexPointer, void, (GLenum, GLsizei, GLvoidP))
+BGL_Wrap(IndexPointer, void, (GLenum, GLsizei, GLaddrP))
BGL_Wrap(Indexub, void, (GLubyte))
BGL_Wrap(Indexubv, void, (GLubyteP))
-BGL_Wrap(InterleavedArrays, void, (GLenum, GLsizei, GLvoidP))
+BGL_Wrap(InterleavedArrays, void, (GLenum, GLsizei, GLaddrP))
BGL_Wrap(IsTexture, GLboolean, (GLuint))
-BGL_Wrap(NormalPointer, void, (GLenum, GLsizei, GLvoidP))
+BGL_Wrap(NormalPointer, void, (GLenum, GLsizei, GLaddrP))
BGL_Wrap(PolygonOffset, void, (GLfloat, GLfloat))
BGL_Wrap(PopClientAttrib, void, (void))
BGL_Wrap(PrioritizeTextures, void, (GLsizei, GLuintP, GLfloatP))
BGL_Wrap(PushClientAttrib, void, (GLbitfield))
-BGL_Wrap(TexCoordPointer, void, (GLint, GLenum, GLsizei, GLvoidP))
+BGL_Wrap(TexCoordPointer, void, (GLint, GLenum, GLsizei, GLaddrP))
BGL_Wrap(TexSubImage1D, void, (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, GLvoidP))
BGL_Wrap(TexSubImage2D, void, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
-BGL_Wrap(VertexPointer, void, (GLint, GLenum, GLsizei, GLvoidP))
+BGL_Wrap(VertexPointer, void, (GLint, GLenum, GLsizei, GLaddrP))
/* GL_VERSION_1_2 */
BGL_Wrap(CopyTexSubImage3D, void, (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))
-BGL_Wrap(DrawRangeElements, void, (GLenum, GLuint, GLuint, GLsizei, GLenum, GLvoidP))
+BGL_Wrap(DrawRangeElements, void, (GLenum, GLuint, GLuint, GLsizei, GLenum, GLaddrP))
BGL_Wrap(TexImage3D, void, (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP))
BGL_Wrap(TexSubImage3D, void, (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
@@ -1477,7 +1497,7 @@ BGL_Wrap(GetShaderiv, void, (GLuint, GLenum, GLintP))
BGL_Wrap(GetUniformLocation, GLint, (GLuint, GLstring))
BGL_Wrap(GetUniformfv, void, (GLuint, GLint, GLfloatP))
BGL_Wrap(GetUniformiv, void, (GLuint, GLint, GLintP))
-BGL_Wrap(GetVertexAttribPointerv, void, (GLuint, GLenum, GLvoidP))
+BGL_Wrap(GetVertexAttribPointerv, void, (GLuint, GLenum, GLaddrP))
BGL_Wrap(GetVertexAttribdv, void, (GLuint, GLenum, GLdoubleP))
BGL_Wrap(GetVertexAttribfv, void, (GLuint, GLenum, GLfloatP))
BGL_Wrap(GetVertexAttribiv, void, (GLuint, GLenum, GLintP))
@@ -3685,4 +3705,4 @@ static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
}
-/** \} */
\ No newline at end of file
+/** \} */