1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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() # start everything |
Error:Traceback (most recent call last):
File "graphic.py", line 47, in <module>
if __name__ == '__main__': main()
File "graphic.py", line 9, in main
glutInit(sys.argv)
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\GLUT\special.py", line 333, in glutInit
_base_glutInit( ctypes.byref(count), holder )
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\platform\baseplatform.py", line 407, in __ca
ll__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling
i copied and paste this from the internet to my project,so there should not be any error.I am only 15 years old,so please dont use too much hard to understand or mathematical term in the answer.
Why is no one answering me?