SlideShare a Scribd company logo
1 of 24
Download to read offline
Casing3D         3                	
  

    pyopengl	
  qtopengl   	
  
 
•    casing3D                        	
  
•    Opengl     	
  
•    Opengl                   	
  
•    Qtopengl          	
  
•    casing3D                               	
  
 
OpenGL   	
  
•  OpenGL                       	
  
•      api                                    	
  
•             	
  
•  GLUT                                   	
  
• 
                         	
  
•                                      	
  
OpenGL s	
  State	
  Machine	
  
•  All	
  rendering	
  a<ributes	
  are	
  encapsulated	
  in	
  
   the	
  OpenGL	
  State	
  
   –  rendering	
  styles	
  
   –  shading	
  
   –  ligh?ng	
  
   –  texture	
  mapping	
  




                                                                    5	
  
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	
  
Controlling	
  current	
  state	
  
•  SeKng	
  State	
  
       glPointSize( size );
       glLineStipple( repeat, pattern );
       glShadeModel( GL_SMOOTH );
•  Enabling	
  Features	
  
       glEnable( GL_LIGHTING );
       glDisable( GL_TEXTURE_2D );




                                                7	
  
Camera	
  Analogy	
  
•  3D	
  is	
  just	
  like	
  taking	
  a	
  photograph	
  (lots	
  of	
  
   photographs!)	
  
                                          viewing	
  
                                          volume	
  

   camera	
  


     tripod	
                                    model	
  


                                                                              8	
  
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	
  
Transforma?on	
                               Poly.	
  
                                                                Per	
  
                                                               Vertex	
  



Pipeline	
                   CPU	
              DL	
  


                                              Pixel	
  
                                                               Texture	
  
                                                                               Raster	
     Frag	
     FB	
  




    object         eye                 clip                                 normalized                          window
                                                                              device
v
e
r      Modelview    Projection            Perspective                                 Viewport
t
e       Matrix       Matrix                Division                                   Transform
x

       Modelview     Projection
                                          •  other	
  calcula?ons	
  here	
  
                                                          –     material	
  è	
  color	
  
       Modelview                                          –     shade	
  model	
  (flat)	
  
                                                          –     polygon	
  rendering	
  mode	
  
             l
             l                                           –     polygon	
  culling	
  
             l                                           –     clipping	
  

                                                                                                                   10	
  
Projec?on	
  Tutorial	
  




                            11	
  
Opengl   	
  
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	
  
…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	
  
…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	
  
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	
  
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	
  
pyopengl	
  
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	
  
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	
  
OpenGL	
  Geometric	
  Primi?ves	
  
•  All	
  geometric	
  primi?ves	
  are	
  specified	
  by	
  
   ver?ces	
  

             GL_LINES
                                                           GL_POLYGON
                        GL_LINE_STRIP   GL_LINE_LOOP
GL_POINTS



                  GL_TRIANGLES

                                              GL_QUADS
                                                         GL_QUAD_STRIP
GL_TRIANGLE_STRIP          GL_TRIANGLE_FAN
                                                                  21	
  
Shapes	
  Tutorial	
  




                         22	
  
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):
 

More Related Content

Similar to Casing3d opengl

GLSL Shading with OpenSceneGraph
GLSL Shading with OpenSceneGraphGLSL Shading with OpenSceneGraph
GLSL Shading with OpenSceneGraphMike Weiblen
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open glArvind Devaraj
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL TransformationSandip Jadhav
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
Modern Graphics Pipeline Overview
Modern Graphics Pipeline OverviewModern Graphics Pipeline Overview
Modern Graphics Pipeline Overviewslantsixgames
 
GFX Part 5 - Introduction to Object Transformations in OpenGL ES
GFX Part 5 - Introduction to Object Transformations in OpenGL ESGFX Part 5 - Introduction to Object Transformations in OpenGL ES
GFX Part 5 - Introduction to Object Transformations in OpenGL ESPrabindh Sundareson
 
NIAR_VRC_2010
NIAR_VRC_2010NIAR_VRC_2010
NIAR_VRC_2010fftoledo
 
Designing Silverlight
Designing SilverlightDesigning Silverlight
Designing SilverlightReagan Hwang
 
Looking glassrenderinglt en
Looking glassrenderinglt enLooking glassrenderinglt en
Looking glassrenderinglt en優介 黒河
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Droidcon Berlin
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
Mixing Path Rendering and 3D
Mixing Path Rendering and 3DMixing Path Rendering and 3D
Mixing Path Rendering and 3DMark Kilgard
 
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and BeyondSIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and BeyondMark Kilgard
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012Mark Kilgard
 
NV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsNV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsMark Kilgard
 

Similar to Casing3d opengl (20)

Apache Helix presentation at Vmware
Apache Helix presentation at VmwareApache Helix presentation at Vmware
Apache Helix presentation at Vmware
 
Chapter-3.pdf
Chapter-3.pdfChapter-3.pdf
Chapter-3.pdf
 
OpenGL Interaction
OpenGL InteractionOpenGL Interaction
OpenGL Interaction
 
GLSL Shading with OpenSceneGraph
GLSL Shading with OpenSceneGraphGLSL Shading with OpenSceneGraph
GLSL Shading with OpenSceneGraph
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open gl
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Modern Graphics Pipeline Overview
Modern Graphics Pipeline OverviewModern Graphics Pipeline Overview
Modern Graphics Pipeline Overview
 
GFX Part 5 - Introduction to Object Transformations in OpenGL ES
GFX Part 5 - Introduction to Object Transformations in OpenGL ESGFX Part 5 - Introduction to Object Transformations in OpenGL ES
GFX Part 5 - Introduction to Object Transformations in OpenGL ES
 
NIAR_VRC_2010
NIAR_VRC_2010NIAR_VRC_2010
NIAR_VRC_2010
 
Designing Silverlight
Designing SilverlightDesigning Silverlight
Designing Silverlight
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
Looking glassrenderinglt en
Looking glassrenderinglt enLooking glassrenderinglt en
Looking glassrenderinglt en
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
Mixing Path Rendering and 3D
Mixing Path Rendering and 3DMixing Path Rendering and 3D
Mixing Path Rendering and 3D
 
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and BeyondSIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012
 
NV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsNV_path rendering Functional Improvements
NV_path rendering Functional Improvements
 
Clipping
ClippingClipping
Clipping
 

More from gowell

Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍gowell
 
Kernel init
Kernel initKernel init
Kernel initgowell
 
Logging develop
Logging developLogging develop
Logging developgowell
 
Logging introduce
Logging introduceLogging introduce
Logging introducegowell
 
Script meta
Script metaScript meta
Script metagowell
 
Script binding
Script bindingScript binding
Script bindinggowell
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率gowell
 
Pytables
PytablesPytables
Pytablesgowell
 
从动态说开去
从动态说开去从动态说开去
从动态说开去gowell
 

More from gowell (9)

Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍
 
Kernel init
Kernel initKernel init
Kernel init
 
Logging develop
Logging developLogging develop
Logging develop
 
Logging introduce
Logging introduceLogging introduce
Logging introduce
 
Script meta
Script metaScript meta
Script meta
 
Script binding
Script bindingScript binding
Script binding
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率
 
Pytables
PytablesPytables
Pytables
 
从动态说开去
从动态说开去从动态说开去
从动态说开去
 

Casing3d opengl

  • 1. Casing3D 3   pyopengl  qtopengl  
  • 2.   •  casing3D   •  Opengl   •  Opengl   •  Qtopengl   •  casing3D  
  • 3.  
  • 4. OpenGL   •  OpenGL   •  api   •    •  GLUT   •    •   
  • 5. OpenGL s  State  Machine   •  All  rendering  a<ributes  are  encapsulated  in   the  OpenGL  State   –  rendering  styles   –  shading   –  ligh?ng   –  texture  mapping   5  
  • 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. Controlling  current  state   •  SeKng  State   glPointSize( size ); glLineStipple( repeat, pattern ); glShadeModel( GL_SMOOTH ); •  Enabling  Features   glEnable( GL_LIGHTING ); glDisable( GL_TEXTURE_2D ); 7  
  • 8. Camera  Analogy   •  3D  is  just  like  taking  a  photograph  (lots  of   photographs!)   viewing   volume   camera   tripod   model   8  
  • 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. Transforma?on   Poly.   Per   Vertex   Pipeline   CPU   DL   Pixel   Texture   Raster   Frag   FB   object eye clip normalized window device v e r Modelview Projection Perspective Viewport t e Matrix Matrix Division Transform x Modelview Projection •  other  calcula?ons  here   –  material  è  color   Modelview –  shade  model  (flat)   –  polygon  rendering  mode   l l –  polygon  culling   l –  clipping   10  
  • 12. Opengl  
  • 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. …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. …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. 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. 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  
  • 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. 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. OpenGL  Geometric  Primi?ves   •  All  geometric  primi?ves  are  specified  by   ver?ces   GL_LINES GL_POLYGON GL_LINE_STRIP GL_LINE_LOOP GL_POINTS GL_TRIANGLES GL_QUADS GL_QUAD_STRIP GL_TRIANGLE_STRIP GL_TRIANGLE_FAN 21  
  • 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.