PyOpenGL - Python Wiki

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

GLUT import * # The display() method does all the work; it has to call the appropriate # OpenGL functions to actually display something. def ... Search: PyOpenGL PyOpenGL FrontPageRecentChangesFindPageHelpContentsPyOpenGL Page ImmutablePageCommentsInfoAttachments MoreActions: RawText PrintView DeleteCache ------------------------ CheckSpelling LikePages LocalSiteMap ------------------------ RenamePage DeletePage ------------------------ ------------------------ RemoveSpam Reverttothisrevision ------------------------ SlideShow User Login PyOpenGL PyOpenGLisalargePythonpackagethatwrapsmost(uptoversion1.2)oftheOpenGLAPI.However,itdoesn'ttrytocleanuptheAPIandpresentamorePythonicinterface,soitwon'tsaveyou(or,moreimportantly,me)fromhavingtolearnthedetailsofOpenGL.ItdoesabstracttheAPIsoyoucallglColorinplaceofglColor3b,glColor3d,glColor3f,glColor3i,glColor3s,...Here'stheskeletonforaprogramthatdisplayssomething::importsys fromOpenGL.GLimport* fromOpenGL.GLUimport* fromOpenGL.GLUTimport* #Thedisplay()methoddoesallthework;ithastocalltheappropriate #OpenGLfunctionstoactuallydisplaysomething. defdisplay(): #Clearthecoloranddepthbuffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #...renderstuffinhere... #Itwillgotoanoff-screenframebuffer. #Copytheoff-screenbuffertothescreen. glutSwapBuffers() glutInit(sys.argv) #Createadouble-bufferRGBAwindow.(Single-bufferingispossible. #Soiscreatinganindex-modewindow.) glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH) #Createawindow,settingitstitle glutCreateWindow('interactive') #Setthedisplaycallback.Youcansetothercallbacksforkeyboardand #mouseevents. glutDisplayFunc(display) #RuntheGLUTmainloopuntiltheuserclosesthewindow. glutMainLoop()PyOpenGL(lastedited2008-11-1514:01:06bylocalhost) MoinMoinPoweredPythonPoweredGPLlicensedValidHTML4.01 Unabletoeditthepage?SeetheFrontPageforinstructions.



請為這篇文章評分?