diff options
Diffstat (limited to 'source/gameengine/VideoTexture/blendVideoTex.cpp')
-rw-r--r-- | source/gameengine/VideoTexture/blendVideoTex.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index c11e7fffecd..1dcc72c8f7d 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -74,7 +74,7 @@ static PyObject * getLastError (PyObject *self, PyObject *args) static PyObject * setLogFile (PyObject *self, PyObject *args) { // get parameters - if (!PyArg_ParseTuple(args, "s", &Exception::m_logFile)) + if (!PyArg_ParseTuple(args, "s:setLogFile", &Exception::m_logFile)) return Py_BuildValue("i", -1); // log file was loaded return Py_BuildValue("i", 0); @@ -86,7 +86,7 @@ static PyObject * imageToArray (PyObject * self, PyObject *args) { // parameter is Image object PyObject * pyImg; - if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type)) + if (!PyArg_ParseTuple(args, "O:imageToArray", &pyImg) || !pyImageTypes.in(pyImg->ob_type)) { // if object is incorect, report error PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object"); @@ -159,8 +159,25 @@ static void registerAllTypes(void) pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24"); } + +#if (PY_VERSION_HEX >= 0x03000000) +static struct PyModuleDef VideoTexture_module_def = { + {}, /* m_base */ + "VideoTexture", /* m_name */ + "Module that allows to play video files on textures in GameBlender.", /* m_doc */ + 0, /* m_size */ + moduleMethods, /* m_methods */ + 0, /* m_reload */ + 0, /* m_traverse */ + 0, /* m_clear */ + 0, /* m_free */ +}; +#endif + PyObject* initVideoTexture(void) { + PyObject * m; + // initialize GL extensions //bgl::InitExtensions(0); @@ -175,9 +192,25 @@ PyObject* initVideoTexture(void) if (PyType_Ready(&TextureType) < 0) return NULL; - PyObject * m = Py_InitModule4("VideoTexture", moduleMethods, - "Module that allows to play video files on textures in GameBlender.", - (PyObject*)NULL,PYTHON_API_VERSION); + /* Use existing module where possible + * be careful not to init any runtime vars after this */ + m = PyImport_ImportModule( "VideoTexture" ); + if(m) { + Py_DECREF(m); + return m; + } + else { + PyErr_Clear(); + +#if (PY_VERSION_HEX >= 0x03000000) + m = PyModule_Create(&VideoTexture_module_def); +#else + m = Py_InitModule4("VideoTexture", moduleMethods, + "Module that allows to play video files on textures in GameBlender.", + (PyObject*)NULL,PYTHON_API_VERSION); +#endif + } + if (m == NULL) return NULL; @@ -187,9 +220,10 @@ PyObject* initVideoTexture(void) Py_INCREF(&TextureType); PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType); - + // init last error description Exception::m_lastError[0] = '\0'; + return m; } |