pyOpenGL GLUT window function doesn't close properly
文章推薦指數: 80 %
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()#
延伸文章資訊
- 1python-opengl/glut-quad-solid.py at master - GitHub
An open access book on Python, OpenGL and Scientific Visualization, Nicolas P. Rougier, 2018 - py...
- 2PyOpenGL:是一個呼叫OpenGL的2D/3D的python圖形庫
1 說明1.1 PyOpenGL:是一個呼叫OpenGL的2D/3D的python圖形庫。1.2 OpenGL:1.2.1 Open Graphics ... GLU import * #調出g...
- 3python 無法使用OpenGL問題error ... - iT 邦幫忙
python環境則是3.8.5 我做了以下的事情 pip install PyOpenGL pip install PyOpenGL_accelerate-3.1.5-cp38-cp38-win...
- 4Python GLUT.glutInit方法代碼示例- 純淨天空
本文整理匯總了Python中OpenGL.GLUT.glutInit方法的典型用法代碼示例。如果您正苦於以下問題:Python GLUT.glutInit方法的具體用法?Python GLUT....
- 5PyOpenGL · PyPI
GLUT (FreeGLUT). GLExtrusion library (libgle). GLU (normally available on any OpenGL-capable mach...