I'm following this guide for my program activity
I installed pip install PyOpenGL PyOpenGL_accelerate , all good.
I tested the installation through the test code:
import OpenGL.GL import OpenGL.GLUT import OpenGL.GLU print("Imports successful!") # If you see this printed to the console then installation was successful
all good
I now run this script:
import OpenGL
import OpenGL.GL
import OpenGL.GLUT
import OpenGL.GLU
print("Imports successful!") # If you see this printed to the console then installation was successful
def showScreen():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Remove everything from screen (i.e. displays all white)
glutInit() # Initialize a glut instance which will allow us to customize our window
glutInitDisplayMode(GLUT_RGBA) # Set the display mode to be colored
glutInitWindowSize(500, 500) # Set the width and height of your window
glutInitWindowPosition(0, 0) # Set the position at which this windows should appear
wind = glutCreateWindow("OpenGL Coding Practice") # Give your window a title
glutDisplayFunc(showScreen) # Tell OpenGL to call the showScreen method continuously
glutIdleFunc(showScreen) # Draw any graphics or shapes in the showScreen function at all times
glutMainLoop() # Keeps the window created above displaying/running in a loop
I get This in my terminal:
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 16:30:00) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenGL
>>> import OpenGL.GL
>>> import OpenGL.GLUT
>>> import OpenGL.GLU
>>> print("Imports successful!") # If you see this printed to the console then installation was successful
Imports successful!
>>> def showScreen():
... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Remove everything from screen (i.e. displays all white)
...
>>> glutInit() # Initialize a glut instance which will allow us to customize our window
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutInit' is not defined
>>> glutInitDisplayMode(GLUT_RGBA) # Set the display mode to be colored
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutInitDisplayMode' is not defined
>>> glutInitWindowSize(500, 500) # Set the width and height of your window
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutInitWindowSize' is not defined
>>> glutInitWindowPosition(0, 0) # Set the position at which this windows should appear
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutInitWindowPosition' is not defined
>>> wind = glutCreateWindow("OpenGL Coding Practice") # Give your window a title
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutCreateWindow' is not defined
>>> glutDisplayFunc(showScreen) # Tell OpenGL to call the showScreen method continuously
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutDisplayFunc' is not defined
>>> glutIdleFunc(showScreen) # Draw any graphics or shapes in the showScreen function at all times
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutIdleFunc' is not defined
>>> glutMainLoop() # Keeps the window created above displaying/running in a loop
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'glutMainLoop' is not defined
I am using Visual Studio Code as my compiler
I followed the answer for this similar question but it led me to this error:
pip install PyOpenGL-3.1.5-cp39-cp39-win_amd64.whl
WARNING: Requirement 'PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl' looks like a filename, but the file does not exist
ERROR: PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl is not a valid wheel filename.
I have downloaded the stated .whl file