Successfully reported this slideshow.
Casing3D         3                	      pyopengl	  qtopengl   	  
 •    casing3D                        	  •    Opengl     	  •    Opengl                   	  •    Qtopengl          	  •  ...
 
OpenGL   	  •  OpenGL                       	  •      api                                    	  •             	  •  GLUT  ...
OpenGL s	  State	  Machine	  •  All	  rendering	  a<ributes	  are	  encapsulated	  in	     the	  OpenGL	  State	     –  re...
Manipula?ng	  OpenGL	  State	  •  Appearance	  is	  controlled	  by	  current	  state	      	  	  	  for	  each	  (	  prim...
Controlling	  current	  state	  •  SeKng	  State	         glPointSize( size );       glLineStipple( repeat, pattern );    ...
Camera	  Analogy	  •  3D	  is	  just	  like	  taking	  a	  photograph	  (lots	  of	     photographs!)	                    ...
Camera	  Analogy	  and	  Transforma?ons	  •  Projec?on	  transforma?ons	     –  adjust	  the	  lens	  of	  the	  camera	  ...
Transforma?on	                               Poly.	                                                                  Per	 ...
Projec?on	  Tutorial	                              11	  
Opengl   	  
From the 1994 OpenGL 1.1 Data Flow…                                                                                       ...
…OpenGL 1.0 in detail                                                                        	  primi?ve	  topology,	     ...
…to the 2009 OpenGL 3.2 Data Flow                                                                                         ...
Patch	       Control	  point	                                                                           Patch	  tessella?o...
Buffer Centric View of OpenGL        Array	  Element	                      glBegin,	  glDrawElements,	  etc.	          Buff...
pyopengl	  
GLUT	  Basics	  •  Applica?on	  Structure	     –  Configure	  and	  open	  window	     –  Ini?alize	  OpenGL	  state	     –...
Hello,	  World	  from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *glutInit("Hello, World")glutInitD...
OpenGL	  Geometric	  Primi?ves	  •  All	  geometric	  primi?ves	  are	  specified	  by	     ver?ces	               GL_LINES...
Shapes	  Tutorial	                           22	  
Qtopengl	  from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *class Casing3DApp(QtGui.QWidget):class ...
 
Upcoming SlideShare
Loading in …5
×

Casing3d opengl

537 views

Published on

python opengl 套管3维成像系统

  • Be the first to comment

  • Be the first to like this

Casing3d opengl

  1. 1. Casing3D 3   pyopengl  qtopengl  
  2. 2.  •  casing3D  •  Opengl  •  Opengl  •  Qtopengl  •  casing3D  
  3. 3.  
  4. 4. OpenGL  •  OpenGL  •  api  •   •  GLUT  •   •   
  5. 5. OpenGL s  State  Machine  •  All  rendering  a<ributes  are  encapsulated  in   the  OpenGL  State   –  rendering  styles   –  shading   –  ligh?ng   –  texture  mapping   5  
  6. 6. Manipula?ng  OpenGL  State  •  Appearance  is  controlled  by  current  state        for  each  (  primi?ve  to  render  )  {        update  OpenGL  state        render  primi?ve        }  •  Manipula?ng  vertex  a<ributes  is  most        common  way  to  manipulate  state   glColor*() / glIndex*() glNormal*() glTexCoord*() 6  
  7. 7. Controlling  current  state  •  SeKng  State   glPointSize( size ); glLineStipple( repeat, pattern ); glShadeModel( GL_SMOOTH );•  Enabling  Features   glEnable( GL_LIGHTING ); glDisable( GL_TEXTURE_2D ); 7  
  8. 8. Camera  Analogy  •  3D  is  just  like  taking  a  photograph  (lots  of   photographs!)   viewing   volume   camera   tripod   model   8  
  9. 9. Camera  Analogy  and  Transforma?ons  •  Projec?on  transforma?ons   –  adjust  the  lens  of  the  camera  •  Viewing  transforma?ons   –  tripod–define  posi?on  and  orienta?on  of  the   viewing  volume  in  the  world  •  Modeling  transforma?ons   –  moving  the  model  •  Viewport  transforma?ons   –  enlarge  or  reduce  the  physical  photograph   9  
  10. 10. Transforma?on   Poly.   Per   Vertex  Pipeline   CPU   DL   Pixel   Texture   Raster   Frag   FB   object eye clip normalized window devicever Modelview Projection Perspective Viewportte Matrix Matrix Division Transformx Modelview Projection •  other  calcula?ons  here   –  material  è  color   Modelview –  shade  model  (flat)   –  polygon  rendering  mode   l l –  polygon  culling   l –  clipping   10  
  11. 11. Projec?on  Tutorial   11  
  12. 12. Opengl  
  13. 13. From the 1994 OpenGL 1.1 Data Flow…   storage   selec<on  /  feedback  /  transform  feedback   access   opera<ons   rasteriza?on   vertex   vertex   &  fragment   blending   puller   processing   depth  tes<ng   coloring   stencil  tes<ng   accumula<on   glDrawElements   glVertex*   glDrawArrays   glColor*   glTexCoord*   etc.     client   raster   texture   framebuffer   memory   opera?ons   glTex{Sub}Image   glDrawPixels glCopyTex{Sub}Image   glBitmap glCopyPixels pixel   unpack   pixel   transfer   pixel   glReadPixels / glCopyPixels / glCopyTex{Sub}Image pack  
  14. 14. …OpenGL 1.0 in detail  primi?ve  topology,   transformed   Legend   vertex  data   Geometric  primi?ve   Vertex   Vertex   assembly  &   ver?ces   assembly   primi?ve   processing   batch   processing   programmable   opera?ons   pixels   type,   vertex  data   fragments     point,  line,   and  polygon   fixed-­‐func?on   filtered  texels   fragments   opera?ons   buffer  data   stenciling,  depth  tes?ng,  primi?ve  batch  type,   blending,  accumula?on  vertex  a<ributes   Texture   Fragment   Raster   Framebuffer   mapping   fragment   processing   opera?ons     texture   Command   fetches   parser   pixel   image     image  and  bitmap   texture   fragments   image   pixel  image  or   specifica?on   texture  image   Pixel   specifica?on   packing   pixels  to  pack   image   rectangles,   bitmaps   Image   Pixel   Pixel   primi?ve   unpacking   unpacked   processing   pixels   processing   copy  pixels,   copy  texture  image  
  15. 15. …to the 2009 OpenGL 3.2 Data Flow uniform/    primi?ve  topology,   parameters   transformed   buffer  objects   Legend   vertex  data   Geometric  primi?ve   Vertex   Vertex   assembly  &   ver?ces   assembly   primi?ve   processing   batch   processing   programmable   transformed   opera?ons   pixels   type,   vertex   vertex  data   a<ributes   fragments   point,  line,   and  polygon   fixed-­‐func?on   filtered  texels   geometry   fragments   opera?ons   Transform   texture   buffer  data   vertex   fetches   buffer   transform   feedback   objects   feedback   buffer   pixels  in  framebuffer  object  textures   objects   stenciling,  depth  tes?ng,   primi?ve  batch  type,   vertex   texture   blending,  accumula?on   vertex  indices,   vertex  a<ributes   texture   fetches   buffer   buffer  data,   objects   Texture   Fragment   Raster   unmap   Framebuffer   mapping   fragment   processing   opera?ons   buffer   texture   Command   Buffer   fetches   parser   store   pixel   map  buffer,   pack   get  buffer   buffer   data   objects   texture   image  and  bitmap     fragments   pixel   image   pixel  image  or   unpack   specifica?on   texture  image   buffer   Pixel   specifica?on   objects   packing   pixels  to  pack   image   rectangles,   bitmaps   Image   Pixel   Pixel   primi?ve   unpacking   unpacked   processing   pixels   processing   copy  pixels,   copy  texture  image  Buffer  cache  
  16. 16. Patch   Control  point   Patch  tessella?on   Patch  evalua?on   assembly  &   processing   transformed   transformed   genera?on   transformed   processing   control  points   processing   patch   transformed   patch,  bivariate   patch  control   patch   domain  tessella?on    patch  topology,  evaluated  patch  vertex  texture   points  fetches    primi?ve  topology,   transformed   Legend   Vertex   Vertex   vertex  data   Geometric  primi?ve   assembly  &   patch  data   assembly   primi?ve   processing   batch   transformed   processing   programmable   ver?ces   opera?ons   type,   vertex   pixels   vertex  data   a<ributes   point,  line,   fragments   and  polygon   fixed-­‐func?on   geometry   filtered  texels   fragments   opera?ons   vertex   Transform   texture   feedback   fetches   buffer  data   buffer   transform   objects   feedback   pixels  in  framebuffer  object  textures   buffer   objects   stenciling,  depth  tes?ng,   primi?ve  batch  type,   vertex   texture   blending,  accumula?on   vertex  indices,   vertex  a<ributes   texture   fetches   buffer   buffer  data,   objects   Texture   Fragment   Raster   unmap   Framebuffer   mapping   fragment   processing   opera?ons   buffer   pixel   texture   Command   Buffer   pack   fetches   parser   store   buffer   map  buffer,   get  buffer   objects   data   image  and  bitmap   texture   fragments     pixel   image   pixel  image  or   unpack   Pixel   specifica?on   texture  image   buffer   packing   specifica?on   objects   OpenGL  4   pixels  to  pack   image   rectangles,   bitmaps   Image   Pixel   Pixel   primi?ve   copy  pixels,   unpacking   unpacked   processing   processing   copy  texture  image   pixels  
  17. 17. Buffer Centric View of OpenGL Array  Element   glBegin,  glDrawElements,  etc.   Buffer  Object   Texture   (VeBO)   Buffer  Object   (TexBO)   Vertex  Array  Buffer   Vertex  Puller   Object  (VaBO)   texel  data   Transform   Feedback  Buffer   Vertex  Shading   Pixel  Unpack   (XBO)   Buffer  (PuBO)   vertex  data   Texturin g   Geometry   glDrawPixels,  glTexImage2D,  etc.   Parameter   Shading   Buffer  (PaBO)   glReadPixels,   Pixel  Pack   etc.   Fragment   Pixel   Buffer   Bindable   Shading   Pipeline   (PpBO)   Uniform   pixel  data   Buffer  (BUB)   parameter  data   (not  ARB  func<onality  yet)   Framebuffer  
  18. 18. pyopengl  
  19. 19. GLUT  Basics  •  Applica?on  Structure   –  Configure  and  open  window   –  Ini?alize  OpenGL  state   –  Register  input  callback  func?ons   •  render   •  resize   •  input:  keyboard,  mouse,  etc.   –  Enter  event  processing  loop   19  
  20. 20. Hello,  World  from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *glutInit("Hello, World")glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH)glutInitWindowSize(400,400)glutCreateWindow("Hello, World")glClearColor(0.,0.,0.,1.)glutSetDisplayFuncCallback(display)glutDisplayFunc()glutMainLoop() ©  2000  Richard  P.  Muller  
  21. 21. OpenGL  Geometric  Primi?ves  •  All  geometric  primi?ves  are  specified  by   ver?ces   GL_LINES GL_POLYGON GL_LINE_STRIP GL_LINE_LOOPGL_POINTS GL_TRIANGLES GL_QUADS GL_QUAD_STRIPGL_TRIANGLE_STRIP GL_TRIANGLE_FAN 21  
  22. 22. Shapes  Tutorial   22  
  23. 23. Qtopengl  from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *class Casing3DApp(QtGui.QWidget):class Casing3DGLWidget(QtOpenGL.QGLWidget): def initializeGL(self): def paintGL(self): def resizeGL(self, width, height): def mouseMoveEvent(self, event):
  24. 24.  

×