Hey. Don't discount using simple GL_TRIANGLES. On first glance they seem inefficient, because you have to send n*3 vertices as opposed to (2 + n) for GL_TRIANGLE_STRIPs or FANs. However:
1) If you used *indexed* vertex lists, then my small scale personal experiments seem to show that they are not slower, despite you having to send more vertices to render the same thing. Graphics cards apparently notice when you use the same indexed vertex again, and re- use the old cached vertex calculation results, so sending the same vertex for several adjacent triangles doesn't actually seem to slow things down. In fact, on two of the five computers I have tried it on, it actually speeds things up. I am guessing those particular graphics cards are optimised for the case of GL_TRIANGLES because it is common. 2) You can easily draw several discontinuous shapes in a single GL_TRIANGLES primitive. This is not possible using GL_TRIANGLE_STRIPs or FANs. So you send fewer primitives. 3) GL_TRIANGLES require much less messing around preparing your data. You don't need to try and decompose all your polygons into an optimal number of STRIP or FAN primitives, which is a non-trivial exercise, even for simple convex polygons. No doubt there are tools out there that could do this sort of thing for you, but I prefer to KISS, and see no reason to add this extra wrinkle of complexity unless there was a compelling benefit, which I don't believe there is. I have no experience with trying to use GL_POLYGONS. That might be really viable and I'm sure other people can comment on their strengths and weaknesses. Also: I have seen very lacklustre performance using pyglet's vertex_list.draw() (identical to explicit glVertex() calls). I would highly recommend using batches instead, which are much faster, for reasons unknown to me. Maybe batches use VBOs under the covers, and vertex lists do not. I speculate. This whole topic has perplexed me, trying to figure out the optimal intended usage patterns for pyglet, and I'd love to hear other people's contributions and corrections to my opinions. Best, Jonathan On Nov 15, 10:32 am, vaibhav <[EMAIL PROTECTED]> wrote: > I am trying to draw two consecutive primitives (circles) in the same > batch and it says in the drawing modes section (below) that > gl_polygon, gl_line_loop or gl_triangle_fan cannot be used. so i was > wondering what winding could i use to draw a circle using one of these > - GL_LINE_STRIP, GL_TRIANGLE_STRIP or GL_QUAD_STRIP > > http://pyglet.org/doc/api/pyglet.graphics-module.html > -------- > Drawing modes > > Methods in this module that accept a mode parameter will accept any > value in the OpenGL drawing mode enumeration; for example, GL_POINTS, > GL_LINES, GL_TRIANGLES, etc. > > Because of the way the graphics API renders multiple primitives with > shared state, GL_POLYGON, GL_LINE_LOOP and GL_TRIANGLE_FAN cannot be > used --- the results are undefined. > > When using GL_LINE_STRIP, GL_TRIANGLE_STRIP or GL_QUAD_STRIP care must > be taken to insert degenrate vertices at the beginning and end of each > vertex list. For example, given the vertex list: > > A, B, C, D > > the correct vertex list to provide the vertex list is: > > A, A, B, C, D, D > > Alternatively, the NV_primitive_restart extension can be used if it is > present. This also permits use of GL_POLYGON, GL_LINE_LOOP and > GL_TRIANGLE_FAN. Unfortunatley the extension is not provided by older > video drivers, and requires indexed vertex lists. > > On Nov 14, 4:26 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote: > > > On Fri, Nov 14, 2008 at 3:59 PM, Vaibhav. bhawsar > > > <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > Since i cannot use GL_TRIANGLE_FAN or GL_POLYGON in > > > pyglet.graphics.vertex_list, what would be a good mode to use to draw > > > a circle? I am not sure what the winding might be to draw a circle if > > > i used a GL_TRIANGLE_STRIP > > > > thanks! > > > > -- > > > Vaibhav Bhawsar > > > You can pass any openGL mode you want to vertex_list.draw (or > > batch.add), so I don't understand why you can't use GL_POLYGON... > > >http://pyglet.org/doc/api/pyglet.graphics.vertexdomain.VertexList-cla... > > > Colin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
