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


Python gl.glOrtho函数代码示例

本文整理汇总了Python中pyglet.gl.glOrtho函数的典型用法代码示例。如果您正苦于以下问题:Python glOrtho函数的具体用法?Python glOrtho怎么用?Python glOrtho使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: set_viewport

def set_viewport(left, right, bottom, top):
    """
    This sets what coordinates appear on the window.

    Note: It is recommended to only set the viewport to integer values that
    line up with the pixels on the screen. Otherwise if making a tiled game
    the blocks may not line up well, creating rectangle artifacts.

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> set_viewport(-1, 1, -1, 1)
    >>> arcade.quick_run(0.25)

    """
    global _left
    global _right
    global _bottom
    global _top

    _left = left
    _right = right
    _bottom = bottom
    _top = top

    # GL.glViewport(0, 0, _window.height, _window.height)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    GL.glOrtho(_left, _right, _bottom, _top, -1, 1)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glLoadIdentity()
开发者ID:mwreuter,项目名称:arcade,代码行数:30,代码来源:window_commands.py

示例2: on_resize

def on_resize(width, height):
    gl.glViewport(0, 0, width, height)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.glOrtho(-width/2, width/2, -height/2, height/2, -1, 1)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    return EVENT_HANDLED
开发者ID:adam-urbanczyk,项目名称:chemshapes,代码行数:7,代码来源:demo.py

示例3: on_resize

    def on_resize(self, width, height):
        """Calculate the new viewport preserving aspect ratio"""

        aspect = float(WIDTH)/HEIGHT

        self.viewport_width = int(min(width, height*aspect))
        self.viewport_height = int(min(height, width/aspect))
        self.viewport_x_offs = (width-self.viewport_width) // 2
        self.viewport_y_offs = (height-self.viewport_height) // 2

        x = (width-WIDTH) / 2
        gl.glViewport(self.viewport_x_offs,
                      self.viewport_y_offs,
                      self.viewport_width,
                      self.viewport_height,
                      )
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, self.viewport_width, 0, self.viewport_height, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        logging.debug("Viewport: %s, %s, %s, %s" % (self.viewport_x_offs,
                                                    self.viewport_y_offs,
                                                    self.viewport_width,
                                                    self.viewport_height,
                                                    ))

        # adjust elements depending on the new viewport
        self.label.x = self.viewport_width // 2
        self.label.y = self.viewport_height // 2
开发者ID:reidrac,项目名称:pyglet-template,代码行数:31,代码来源:__init__.py

示例4: on_resize

 def on_resize(self, width, height):
     glViewport(0, 0, width, height)
     glMatrixMode(GL_PROJECTION)
     glLoadIdentity()
     glOrtho(0, width, 0, height, -1000, 1000)
     glMatrixMode(GL_MODELVIEW)
     return pyglet.event.EVENT_HANDLED
开发者ID:AojiaoZero,项目名称:thbattle,代码行数:7,代码来源:baseclasses.py

示例5: on_draw

    def on_draw():
        gl.glClearColor(1.0,1.0,1.0,1.0)
	window.clear()

        # Compute
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, 1, 0, 1, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)

        gl.glActiveTexture( gl.GL_TEXTURE1 )
	gl.glBindTexture(texture_s.target, texture_s.id)

        gl.glActiveTexture( gl.GL_TEXTURE0 )
	gl.glBindTexture(texture_uv.target, texture_uv.id)

        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, framebuffer)
	reaction_shader.bind()
        texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
	reaction_shader.unbind()
        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, 0)

        # Render
        gl.glViewport(0, 0, window.width, window.height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, 1, 0, 1, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)

	color_shader.bind()
        texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
	color_shader.bind()
开发者ID:rougier,项目名称:grayscott,代码行数:33,代码来源:grayscott.py

示例6: on_draw

def on_draw():
    update_grid()
    window.clear()
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.glOrtho(0, 200, 200, 0, 0, 1)
    grid.draw()
开发者ID:jamesturk,项目名称:graveyard,代码行数:7,代码来源:hex.py

示例7: SetOrigin

 def SetOrigin(self):
     size = self.GetVirtualSize()
     self.SetScrollbar(wx.HORIZONTAL, self.GetScrollPos(wx.HORIZONTAL), size[0],
                       self.map.width * 32 * self.zoom, refresh=True)
     self.SetScrollbar(wx.VERTICAL, self.GetScrollPos(wx.VERTICAL), size[1],
                       self.map.height * 32 * self.zoom, refresh=True)
     size = self.GetGLExtents()
     if size.width <= 0:
         size.width = 1
     if size.height <= 0:
         size.height = 1
     self.tilemap.updateDimmingSprite(
         int(size.width) + 2, int(size.height) + 2, 1 / self.zoom)
     gl.glViewport(0, 0, size.width, size.height)
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.glOrtho(
         0, size.width / self.zoom, 0, size.height / self.zoom, -1, 1)
     x = (-self.GetScrollPos(wx.HORIZONTAL)) / self.zoom
     y = ((-(self.map.height * 32) + size.height / self.zoom) +
          self.GetScrollPos(wx.VERTICAL) / self.zoom)
     gl.glTranslatef(x, y, 0)
     self.translateX = -x + size.width / 2 / self.zoom
     self.translateY = -y + size.height / 2 / self.zoom
     self.onscreenwidth = int(size.width / self.zoom)
     self.onscreenheight = int(size.height / self.zoom)
     self.tilemap.setDimXY(self.translateX - 1, self.translateY + 1)
     gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:borisblizzard,项目名称:arcreator,代码行数:28,代码来源:tilemap_panel.py

示例8: _drawLUTtoScreen

    def _drawLUTtoScreen(self):
        """(private) Used to set the LUT in Bits++ mode.

        Should not be needed by user if attached to a ``psychopy.visual.Window()``
        since this will automatically draw the LUT as part of the screen refresh.
        """
        #push the projection matrix and set to orthorgaphic
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glOrtho( 0, self.win.size[0],self.win.size[1], 0, 0, 1 )    #this also sets the 0,0 to be top-left
        #but return to modelview for rendering
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()

        #draw the pixels
        GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
        GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
        GL.glRasterPos2i(0,1)
        GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
        GL.glDrawPixels(len(self._HEADandLUT),1,
            GL.GL_RGB,GL.GL_UNSIGNED_BYTE,
            self._HEADandLUTstr)
        #GL.glDrawPixels(524,1, GL.GL_RGB,GL.GL_UNSIGNED_BYTE, self._HEADandLUTstr)
        #return to 3D mode (go and pop the projection matrix)
        GL.glMatrixMode( GL.GL_PROJECTION )
        GL.glPopMatrix()
        GL.glMatrixMode( GL.GL_MODELVIEW )
开发者ID:alexholcombe,项目名称:psychopy,代码行数:32,代码来源:bits.py

示例9: _resize

	def _resize(self, width, height):
		aspect = float(self._width)/self._height

		self._viewport_width = int(min(width, height*aspect))
		self._viewport_height = int(min(height, width/aspect))
		self._viewport_x_offs = (width-self._viewport_width) // 2
		self._viewport_y_offs = (height-self._viewport_height) // 2

		x = (width-self._width) / 2
		gl.glViewport(self._viewport_x_offs,
			self._viewport_y_offs,
			self._viewport_width,
			self._viewport_height,
		)
		gl.glMatrixMode(gl.GL_PROJECTION)
		gl.glLoadIdentity()
		gl.glOrtho(0, self._viewport_width, 0, self._viewport_height, -1, 1)
		gl.glMatrixMode(gl.GL_MODELVIEW)
		gl.glLoadIdentity()

		logging.debug("Viewport: %s, %s, %s, %s" % (self._viewport_x_offs,
			self._viewport_y_offs,
			self._viewport_width,
			self._viewport_height,
		))
开发者ID:PermianLizard,项目名称:Pyweek-17,代码行数:25,代码来源:director.py

示例10: _reset_projection

    def _reset_projection(self):
        if self.fullcanvas:
            if self._pygimage is None:
                return
            width, height = self._pygimage.width, self._pygimage.height
        else:
            size = self.GetClientSize()
            width, height = size.width, size.height

        b = 0
        t = height

        if self.flip_lr:
            l = width
            r = 0
        else:
            l = 0
            r = width

        if self.rotate_180:
            l,r=r,l
            b,t=t,b

        if width==0 or height==0:
            # prevent OpenGL error
            return

        self.wxcontext.SetCurrent()
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(l,r,b,t, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:BackupTheBerlios,项目名称:ctrax-svn,代码行数:32,代码来源:wxglvideo.py

示例11: draw

    def draw(self):
        # set up projection
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glViewport(self.x, self.y, self.width, self.height)
        gl.glOrtho(0, self.width, 0, self.height, self.near, self.far)
        gl.glMatrixMode(gl.GL_MODELVIEW)

        fx, fy = self._determine_focus()

        w2 = self.width / 2
        h2 = self.height / 2
        x1, y1 = fx - w2, fy - h2
        x2, y2 = fx + w2, fy + h2

        gl.glPushMatrix()
        gl.glTranslatef(self.width / 2 - fx, self.height / 2 - fy, 0)
        for layer in self.layers:
            if hasattr(layer, 'x'):
                translate = layer.x or layer.y
            else:
                translate = False
            if translate:
                gl.glPushMatrix()
                gl.glTranslatef(layer.x, layer.y, 0)
            layer.draw()
            if translate:
                gl.glPopMatrix()
        gl.glPopMatrix()
开发者ID:bitcraft,项目名称:pyglet,代码行数:29,代码来源:view.py

示例12: handle_resize

def handle_resize(w, h):
    gl.glViewport(0, 0, w, h)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.glOrtho(0, w, h, 0, 0, 1)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glLoadIdentity()
开发者ID:moshev,项目名称:project-viking,代码行数:7,代码来源:project_viking.py

示例13: draw_camera

def draw_camera():
    gl.glViewport(0, 0, w, h)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.glOrtho(0, w, 0, h, -1, 1)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glLoadIdentity()
开发者ID:rgrigoriadi,项目名称:pyGameOfLife,代码行数:8,代码来源:game.py

示例14: before_render

 def before_render(self, texture):
     self.pbuf.switch_to()
     gl.glViewport(0, 0, self.pbuf.width, self.pbuf.height)
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.glOrtho(0, self.pbuf.width, 0, self.pbuf.height, -1, 1)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glEnable(gl.GL_TEXTURE_2D)
开发者ID:BetaMatrix,项目名称:cocos,代码行数:8,代码来源:framegrabber.py

示例15: __enter__

 def __enter__(self):
     width, height = self.window.get_size()
     gl.glViewport(0, 0, width, height)
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.glOrtho(0, width, 0, height, -1, 1)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glLoadIdentity()
开发者ID:znah,项目名称:yoxel-voxel,代码行数:8,代码来源:zgl2.py


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