Batches with GL_LINE_STRIP

416 views
Skip to first unread message

Leonardo Santagada

unread,
Mar 31, 2009, 10:43:08 AM3/31/09
to pyglet-users
I tried creating a batch to draw many lines at the same time, but even
with the idea of creating degenerate polygons (in this case lines) the
lines are still connected between them. Is there something speciall
about them or not?

the code I'm using is more or less:

bpoints = [x1, y1, x2, y2, x3, y3]
points = bpoints[0:2] + bpoints + bpoints[-2:]
size = len(points)/2
r, g, b = COLOR[edge.color]
pyglet.graphics.vertex_list(size,
('v2f/static', points),
('c4B/statoc', [r, g, b, 255] * size)))

of course before I was adding them to a batch and not creating a
vertex_list.

Tristam MacDonald

unread,
Mar 31, 2009, 11:06:55 AM3/31/09
to pyglet...@googlegroups.com
You can't batch line strips at all, unless your card supports one of the fence extensions, which lets you specify the end of a primitive list. I would suggest you just use GL_LINES - the duplicate vertices shouldn't hurt performance too much.
--
Tristam MacDonald
http://swiftcoder.wordpress.com/

Leonardo Santagada

unread,
Apr 1, 2009, 10:05:34 AM4/1/09
to pyglet-users


On Mar 31, 12:06 pm, Tristam MacDonald <swiftco...@gmail.com> wrote:
> You can't batch line strips at all, unless your card supports one of the
> fence extensions, which lets you specify the end of a primitive list. I
> would suggest you just use GL_LINES - the duplicate vertices shouldn't hurt
> performance too much.

Thanks a lot, so there is an error on the docs at
http://www.pyglet.org/doc/api/pyglet.graphics-module.html when it is
talking about drawing modes you se this line:

"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:"

It should actually say GL_LINES right?

and then in the end:
"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."

There should be a GL_LINE_STRIP in there also.

Tristam MacDonald

unread,
Apr 1, 2009, 10:37:48 AM4/1/09
to pyglet...@googlegroups.com
On Wed, Apr 1, 2009 at 10:05 AM, Leonardo Santagada <sant...@gmail.com> wrote:
On Mar 31, 12:06 pm, Tristam MacDonald <swiftco...@gmail.com> wrote:
> You can't batch line strips at all, unless your card supports one of the
> fence extensions, which lets you specify the end of a primitive list. I
> would suggest you just use GL_LINES - the duplicate vertices shouldn't hurt
> performance too much.

Thanks a lot, so there is an error on the docs at
http://www.pyglet.org/doc/api/pyglet.graphics-module.html when it is
talking about drawing modes you se this line:

"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:"

It should actually say GL_LINES right?

GL_LINES doesn't need degenerate vertices, since each segment is independent of the preceeding segment - unfortunately, it also requires twice as many vertices as a strip. GL_LINE_STRIP doesn't work with degenerate vertices, only quad/triangle-strips. 

and then in the end:
"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."

There should be a GL_LINE_STRIP in there also.

Ja, I think so. However, I really don't know how widespread that extension is.
Reply all
Reply to author
Forward
0 new messages