[Bf-committers] Pytho API access to an Image's bindcode

bf-committers@blender.org bf-committers@blender.org
Thu, 15 Jul 2004 14:17:25 -0400


This is a multi-part message in MIME format.

--Boundary_(ID_F3Nney2TRSpfTQ78a/eGEA)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

Attached is a patch to give access to an Image's bindcode through Python.

Motivation: We are writing a cel-shading plugin.  We are currently render the model using only 1D textures.  We would like to render another pass where 2D textures are already applied.  Currently an Image instance does not give access to the id that would be used when calling glBindTexture.  This will also allow others to use already loaded textures.

http://uniclipse.com/opensource/patchscreen.jpg
A screen shot of it in use.  On the left you can see the UV texture applied to Suzanne.  On the right, the texture is mapped to a quad using BGL. Note, we have not yet integrated 2D textures with the celshading plugin, this is just drawing a quad.

- Andrew Corrigan, Satish Goda,  Uniclipse

--Boundary_(ID_F3Nney2TRSpfTQ78a/eGEA)
Content-type: text/plain; NAME=patch.txt
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=patch.txt

? dlltool/python23.dll.def
? obj/windows
Index: source/blender/python/api2_2x/Image.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Image.c,v
retrieving revision 1.17
diff -u -r1.17 Image.c
--- source/blender/python/api2_2x/Image.c	6 Jun 2004 22:42:50 -0000	1.17
+++ source/blender/python/api2_2x/Image.c	15 Jul 2004 17:54:21 -0000
@@ -231,7 +231,8 @@
 static PyObject *Image_getSize(BPy_Image *self);
 static PyObject *Image_getDepth(BPy_Image *self);
 static PyObject *Image_getXRep(BPy_Image *self);
-static PyObject *Image_getYRep(BPy_Image *self);
+static PyObject *Image_getYRep(BPy_Image *self);
+static PyObject *Image_getBindCode(BPy_Image *self); 
 static PyObject *Image_setName(BPy_Image *self, PyObject *args);
 static PyObject *Image_setXRep(BPy_Image *self, PyObject *args);
 static PyObject *Image_setYRep(BPy_Image *self, PyObject *args);
@@ -253,7 +254,9 @@
 	{"getXRep", (PyCFunction)Image_getXRep, METH_NOARGS,
 					"() - Return Image object x repetition value"},
 	{"getYRep", (PyCFunction)Image_getYRep, METH_NOARGS,
-					"() - Return Image object y repetition value"},
+					"() - Return Image object y repetition value"},
+        {"getBindCode", (PyCFunction)Image_getBindCode, METH_NOARGS,
+					"() - Return Image object's bind code value"},                                
 	{"reload", (PyCFunction)Image_reload, METH_NOARGS,
 					"() - Reload the image from the filesystem"},
 	{"setName", (PyCFunction)Image_setName, METH_VARARGS,
@@ -427,13 +430,23 @@
 
 static PyObject *Image_getYRep(BPy_Image *self)
 {
-	PyObject *attr = PyInt_FromLong(self->image->yrep);
+	PyObject *attr = PyInt_FromLong(self->image->bindcode);
 
 	if (attr) return attr;
 
 	return EXPP_ReturnPyObjError (PyExc_RuntimeError,
 					"couldn't get Image.yrep attribute");
 }
+
+static PyObject *Image_getBindCode(BPy_Image *self)
+{
+	PyObject *attr = PyLong_FromUnsignedLong(self->image->bindcode);
+
+	if (attr) return attr;
+
+	return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+					"couldn't get Image.bindcode attribute");
+}
 
 static PyObject *Image_reload(BPy_Image *self)
 {
@@ -522,10 +535,11 @@
 		attr = PyInt_FromLong(self->image->xrep);
 	else if (strcmp(name, "yrep") == 0)
 		attr = PyInt_FromLong(self->image->yrep);
-
+	else if (strcmp(name, "bindcode") == 0)
+		attr = PyInt_FromLong(self->image->bindcode);
 	else if (strcmp(name, "__members__") == 0)
-		attr = Py_BuildValue("[s,s,s,s,s,s]",
-										"name", "filename", "size", "depth", "xrep", "yrep");
+		attr = Py_BuildValue("[s,s,s,s,s,s,s]",
+										"name", "filename", "size", "depth", "xrep", "yrep", "bindcode");
 
 	if (!attr)
 		return (EXPP_ReturnPyObjError (PyExc_MemoryError,

--Boundary_(ID_F3Nney2TRSpfTQ78a/eGEA)--