On 17/03/2007, at 7:00 AM, Nyad wrote:
> > I am an opengl user. I recently considered designing a 3d engine in > python using opengl and ctypes. I didn't get too far because the jump > from ctypes to the api is rather slow using: > > from ctypes import * > windll.opengl32.glColor3f(c_float(1),c_float(1),c_float(1)) We use the argtypes and restypes attributes to get ctypes to convert (and check) types for us: gl = windll.opengl32 gl.glColor3f.argtypes = [c_float, c_float, c_float] gl.glColor3f(1, 1, 1) > This is just an example. I wrote a program in assembler that does all > the drawing code. > Then I called the dll file with ctypes but it didn't run too > spectacularly. Just acceptably. > My code was not written badly. It was ctypes fault. > But if you guys have some other way that works faster then I am > interested. > I know an average amount of opengl and am also a previous pygame user > until I moved to assembler. I have trudged through five languages in > order to discover > what I need to make a 3d engine. So far python and assembler have been > the most promising. > I dislike C++. The apps are too large. > I like it small. > I believe that it is possible to write a fast engine in python. Mainly > because the graphics api > does all the drawing work and not python. I use pygame for windowing > and event management. > It seems to excel in those arreas. You are essentially limited by Python's function call speed; by my benchmarks around 100x slower than an equivalent call in C, and a ctypes function call is around 50% slower again. In order to take advantage of GL CPU offloading, you need to use as few function calls as possible; make heavy use of vertex arrays, vertex buffers, display lists, and so on. If you're in the position of being able to write your own graphics API, you should architect the calls in a similar way. Cheers Alex. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
