hi all today i am trying to catch up with the newest pyglet API. It looks very nice although a bit weird at the first moment. I am working on this simple example where many instances of an object are rendered on random locs on screen. On my Desktop this takes almost 80% CPU, i am pretty sure i am doing something wrong because most of the CPU time is taken by the render method, (If I comment render() out it drops to 4% CPU).
any suggestions? I am on Debian, on a PIV at 1.7 gz . Below i paste the script i am working in. thanks! enrike from pyglet.gl import * import pyglet ##pyglet.options[ 'debug_gl' ] = False # increase performace when using opengl. disables error checking from random import Random seed = Random() width, height = 800,600 try: # Try and create a window with multisampling (antialiasing) config = Config(sample_buffers=1, samples=4, depth_size=16, double_buffer=True,) window = pyglet.window.Window(resizable=True, config=config) except pyglet.window.NoSuchConfigException: # Fall back to no multisampling for old hardware print "applying safe configuration" window = pyglet.window.Window(resizable=True) class Graph : def __init__( self, x, y ) : self.x = x self.y = y def render( self ) : glPushMatrix() glTranslatef( self.x, self.y, 0 ) # go to mouseloc glColor3f( 0.8,0,0) glRectf(-6, -6, 6, 6) ## glBegin( GL_QUADS ) ## glVertex3f( -6, 6, 0 ) #left top ## glVertex3f( 6, 6, 0 ) ## glVertex3f( 6, -6, 0 ) ## glVertex3f( -6, -6, 0 ) ## glEnd() glPopMatrix() def setup() : glClearColor(1, 1, 1, 1) glColor3f(1, 0, 0) glEnable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0, width, height, 0, 1, 0) glMatrixMode(GL_MODELVIEW) global stack stack = [] for o in xrange(500) : x = seed.random() * width y = seed.random() * height stack.append( Graph( x, y ) ) [EMAIL PROTECTED] def on_draw() : glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) for o in stack : o.render() window.on_draw = on_draw def update(dt) : for o in stack : o.x = seed.random() * width o.y = seed.random() * height setup() pyglet.clock.schedule_interval(update, 1./12) pyglet.app.run() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to pyglet-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---