diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
commit | f5fc4ebdd8ede5263f4b34f161ebe139d40466dc (patch) | |
tree | 7122404f3410c14cd225343cfc97bc0a97441f1e /source/gameengine/VideoTexture | |
parent | d78eec93197cc1d3cc9da773ce30396891ec60f6 (diff) |
BGE Python API
- More verbose error messages.
- BL_Shader wasnt setting error messages on some errors
- FilterNormal depth attribute was checking for float which is bad because scripts often expect ints assigned to float attributes.
- Added a check to PyVecTo for a tuple rather then always using a generic python sequence. On my system this is over 2x faster with an optmized build.
Diffstat (limited to 'source/gameengine/VideoTexture')
-rw-r--r-- | source/gameengine/VideoTexture/FilterNormal.cpp | 21 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/blendVideoTex.cpp | 10 |
2 files changed, 18 insertions, 13 deletions
diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 03a79c1c8ce..a7266967efb 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -74,7 +74,7 @@ static int setColor (PyFilter * self, PyObject * value, void * closure) // check validity of parameter if (value == NULL || !PyInt_Check(value)) { - PyErr_SetString(PyExc_TypeError, "The value must be a int"); + PyErr_SetString(PyExc_TypeError, "filt.colorIdx = int: VideoTexture.FilterNormal, expected the value must be a int"); return -1; } // set color index @@ -94,15 +94,20 @@ static PyObject * getDepth (PyFilter * self, void * closure) static int setDepth (PyFilter * self, PyObject * value, void * closure) { // check validity of parameter - if (value == NULL || !PyFloat_Check(value)) + if (value) { - PyErr_SetString(PyExc_TypeError, "The value must be a float"); - return -1; + float depth= (float)PyFloat_AsDouble(value); + if ((depth==-1 && PyErr_Occurred()) == 0) /* no error converting to a float? */ + { + // set depth + getFilter(self)->setDepth(depth); + // success + return 0; + } } - // set depth - getFilter(self)->setDepth(float(PyFloat_AsDouble(value))); - // success - return 0; + + PyErr_SetString(PyExc_TypeError, "filt.depth = float: VideoTexture.FilterNormal, expected the value must be a float"); + return -1; } diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index ec066811a52..c11e7fffecd 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -1,6 +1,6 @@ /* $Id$ ----------------------------------------------------------------------------- -This source file is part of VideoTexure library +This source file is part of VideoTexture library Copyright (c) 2006 The Zdeno Ash Miklas @@ -49,14 +49,14 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args) char * matName; // get parameters - if (!PyArg_ParseTuple(args, "Os", &obj, &matName)) + if (!PyArg_ParseTuple(args, "Os:materialID", &obj, &matName)) return NULL; // get material id short matID = getMaterialID(obj, matName); // if material was not found, report errot if (matID < 0) { - PyErr_SetString(PyExc_RuntimeError, "object doesn't have material with given name"); + PyErr_SetString(PyExc_RuntimeError, "VideoTexture.materialID(ob, string): Object doesn't have material with given name"); return NULL; } // return material ID @@ -67,7 +67,7 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args) // get last error description static PyObject * getLastError (PyObject *self, PyObject *args) { - return Py_BuildValue("s", Exception::m_lastError.c_str()); + return PyString_FromString(Exception::m_lastError.c_str()); } // set log file @@ -89,7 +89,7 @@ static PyObject * imageToArray (PyObject * self, PyObject *args) if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type)) { // if object is incorect, report error - PyErr_SetString(PyExc_TypeError, "The value must be a image source object"); + PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object"); return NULL; } // get image structure |