При выполнении не все строки печатаются в окне. Кроме того окно вылетает после glutSwapBuffers () в функции showScreen. Вот изображение: https://imgur.com/n0oBJx9
w, h, g = 1200, 900, 1
def plot(coordinates, stringa, g, Px, Px1):
x, y = coordinates
while Px >= Px1:
glBegin(GL_LINES)
if stringa[Px] == "A":
glVertex2f(x, y)
glVertex2f(x, y - g)
y -= g
elif stringa[Px] == "B":
glVertex2f(x, y)
glVertex2f(x + g, y)
x += g
elif stringa[Px] == "C":
glVertex2f(x, y)
glVertex2f(x, y + g)
y += g
elif stringa[Px] == "D":
glVertex2f(x, y)
glVertex2f(x - g, y)
x -= g
glEnd()
Px -= 1
def iterate():
glViewport(0, 0, 500, 500)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.0, 500, 0.0, 500, 0.0, 1.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
def showScreen(coordinates, stringa, g, Px, Px1):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
iterate()
glColor3f(1.0, 0.0, 3.0)
plot(coordinates, stringa, g, Px, Px1)
glutSwapBuffers()
time.sleep(5)
glutInit()
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE |GLUT_RGBA)
glutInitWindowSize(w, h)
window = glutCreateWindow("dragon curve in Opengl")
glutDisplayFunc(showScreen([300, 400], stringa, x, len(stringa)-1, 0))
glutIdleFunc(showScreen([300, 400], stringa, x, len(stringa)-1, 0))
end = time.perf_counter()
print(f'Terminated in {round(end - start, 2)} seconds')
glutMainLoop()
Я получаю эту ошибку в функции showScreen после glutSwapBuffers ()
freeglut (foo): Fatal error in program. NULL display callback not permitted in GLUT 3.0+ or freeglut 2.0.1+
Что означает и как эта ошибка это исправить?