Dummy vertex lists

38 views
Skip to first unread message

josch

unread,
Nov 4, 2008, 12:48:13 PM11/4/08
to pyglet-users
Hi!

I use a dynamic number of vertex lists to draw to my screen, because
depending on the map size different number of textures are required.
Hence I dynamically resize the vertex lists when moving around the map
according to what has to be drawn.
My problem: when there is no object of the group of one of the vertex
lists to be drawn in one scene then the size of the specific list
would be zero - which is not allowed.
So what can I do? I do not want to delete() and add() the vertex list
because of the overhead. Maybe I have to live with dummy vertices? And
how do i initialize such a list?

Alex Holkner

unread,
Nov 4, 2008, 4:42:27 PM11/4/08
to pyglet...@googlegroups.com

If your list is of triangles, three vertices with the same coordinate
will give a degenerate triangle -- one that is guaranteed not to
render. Similarly, use four of the same vertices for a quad, etc.

It should be pretty easy to add support for zero-length vertex lists;
I'll look into it for pyglet 1.2.

Alex.

josch

unread,
Nov 4, 2008, 6:06:56 PM11/4/08
to pyglet-users
yeah i did this already with a dummy GL_QUAD of zero size - but this
felt dirty.

would be nice to have zero sized vertex lists - especially when one
could invoke batch.add() with zero vertices so they are already in the
batch and bound to a group. when this is possible i will wait for this
feature.

On Nov 4, 10:42 pm, "Alex Holkner" <alex.holk...@gmail.com> wrote:

josch

unread,
Nov 5, 2008, 7:44:19 AM11/5/08
to pyglet-users
Okay forget about it :(

I now do a vertex_list.delete() when a list is no longer used and
Batch.add() when a new one is required.
Of course delete() and add() is much slower than resize() but on my
machine with limited vram it is even more costly to draw TextureGroups
that don't even show up anymore so overall i gain in speed by doing
this.

Alex Holkner

unread,
Nov 5, 2008, 7:48:29 AM11/5/08
to pyglet...@googlegroups.com

r2343 (trunk) adds support for zero-length vertex arrays. I'd
appreciate you testing this, as I don't have any good test cases since
nvidia's driver behaviour changed. You may need to disable audio for
everything to work in trunk at the moment (there are lots of known
issues).

Alex.

josch

unread,
Nov 5, 2008, 8:10:17 AM11/5/08
to pyglet-users
thank you very much! this works like a charm!

I can now batch.add() empty lists, I can resize empty lists to any
other value and I can resize normal vertex lists to zero!

But to get the code run on debian lenny+intel gfx here I had to add
the following patch:

Index: pyglet/gl/xlib.py
===================================================================
--- pyglet/gl/xlib.py (revision 2343)
+++ pyglet/gl/xlib.py (working copy)
@@ -15,6 +15,8 @@
from pyglet.gl import glx
from pyglet.gl import glxext_arb
from pyglet.gl import glx_info
+from pyglet.gl import glxext_mesa
+from pyglet.gl import glxext_arb

class XlibConfig(Config):
def match(self, canvas):
@@ -29,10 +31,7 @@
if have_13:
config_class = XlibCanvasConfig13
else:
- if 'ATI' in canvas.display.info.get_client_vendor():
- config_class = XlibCanvasConfig10ATI
- else:
- config_class = XlibCanvasConfig10
+ config_class = XlibCanvasConfig10

# Construct array of attributes
attrs = []
@@ -120,7 +119,7 @@
x_screen = canvas.display.x_screen

self._visual_info = glx.glXChooseVisual(
- x_display, x_screen_id, attrib_list)
+ x_display, x_screen, attrib_list)
if not self._visual_info:
raise gl.ContextException('No conforming visual exists')


I deleted canvas.display.info.get_client_vendor() because canvas was
None - this was also the reason for an error on exiting the program:

File "/home/josch/fheroes3/heroes rebirth/pyglet/gl/xlib.py", line
260, in set_current
glx.glXMakeCurrent(self.x_display, self.canvas.x_window,
AttributeError: 'NoneType' object has no attribute 'x_window'

Alex Holkner

unread,
Nov 5, 2008, 8:22:22 AM11/5/08
to pyglet...@googlegroups.com

Thanks; GLX 1.1 implementation is fixed now.

Alex.

Reply all
Reply to author
Forward
0 new messages