Ir al contenido


Foto

problema en gráfico animado en python


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 robert01

robert01

    Advanced Member

  • Miembros
  • PipPipPip
  • 162 mensajes
  • LocationArgentina

Escrito 05 abril 2023 - 08:25


php
  1. import math
  2. from OpenGL.GL import *
  3. from OpenGL.GLUT import *
  4.  
  5. a = 50.0 # semi-eje mayor de la elipse
  6. b = 30.0 # semi-eje menor de la elipse
  7. r = 50.0 # radio de la circunferencia
  8.  
  9. circle_points = [] # buffer de puntos de la circunferencia
  10. ellipse_points = [] # buffer de puntos de la elipse
  11.  
  12. def deg_to_rad(degrees):
  13. return degrees * math.pi / 180.0
  14.  
  15. def draw_circle(theta):
  16. x = r * math.cos(theta)
  17. y = r * math.sin(theta)
  18. circle_points.append((x, y))
  19.  
  20. def draw_ellipse(theta):
  21. x = a * math.cos(theta)
  22. y = b * math.sin(theta)
  23. ellipse_points.append((x, y))
  24.  
  25. def draw_points():
  26. glColor3f(1.0, 0.0, 0.0) # rojo
  27. glPointSize(3.0)
  28. glBegin(GL_POINTS)
  29. for x, y in circle_points:
  30. glVertex2f(x, y)
  31. for x, y in ellipse_points:
  32. glVertex2f(x, y)
  33. glEnd()
  34.  
  35. def display():
  36. glClear(GL_COLOR_BUFFER_BIT)
  37. draw_points()
  38. glutSwapBuffers()
  39.  
  40. def update(value):
  41. theta = deg_to_rad(value)
  42. draw_circle(theta)
  43. draw_ellipse(theta)
  44. glutPostRedisplay()
  45. glutTimerFunc(50, update, value + 1)
  46.  
  47. def main():
  48. glutInit()
  49. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
  50. glutInitWindowSize(800, 800)
  51. glutCreateWindow(b"Elipse y Circunferencia")
  52. glClearColor(1.0, 1.0, 1.0, 0.0)
  53. glMatrixMode(GL_PROJECTION)
  54. glLoadIdentity()
  55. glOrtho(-2 * r, 2 * r, -2 * r, 2 * r, -1.0, 1.0)
  56. glutDisplayFunc(display)
  57. glutTimerFunc(50, update, 0)
  58. glutMainLoop()
  59.  
  60. if __name__ == '__main__':
  61. main()

Tengo un problema con el código. No se si es una librería desactualizada. No se si alguien puede ayudarme.

 

Saludos

 

Este es el mensaje de error.

 

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

 


  • 0




IP.Board spam blocked by CleanTalk.