Skip to content
Advertisement

PyOpenGL, pygame, and errors when drawing a shape

I’ve been writing a custom snake game using python, pygame, and pyopengl. I’m trying to draw a shape on the screen. However, I’ve stumbled upon this error:

JavaScript

The console is throwing me a TypeError and an Attribute error. I’m not sure if this is due to my code or an issue with one of the libraries. I’m using Python 3.9.1, pygame 2.0.1, and PyOpenGL 3.1.5.

Here’s the snippet of my script where the issue arises:

JavaScript

Advertisement

Answer

The argument of glVertex2fv must be an array with 2 elements. If you have two separate coordinates which are not aggregated in an array you must use glVertex2f. See glVertex:

glVertex2fv(cosine, sine)

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement