diff options
Diffstat (limited to 'source/blender/python/generic/bgl.c')
-rw-r--r-- | source/blender/python/generic/bgl.c | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 474259fe0e3..730db73e685 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -27,10 +27,17 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/python/generic/bgl.c + * \ingroup pygen + */ + + /* This file is the 'bgl' module. * The BGL submodule "wraps" OpenGL functions and constants, * allowing script writers to make OpenGL calls in their Python scripts. */ +#include <Python.h> + #include "bgl.h" /*This must come first */ #include <GL/glew.h> #include "MEM_guardedalloc.h" @@ -38,7 +45,6 @@ #include "BLI_utildefines.h" - static char Method_Buffer_doc[] = "(type, dimensions, [template]) - Create a new Buffer object\n\n\ (type) - The format to store data in\n\ @@ -94,9 +100,9 @@ PyTypeObject BGL_bufferType = { ( printfunc ) 0, /*tp_print */ ( getattrfunc ) Buffer_getattr, /*tp_getattr */ ( setattrfunc ) 0, /*tp_setattr */ - 0, /*tp_compare */ + NULL, /*tp_compare */ ( reprfunc ) Buffer_repr, /*tp_repr */ - 0, /*tp_as_number */ + NULL, /*tp_as_number */ &Buffer_SeqMethods, /*tp_as_sequence */ }; @@ -126,16 +132,16 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ int BGL_typeSize(int type) { switch (type) { - case GL_BYTE: - return sizeof(char); - case GL_SHORT: - return sizeof(short); - case GL_INT: - return sizeof(int); - case GL_FLOAT: - return sizeof(float); - case GL_DOUBLE: - return sizeof(double); + case GL_BYTE: + return sizeof(char); + case GL_SHORT: + return sizeof(short); + case GL_INT: + return sizeof(int); + case GL_FLOAT: + return sizeof(float); + case GL_DOUBLE: + return sizeof(double); } return -1; } @@ -164,7 +170,8 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf if (initbuffer) { memcpy(buffer->buf.asvoid, initbuffer, length*size); - } else { + } + else { memset(buffer->buf.asvoid, 0, length*size); /* for (i= 0; i<length; i++) { @@ -274,7 +281,8 @@ static PyObject *Buffer_item(PyObject *self, int i) case GL_FLOAT: return PyFloat_FromDouble(buf->buf.asfloat[i]); case GL_DOUBLE: return Py_BuildValue("d", buf->buf.asdouble[i]); } - } else { + } + else { Buffer *newbuf; int j, length, size; @@ -285,7 +293,7 @@ static PyObject *Buffer_item(PyObject *self, int i) size= BGL_typeSize(buf->type); newbuf= (Buffer *) PyObject_NEW(Buffer, &BGL_bufferType); - + Py_INCREF(self); newbuf->parent= self; @@ -299,7 +307,7 @@ static PyObject *Buffer_item(PyObject *self, int i) return (PyObject *) newbuf; } - + return NULL; } @@ -344,17 +352,21 @@ static int Buffer_ass_item(PyObject *self, int i, PyObject *v) if (buf->type==GL_BYTE) { if (!PyArg_Parse(v, "b:Coordinates must be ints", &buf->buf.asbyte[i])) return -1; - } else if (buf->type==GL_SHORT) { + } + else if (buf->type==GL_SHORT) { if (!PyArg_Parse(v, "h:Coordinates must be ints", &buf->buf.asshort[i])) return -1; - } else if (buf->type==GL_INT) { + } + else if (buf->type==GL_INT) { if (!PyArg_Parse(v, "i:Coordinates must be ints", &buf->buf.asint[i])) return -1; - } else if (buf->type==GL_FLOAT) { + } + else if (buf->type==GL_FLOAT) { if (!PyArg_Parse(v, "f:Coordinates must be floats", &buf->buf.asfloat[i])) return -1; - } else if (buf->type==GL_DOUBLE) { + } + else if (buf->type==GL_DOUBLE) { if (!PyArg_Parse(v, "d:Coordinates must be floats", &buf->buf.asdouble[i])) return -1; } @@ -423,7 +435,7 @@ static PyObject *Buffer_dimensions(PyObject *self) Buffer *buffer= (Buffer *) self; PyObject *list= PyList_New(buffer->ndimensions); int i; - + for (i= 0; i<buffer->ndimensions; i++) { PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i])); } @@ -792,7 +804,7 @@ BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdo * {"glAccum", Method_Accumfunc, METH_VARARGS} */ static struct PyMethodDef BGL_methods[] = { - {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc}, + {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc}, /* #ifndef __APPLE__ */ MethodDef(Accum), @@ -1124,13 +1136,13 @@ static struct PyMethodDef BGL_methods[] = { static struct PyModuleDef BGL_module_def = { PyModuleDef_HEAD_INIT, "bgl", /* m_name */ - 0, /* m_doc */ + NULL, /* m_doc */ 0, /* m_size */ BGL_methods, /* m_methods */ - 0, /* m_reload */ - 0, /* m_traverse */ - 0, /* m_clear */ - 0, /* m_free */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ }; @@ -1629,7 +1641,7 @@ PyObject *BPyInit_bgl(void) EXPP_ADDCONST(GL_TEXTURE_RESIDENT); EXPP_ADDCONST(GL_TEXTURE_BINDING_1D); EXPP_ADDCONST(GL_TEXTURE_BINDING_2D); - + return submodule; } |