I am trying to render a polygon using the GL_TRIANGLES mode for pyglet.graphics.draw but have been running into issues.
I have been attempting to render it like I've seen people do in many other places
def draw(self):
pyglet.graphics.draw(
size=int(len(self.coords) / 2),
mode=pyglet.gl.GL_TRIANGLES,
position=('v2f', self.coords),
)
but have been running into the following error:
File "C:\Python311\Lib\site-packages\pyglet\graphics\__init__.py", line 52, in draw
gl_type = vertexdomain._gl_types[fmt[0]]
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'v'
Did the usage change? Not sure exactly what I'm doing wrong here.
v2fis the old format specification. In Pyglet Version 2.0, this has changed. See the documentation ofdraw(size, mode, **data). The first parameter is the number of vertices and each vertex has to have 3 components. The format is justffor float. e.g.:Note that this will draw only black triangles. Set the
colorsattribute to draw a colorful shape.Minimal example: