Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorUlysse Martin <you.le@live.fr>2016-02-18 13:56:25 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2016-02-18 14:05:53 +0300
commit608ee3e0734cc307c282a49518c595c674bbb9f0 (patch)
tree899118179541db8ea68a3673c58624bc021f814c /source
parente24323ea4012482c4ede3b8ed3a80fe91f416e6e (diff)
BGE: Allow access to original texture openGL Bind code/Id/Number
This patch adds a python method to get openGL bind code of material's texture according to the texture slot. Example: import bge cont = bge.logic.getCurrentController() own = cont.owner bindId = own.meshes[0].materials[0].getTextureBindcode(0) Test file: http://www.pasteall.org/blend/40679 This can be used to play with texture in openGL, for example, remove mipmap on the texture or play with all wrapping or filtering options. And this can be used to learn openGL with Blender. Reviewers: TwisterGE, kupoman, moguri, panzergame Reviewed By: TwisterGE, kupoman, moguri, panzergame Projects: #game_engine Differential Revision: https://developer.blender.org/D1804
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp17
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index 1d185d52dc8..476fbd29b8b 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -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
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h
index df089cb7f99..a3d10c0a89d 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h
@@ -133,6 +133,7 @@ public:
KX_PYMETHOD_DOC(KX_BlenderMaterial, getMaterialIndex);
KX_PYMETHOD_DOC(KX_BlenderMaterial, getTexture);
KX_PYMETHOD_DOC(KX_BlenderMaterial, setTexture);
+ KX_PYMETHOD_DOC(KX_BlenderMaterial, getTextureBindcode);
KX_PYMETHOD_DOC(KX_BlenderMaterial, setBlending);
#endif /* WITH_PYTHON */