[visionegg] Re: Dropping into C
- From: Andrew Straw <astraw@xxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Fri, 27 Jan 2006 14:30:58 -0800
Hi Doug,
You'll want to use Python's distutils to build C extensions[1] to
Python. You can (and should) use distutils to compile extensions[2]. The
VE has examples of all this, and _draw_in_c.c gets compiled to the .so
via the setup.py script. Basically, a "python setup.py build_ext" will
build these C extensions. (This happens as a part of the "python
setup.py install" process.)
_draw_in_c.c is written in pure C, but if you find that tedious and
error-prone, I highly recommend Pyrex[3]. Pyrex is a very-Python-like
language for writing extension modules. Think Python-to-C compiler and
you'll be in the right ballpark. There are now some examples of Pyrex
use in the Vision Egg, and I plan on converting all the SWIG stuff to
Pyrex eventually -- when the occasion arises to mess with the SWIG
source code. At that point, I'll re-code it in Pyrex rather than deal
with SWIG anymore.
[1] http://www.python.org/doc/2.4.2/ext/ext.html
[2] http://www.python.org/doc/2.4.2/dist/describing-extensions.html
[3] http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Douglas Taylor wrote:
Hi Andrew,
I was trying to optimize the dot drawing routine
using the Vertex Array method
xy[:,0] = xstart #where xy is an [npoints][2] array
xy[:,1] = ystart
# Pass a pointer to the start of the point-coordinate array:
glVertexPointerd(xy);
# glVertexPointer(2, GL_DOUBLE, 0, xy); Python did not like
it this way
# Enable fast rendering of arrays:
glEnableClientState(GL_VERTEX_ARRAY);
# Render all n points, starting at point 0, render them as
POINTS:
glDrawArrays(GL_POINTS, 0, len(xstart));
# Disable fast rendering of arrays:
glDisableClientState(GL_VERTEX_ARRAY);
and on the Mac(10.3 and 10.4) I actually got worse performance than the
GL_POINTS loop method. So I would like to drop into C and I found
the _draw_in_c.c code which looks like a good place to start. I don't
understand however how you generated the .so file. I couldn't find
any examples on the Apple site either. I have XCODE and CodeWarrior.
Could you point me in the right direction here. Thanks much,
Doug
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- Follow-Ups:
- [visionegg] Re: Dropping into C
- From: Douglas Taylor
- References:
- [visionegg] Dropping into C
- From: Douglas Taylor
Other related posts:
- » [visionegg] Dropping into C
- » [visionegg] Re: Dropping into C
- » [visionegg] Re: Dropping into C
- » [visionegg] Re: Dropping into C
- » [visionegg] Re: Dropping into C
- » [visionegg] Re: Dropping into C
Hi Andrew,
I was trying to optimize the dot drawing routine using the Vertex Array method
xy[:,0] = xstart #where xy is an [npoints][2] array
xy[:,1] = ystart
# Pass a pointer to the start of the point-coordinate array:
glVertexPointerd(xy);
# glVertexPointer(2, GL_DOUBLE, 0, xy); Python did not like it this way
# Enable fast rendering of arrays:
glEnableClientState(GL_VERTEX_ARRAY);
# Render all n points, starting at point 0, render them as POINTS:
glDrawArrays(GL_POINTS, 0, len(xstart));
# Disable fast rendering of arrays:
glDisableClientState(GL_VERTEX_ARRAY);
and on the Mac(10.3 and 10.4) I actually got worse performance than the GL_POINTS loop method. So I would like to drop into C and I found the _draw_in_c.c code which looks like a good place to start. I don't understand however how you generated the .so file. I couldn't find any examples on the Apple site either. I have XCODE and CodeWarrior. Could you point me in the right direction here. Thanks much,
Doug
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] Re: Dropping into C
- From: Douglas Taylor
- [visionegg] Dropping into C
- From: Douglas Taylor