I have the following code, I wanted to make a simple event to close the application but my keyboard function does not work, I looked elsewhere and I found similar versions. If you can help me, thank you.
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import OpenGL.GL
import sys, struct
def desenha():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glPointSize(5.0)
glBegin(GL_POINTS)
glColor3fv((0,1,0))
glVertex3f(0.0, 0.0, 0.0)
glColor3fv((1,0,1))
glVertex3f(0.0, 0.1, 0.0)
glColor3fv((1,0,1))
glVertex3f(0.1, 0.0, 0.0)
glColor3fv((1,0,1))
glVertex3f(0.0, -0.1, 0.0)
glColor3fv((1,0,1))
glVertex3f(-0.1, 0.0, 0.0)
glEnd()
glutSwapBuffers()
def keyboard(key, x, y):
if key == chr(97):
sys.exit(0)
return 0
def main():
glutInit([])
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB| GLUT_DEPTH | GLUT_ALPHA)
#glutInitWindowSize(400,400)
glutCreateWindow(b'This is my title')
glutInitWindowPosition(100, 100)
glutDisplayFunc(desenha)
glutKeyboardFunc(keyboard)
glutCreateMenu(nome)
glutMainLoop()
main()