Hi, sorry if this is super newb - I used to code a lot but took a 15 year break.
I've got a "game" going with a bunch of vector-style graphics, not sprite based or anything else. Think square nodes connected by roads. So maybe about 100 square nodes and ~450 roads, and maybe 20 game pieces (more squares) sliding around on those nodes and roads. I was just doing everything in old fashioned gl calls, so to draw my map of nodes, I'm drawing unit squares after transforming the ctm to the location and size I want. def drawSquare(): glBegin(GL_QUADS) glVertex2f(-.5,-.5) glVertex2f(-.5, .5) ... etc. for node in nodes: glPushMatrix() glTranslatef(node.coords) glScalef(node.size) drawSquare() glPopMatrix() For the roads, I'm doing something similar: for road in roads: glPushMatrix() glTranslatef(road.center) glRotatef(road.angle) glScalef(road.length,road.width,1) drawSquare() glPopMatrix() I just recently read that throwing lots of polys into a batch is faster/more efficient, but I'm having a ~hard time figuring out what batch supports and what my workarounds are. First question: In the rough order of magnitude of what I'm drawing, does it even matter? I'm looking at - say, eventually I might want 200 nodes, 1000 roads, 100 moving pieces, I'm looking at a few thousand triangles. Is that going to be taking any appreciable time? Is there a lot of overhead for pushing and popping matrices (I'm looking at pushing and popping ~1500 times in this case)? Second: it looks like pyglet.graphics.batch only allows me to dump vertices on it, and I assume it's doing nothing smart to those vertices. Is that correct? e.g. if I want to put a square in a batch centered on (10,0,0), I can't glTranslate(10,0,0) and then batch.add a square centered on the origin; I need to batch.add vertices from (9.5,-.5) to (10.5,.5), correct? Third: if batch doesn't support transform matrices like I suspect... that means I have to be transforming all my points myself. Does pyglet include convenience functions for doing matrix math? e.g. multipling matrices together, multiplying lists of vertices or vectors my matrices, transposing/inverting matrices, etc.? If I have to code in a few thousand matrix translates and scales and multiplies with vertices just to put into batch, is that actually faster than letting gl do all the pushing/popping for me? Fourth: Should I be doing this another way? It's been a long time since I've coded anything at all. I know what I currently have definitely works; I'm just having a hard time looking at it and knowing if this is a "good" way to do it or if a real programmer would be shaking his head at the sheer idiocy... Thanks! -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyglet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
