Search code examples
windowspython-3.xopenglanacondaglut

How to install GLUT on Anaconda on Windows?


I'm trying to run a simple OpenGL code:

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

window = 0                                             # glut window number
width, height = 500, 400                               # window size

def draw():                                            # ondraw is called all the time
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
    glLoadIdentity()                                   # reset position

    # ToDo draw rectangle

    glutSwapBuffers()                                  # important for double buffering


# initialization
glutInit()                                             # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height)                      # set window size
glutInitWindowPosition(0, 0)                           # set window position
window = glutCreateWindow("noobtuts.com")              # create window with title
glutDisplayFunc(draw)                                  # set draw function callback
glutIdleFunc(draw)                                     # draw all the time
glutMainLoop()     

But everytime I try to execute it I get this error:

OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling

According to this question The problem is that the glut.dll and glut32.dll are not part of the PyOpenGL package. So I downloaded the dll files and copied them to C:/Windows/SysWOW64 and added that folder to PATH, but the error persists. In the same question reference above, one user also suggests coping the dll files to the Python OpenGL DLL folder.

Where can I find this folder in my Ananconda installation? Or where should I copy the dll files to make this work? Thanks


Solution

  • Rabbid76's response solved the problem:

    "When I installed OpenGL on my Windows system, I follow this instructions and downloaded the binaries (.whl) from here"