BGE: Allow access to original texture openGL Bind code/Id/Number
[blender.git] / source / gameengine / Ketsji / KX_BlenderMaterial.cpp
index 1d185d52dc8c623cc533a26c09d56f8f307d73ff..476fbd29b8b96b5fcb2ec84d1ba2d9c6275c61d3 100644 (file)
@@ -972,6 +972,7 @@ PyMethodDef KX_BlenderMaterial::Methods[] =
 {
        KX_PYMETHODTABLE( KX_BlenderMaterial, getShader ),
        KX_PYMETHODTABLE( KX_BlenderMaterial, getMaterialIndex ),
+       KX_PYMETHODTABLE( KX_BlenderMaterial, getTextureBindcode ),
        KX_PYMETHODTABLE( KX_BlenderMaterial, setBlending ),
        {NULL,NULL} //Sentinel
 };
@@ -1325,4 +1326,20 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( bge.logic.sr
        return NULL;
 }
 
+KX_PYMETHODDEF_DOC(KX_BlenderMaterial, getTextureBindcode, "getTextureBindcode(texslot)")
+{
+       unsigned int texslot;
+       if (!PyArg_ParseTuple(args, "i:texslot", &texslot)) {
+               PyErr_SetString(PyExc_ValueError, "material.getTextureBindcode(texslot): KX_BlenderMaterial, expected an int.");
+               return NULL;
+       }
+       Image *ima = getImage(texslot);
+       if (ima) {
+               unsigned int *bindcode = ima->bindcode;
+               return PyLong_FromLong(*bindcode);
+       }
+       PyErr_SetString(PyExc_ValueError, "material.getTextureBindcode(texslot): KX_BlenderMaterial, invalid texture slot.");
+       return NULL;
+}
+
 #endif // WITH_PYTHON