[Python] Opengl

Source: Internet
Author: User

PYOPENGL Installation

Package             Version
------------------- -------
NumPy
Pyopengl 3.1.0
Pyopengl-accelerate 3.1.0

Demo1

1 #-*-coding:utf-8-*-2  fromOpengl.glImport*3  fromOpengl.gluImport*4  fromOpengl.glutImport*5 6 7 definit ():8Glclearcolor (1, 1, 1, 1)9Gluortho2d (-1, 1,-1, 1)Ten  One  A deftriangle (): - glclear (gl_color_buffer_bit) -glcolor3f (1, 0, 0) the Glbegin (gl_triangles) -  -glcolor3f (1, 0, 0) -GLVERTEX2F (-1,-1) +  -glcolor3f (0, 1, 0) +GLVERTEX2F (1,-1) A  atglcolor3f (0, 0, 1) -glvertex2f (0, 1) -  - glend () - Glflush () -  in  - defMain (): to glutinit (SYS.ARGV) +Glutinitdisplaymode (Glut_single |Glut_rgb) -Glutinitwindowsize (800, 600) theGlutinitwindowposition (50, 50) *Glutcreatewindow ("Triangle") $ glutdisplayfunc (triangle)Panax Notoginseng Init () - Glutmainloop () the  +  A if __name__=='__main__': theMain ()

Demo2

#-*-coding:utf-8-*- fromOpengl.glImport* fromOpengl.gluImport* fromOpengl.glutImport*defDrawfunc ():#Clear the previous screenglclear (gl_color_buffer_bit) Glrotatef (0.01, 3, 2, 1)#(angle, x, Y, z)Glutwireteapot (0.5) Glutwirecube (0.5)    #Refresh DisplayGlflush ()#initializing OpenGL with glutGlutinit ()#display mode: Glut_single direct display without buffering | Glut_rgba with RGB (a non-alpha)Glutinitdisplaymode (Glut_single |Glut_rgba)#window position and size-generatedglutinitwindowposition (0, 0) glutinitwindowsize (400, 400) Wnd= Glutcreatewindow (b" First")#call function to draw an imageGlutdisplayfunc (Drawfunc) glutidlefunc (drawfunc)#Main LoopGlutmainloop ()

[Python] Opengl

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.