MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / main

Function main

pyPBD/examples/pendulum.py:82–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 buildModel()
81
82def main():
83 # Activate logger to output info on the console
84 pbd.Logger.addConsoleSink(pbd.LogLevel.INFO)
85
86 # init OpenGL
87 initGL(1280, 1024)
88 gluLookAt (0, -2, -10, 0, -2, 0, 0, 1, 0)
89
90 # build simulation model
91 buildModel()
92
93 # start event loop
94 running = True
95 while running:
96 for event in pygame.event.get():
97 if event.type == pygame.QUIT:
98 running = False
99 if event.type == pygame.KEYDOWN:
100 if event.key == pygame.K_r:
101 reset()
102 if event.key == pygame.K_ESCAPE:
103 running = False
104
105 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
106 glClearColor(0.3, 0.3, 0.3, 1.0)
107 timeStep()
108 render()
109 pygame.display.flip()
110 pygame.time.wait(5) # slow down simulation since it is too fast
111
112 pygame.quit()
113 pbd.Timing.printAverageTimes()
114
115if __name__ == "__main__":
116 main()

Callers 1

pendulum.pyFile · 0.70

Calls 7

initGLFunction · 0.85
printAverageTimesMethod · 0.80
buildModelFunction · 0.70
resetFunction · 0.70
timeStepFunction · 0.70
renderFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected