当前位置: 首页>>代码示例>>Python>>正文


Python GL.glViewport方法代码示例

本文整理汇总了Python中opengltk.OpenGL.GL.glViewport方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glViewport方法的具体用法?Python GL.glViewport怎么用?Python GL.glViewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opengltk.OpenGL.GL的用法示例。


在下文中一共展示了GL.glViewport方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reshape

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
 def reshape(self, w, h):
    GL.glViewport( 0, 0, w, h)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    if(w <= h):
       GLU.gluOrtho2D( 0.0, 30.0, 0.0, 30.0 * h/w)
    else:
       GLU.gluOrtho2D( 0.0, 30.0 * w/h, 0.0, 30.0)
    GL.glMatrixMode( GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:test_smooth.py

示例2: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
 def initProjection(self):
     if self.imarray is None:
         return
     self.tk.call(self._w, 'makecurrent')
     GL.glViewport(0, 0, self.width, self.height)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GL.glOrtho(0, float(self.width), 0, float(self.height), -1.0, 1.0)
     GL.glMatrixMode(GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:imageViewer.py

示例3: Configure

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
    def Configure(self, *dummy):
        """guillaume: set the opengl viewport"""
        # unbind <configure, because changing size of togl widget creates such
        # an event, hence causing an endless loop

        self.unbind('<Configure>')
        self.configure(width=self.width, height=self.height)
        self.bind('<Configure>', self.Configure)
        GL.glViewport(0, 0, self.width, self.height)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:MaterialEditor.py

示例4: reshape

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
 def reshape(self,  w, h):
        GL.glViewport( 0, 0, w, h)
        GL.glMatrixMode( GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glFrustum( -1.0, 1.0, -1.0, 1.0, 1.5, 20.0)
        GL.glMatrixMode( GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:8,代码来源:test_cube.py

示例5: reshape

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
    def reshape(self, w, h):
        GL.glViewport( 0, 0, w, h)
	self.setup_viewport()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:5,代码来源:test_dots.py

示例6: reshape

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
 def reshape(self, w, h):
     GL.glViewport( 0, 0, w, h)
     GL.glMatrixMode( GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GLU.gluOrtho2D( 0.0, w, 0.0, h)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:test_lines.py

示例7: endTile

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
   def endTile(self):
      assert(self.CurrentTile>=0)

      # be sure OpenGL rendering is finished
      GL.glFinish() #was glFlush()

      # save current glPixelStore values
      prevRowLength = GL.glGetIntegerv(GL.GL_PACK_ROW_LENGTH)[0]
      prevSkipRows = GL.glGetIntegerv(GL.GL_PACK_SKIP_ROWS)[0]
      prevSkipPixels = GL.glGetIntegerv(GL.GL_PACK_SKIP_PIXELS)[0]
      #prevAlignment = GL.glGetIntegerv(GL_PACK_ALIGNMENT)[0]

      if self.TileBuffer is not None:
         srcX = self.TileBorder
         srcY = self.TileBorder
         srcWidth = self.TileWidthNB
         srcHeight = self.TileHeightNB
         GL.glReadPixels(srcX, srcY, srcWidth, srcHeight,
                         self.TileFormat, self.TileType, self.TileBuffer)

      if self.ImageBuffer is not None:
         srcX = self.TileBorder
         srcY = self.TileBorder
         srcWidth = self.CurrentTileWidth - 2 * self.TileBorder
         srcHeight = self.CurrentTileHeight - 2 * self.TileBorder
         destX = self.TileWidthNB * self.CurrentColumn
         destY = self.TileHeightNB * self.CurrentRow

##          #save single tile
##          # setup pixel store for glReadPixels
##          GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, self.CurrentTileWidth)
##          GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, 0)
##          GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, 0)
##          #GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1)

##          # read the tile into buffer
##          gllib.glReadPixels(srcX, srcY, srcWidth, srcHeight,
##                             self.ImageFormat, self.ImageType, self.oneTileRenderBuffer)
##          import Image, sys
##          im = Image.fromstring('RGB', (srcWidth, srcHeight),
##                                self.oneTileRenderBuffer) 
##          if sys.platform!='win32':
##             im = im.transpose(Image.FLIP_TOP_BOTTOM)
##          im.save('tile%d_%d.tif'%(self.CurrentRow, self.CurrentColumn))
         
         # setup pixel store for glReadPixels
         GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, self.ImageWidth)
         GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, destY)
         GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, destX)
         #GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1)

         # read the tile into the final image
         #print 'DEBUG Tile renderer'
         #print 'column, row:', self.CurrentColumn, self.CurrentRow
         #print 'srcWidth,srcHeight,destX, destY',srcWidth,srcHeight,destX, destY
         gllib.glReadPixels(srcX, srcY, srcWidth, srcHeight,
                            self.ImageFormat, self.ImageType, self.ImageBuffer)

      # restore previous glPixelStore values
      GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, int(prevRowLength))
      GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, int(prevSkipRows))
      GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, int(prevSkipPixels))
      #GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, prevAlignment)

      # increment tile counter, return 1 if more tiles left to render
      self.CurrentTile+=1
      if self.CurrentTile >= self.Rows * self.Columns:
         # restore user's viewport
         GL.glViewport(int(self.ViewportSave[0]), int(self.ViewportSave[1]),
                       int(self.ViewportSave[2]), int(self.ViewportSave[3]))
         self.CurrentTile = -1  # all done
         return 0
      else:
         return 1
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:76,代码来源:tileRenderer.py

示例8: beginTile

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
   def beginTile(self):

      if self.CurrentTile <= 0:
         self.setup()
      # Save user's viewport, will be restored after last tile rendered
      self.ViewportSave = GL.glGetIntegerv(GL.GL_VIEWPORT)

      # which tile (by row and column) we're about to render
      if self.RowOrder==TR_BOTTOM_TO_TOP:
         self.CurrentRow = self.CurrentTile / self.Columns
         self.CurrentColumn = self.CurrentTile % self.Columns
      elif self.RowOrder==TR_TOP_TO_BOTTOM:
         self.CurrentRow = self.Rows - (self.CurrentTile / self.Columns) - 1
         self.CurrentColumn = self.CurrentTile % self.Columns
      else:
         raise RuntimeError

      assert(self.CurrentRow < self.Rows)
      assert(self.CurrentColumn < self.Columns)

      border = self.TileBorder

      # Compute actual size of this tile with border
      if self.CurrentRow < self.Rows-1:
         tileHeight = self.TileHeight
      else:
         tileHeight = self.ImageHeight - (self.Rows-1) * \
                      (self.TileHeightNB) + 2 * border

      if self.CurrentColumn < self.Columns-1:
         tileWidth = self.TileWidth
      else:
         tileWidth = self.ImageWidth - (self.Columns-1) * \
                     (self.TileWidthNB) + 2 * border

      # Save tile size, with border
      self.CurrentTileWidth = tileWidth
      self.CurrentTileHeight = tileHeight

      GL.glViewport(0, 0, tileWidth, tileHeight) #tile size including border

      # save current matrix mode
      matrixMode = GL.glGetIntegerv(GL.GL_MATRIX_MODE)[0]
      GL.glMatrixMode(GL.GL_PROJECTION)
      GL.glLoadIdentity()

      # compute projection parameters
      self.tileleft = left = self.Left + (self.Right - self.Left) \
                      * (self.CurrentColumn * self.TileWidthNB - border) \
                      / self.ImageWidth
      self.tileright = right = left + (self.Right - self.Left) * \
                       self.TileWidth / self.ImageWidth
      self.tilebottom = bottom = self.Bottom + (self.Top - self.Bottom) \
                        * (self.CurrentRow * self.TileHeightNB - border) / \
                        self.ImageHeight
      self.tiletop = top = bottom + (self.Top - self.Bottom) * self.TileHeight / \
                     self.ImageHeight

      if self.Perspective:
         GL.glFrustum(float(left), float(right),
                      float(bottom), float(top),
                      float(self.Near), float(self.Far))
      else:
         GL.glOrtho(float(left), float(right),
                    float(bottom), float(top),
                    float(self.Near), float(self.Far))

      # restore user's matrix mode
      GL.glMatrixMode(int(matrixMode))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:71,代码来源:tileRenderer.py

示例9: Configure

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glViewport [as 别名]
 def Configure(self, *dummy):
     """Cause the opengl widget to redraw itself."""
     #print 'Configure 0'
     width = self.winfo_width()
     height = self.winfo_height()
     GL.glViewport(0, 0, width, height)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:8,代码来源:test_togl.py


注:本文中的opengltk.OpenGL.GL.glViewport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。