• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gl.glOrtho函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: on_resize

 def on_resize(self, width, height, x=0, y=0):
     gl.glViewport(x, y, width, height)
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     h = height or 1
     w = width / float(h)
     gl.glOrtho(-w, w, -1, 1, -1, 1000.)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     self._setLightsAndEffects()
开发者ID:Knio,项目名称:miru,代码行数:9,代码来源:camera.py


示例17: _set_2d

 def _set_2d(self, near, far):
     w = self.context.window
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     gl.glOrtho(0, w.width, 0, w.height, near, far)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glPushMatrix()
     gl.glLoadIdentity()
开发者ID:Knio,项目名称:miru,代码行数:9,代码来源:osd2.py


示例18: on_resize

 def on_resize(self, width, height):
     from options import options
     z = options.zoom
     glViewport(0, 0, int(width * z), int(height * z))
     glMatrixMode(GL_PROJECTION)
     glLoadIdentity()
     glOrtho(0, width, 0, height, -1000, 1000)
     glMatrixMode(GL_MODELVIEW)
     return pyglet.event.EVENT_HANDLED
开发者ID:feisuzhu,项目名称:thbattle,代码行数:9,代码来源:baseclasses.py


示例19: on_draw

    def on_draw(self, dt):
        self.window.clear()

        # This is where the code to auto-resize the window begins.

        # Set it up to draw to the whole space of the window.
        glViewport(0, 0, self.window.width, self.window.height)

        # Switch to projection matrix.
        glMatrixMode(gl.GL_PROJECTION)
        glLoadIdentity()

        # Calculate the size of our display.
        base_size = 240.0
        size_x = 0.0
        size_y = 0.0
        if (self.window.width >= self.window.height):
            size_x = base_size * (self.window.width/float(self.window.height))
            size_y = base_size
        else:
            size_x = base_size
            size_y = base_size * (self.window.height/float(self.window.width))

        # Set the orthogonal projection.
        glOrtho(-size_x/2.0, size_x/2.0, -size_y/2.0, size_y/2.0, -100, 100)

        # Switch back to model view so we can do the rest of our drawing.
        glMatrixMode(gl.GL_MODELVIEW)
        glLoadIdentity()

        # Draw stuff in the level.
        glPushMatrix()
        glTranslatef(int(-self.player1.x), int(-self.player1.y), 0.0)

        self.bg.draw()

        for platform in self.platforms:
            platform.render()

        self.player1.draw()
        if const.DRAW_SENSORS:
            for sensor in self.player1.sensors:
                sensor.render()
        
        glPopMatrix()

        # Draw HUD.
        self.fps_display.text = 'FPS: %d' % (1 / dt)
        self.fps_display.draw()

        self.debug_text[0].text = str(int(self.player1.hlock))
        self.debug_text[1].text = str(self.player1.state)
        self.debug_text[2].text = str(self.player1.rangle)
        self.debug_text[0].draw()
        self.debug_text[1].draw()
        self.debug_text[2].draw()
开发者ID:DMAshura,项目名称:porcupyne,代码行数:56,代码来源:porcupyne.py


示例20: set_2d

 def set_2d(self, size):
     """Configure OpenGL to draw in 2d."""
     width, height = size
     GL.glDisable(GL.GL_DEPTH_TEST)
     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:PythonJedi,项目名称:pycraft,代码行数:10,代码来源:gs_running.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glPopAttrib函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glMatrixMode函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap