pyOpenGL GLUT window function doesn't close properly

文章推薦指數: 80 %
投票人數:10人

PyOpenGL uses freeglut. You have to give freeglut the chance to close the window. glutDestroyWindow does not destroy the window immediately, ... Lessthan10daystoRSVP!Virtuallyjoinusatourinauguralconference,everyoneiswelcome. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams pyOpenGLGLUTwindowfunctiondoesn'tcloseproperly AskQuestion Asked 1year,6monthsago Modified 1year,3monthsago Viewed 538times 2 ThisminimumworkingexampleofanenvironmentwithPyOpenGlandGLUTpresentsthesameissueIamhavingonbiggercode.Creating/closingcontinuouslyaninstanceofthisclass,increasesmemoryusageuntilallmymachinestartsslowingdown. WhatishappeningisthatthecalltoglutDestroyWindowhasnoteffectandtheprocess/usr/lib/xorg/XorgquicklyfillsupthewholeGPU. fromOpenGL.GLUTimport* DISPLAY_WIDTH,DISPLAY_HEIGHT=2000,2000 classTestEnv: def__init__(self): self.window=None glutInit(sys.argv) glutInitWindowSize(DISPLAY_WIDTH,DISPLAY_HEIGHT) self.window=glutCreateWindow(b"TestEnv") defclose(self): ifself.window: glutDestroyWindow(self.window) if__name__=="__main__": i=0 whileTrue: env=TestEnv() env.close() print(i) i+=1 Whatisthecorrectwayofreleasingallresources? pythonopenglglutpyopenglfreeglut Share Improvethisquestion Follow editedMar7,2021at10:03 Rabbid76 186k2525goldbadges107107silverbadges156156bronzebadges askedMar5,2021at3:23 DanieleDaniele 2122bronzebadges 1 Idon'tuseglut,butitlookslikeyouarefreeingthewindowinstance,butnotthememoryoccupiedbyglutInit(sys.argv)?MaybesurftheglutdocsfromsomekindofglutDone()? – MudkipHacker Mar5,2021at22:13 Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 0 PyOpenGLusesfreeglut.Youhavetogivefreeglutthechancetoclosethewindow.glutDestroyWindowdoesnotdestroythewindowimmediately,buttriggersaneventthatdestroysthewindow.Thereforyouhavetoruntheeventloop.InvokeglutMainLoopEventafterrequestingthewindowtobedestroyed: fromOpenGL.GLUTimport* DISPLAY_WIDTH,DISPLAY_HEIGHT=2000,2000 classTestEnv: def__init__(self): self.window=None glutInit(sys.argv) glutInitWindowSize(DISPLAY_WIDTH,DISPLAY_HEIGHT) self.window=glutCreateWindow(b"TestEnv") defclose(self): ifself.window: glutDestroyWindow(self.window) if__name__=="__main__": i=0 whileTrue: env=TestEnv() env.close() glutMainLoopEvent()#



請為這篇文章評分?