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

Python gl.gluOrtho2D函数代码示例

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

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



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

示例1: _layerProjectLocalToScreen

    def _layerProjectLocalToScreen(self):
        """Maps self.coordLocal to self.coordScreen within OpenGL."""
        if self._scissorBox is None and self.localBounds is None:
            return
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        # gluOrtho2D declares the render space for the corners of the window.
        # So, we want to set it up in such a way that our layer renders in
        # the right place.  In other words, determine window corners that
        # map cl -> cs.  All clipping, etc is already handled by the coordsLocal
        # getter.
        cs = self.coordsScreen
        cl = self.coordsLocal
        sw = self.scene.width
        sh = self.scene.height

        # Determine the window width and height.  We want a local-sized chunk
        # of this to correspond to a screen-sized chunk of the screen.  That is,
        # cl[2] / ww == cs[2] / sw
        ww = cl[2] * sw / cs[2]
        wh = cl[3] * sh / cs[3]

        # cs[0] / sw = (x - nx) / ww
        nx = cl[0] - cs[0] * ww / sw
        ny = cl[1] - cs[1] * wh / sh
        gl.gluOrtho2D(nx, nx+ww, ny, ny+wh)
        gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:wwoods,项目名称:pyglet_piss,代码行数:28,代码来源:layer.py


示例2: world_projection

    def world_projection(self):
        """
        Sets OpenGL projection and modelview matrices such that the window
        is centered on self.(x,y), shows at least 'scale' world units in every
        direction, and is oriented by rot.
        """
        left = bottom = -self.scale
        right = top = self.scale
        aspect = self.width / self.height
        if aspect >= 1:
            # landscape
            left *= aspect
            right *= aspect
        else:
            # portrait
            bottom /= aspect
            top /= aspect
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluOrtho2D(left, right, bottom, top)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(
            self.x, self.y, +1.0,
            self.x, self.y, -1.0,
            sin(self.rot), cos(self.rot), 0.0)
开发者ID:tartley,项目名称:chronotank,代码行数:27,代码来源:camera.py


示例3: _set_texture

    def _set_texture(self, t):
        self._texture = t
        from pyglet import gl
        try:
            gl.glFramebufferTexture2DEXT(
                gl.GL_FRAMEBUFFER_EXT,
                gl.GL_COLOR_ATTACHMENT0_EXT,
                t.target, t.id, 0,
            )
        except gl.GLException:
            # HACK: Some Intel card return errno == 1286L
            # which means GL_INVALID_FRAMEBUFFER_OPERATION_EXT
            # but IT ACTUALLY WORKS FINE!!
            pass

        gl.glViewport(0, 0, t.width, t.height)

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluOrtho2D(0, t.width, 0, t.height)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        # ATI cards hack
        gl.glBegin(gl.GL_LINES)
        gl.glEnd()
开发者ID:feisuzhu,项目名称:thbattle,代码行数:27,代码来源:misc.py


示例4: hud_mode

 def hud_mode(self):
     "Set matrices ready for drawing HUD, like fps counter"
     glMatrixMode(GL_PROJECTION)
     glLoadIdentity()
     gluOrtho2D(0, self.win_width, 0, self.win_height)
     glMatrixMode(GL_MODELVIEW)
     glLoadIdentity()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:camera.py


示例5: get_vlist

def get_vlist(geom, batch=None, group=None, data=None):
        """Get a "new" C{pyglet.graphics.VertexList} for this
        geometry.  If a batch is given, vertex list will be added to the batch
        """
        # projection with one world coordinate unit equal to one screen pixel
        # glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0, windowWidth, 0, windowHeight);
        window = pyglet.window.get_platform().get_default_display().get_windows()[0]
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluOrtho2D(0,
                      window.width,
                      0,
                      window.height)
        _data = [('v3f', geom.vertex_data)]
        if hasattr(geom, 'normal_data'):
            _data.append(('n3f', geom.normal_data))
        if hasattr(geom, 'texcoord_data'):
            _data.append(('t2f', geom.texcoord_data))
        if data:
            _data.extend(data)
        count = len(geom.vertex_data) // geom.vertex_pitch
        indexed = hasattr(geom, 'indices')
        if batch:
            if indexed:
                return batch.add_indexed( count,
                        geom.drawing_mode, group, geom.indices, *_data)
            return batch.add( count,
                    geom.drawing_mode, group, *_data)
        if indexed:
            return pyglet.graphics.vertex_list_indexed( count, geom.indices, *_data )
        return pyglet.graphics.vertex_list( count, *_data)
开发者ID:Knio,项目名称:miru,代码行数:31,代码来源:geom.py


示例6: world_projection

    def world_projection(self, aspect):
        """
        Sets OpenGL projection and modelview matrices such that the window
        is centered on self.(x,y), shows at least scale world units in every
        direction, and is oriented by angle.
        """
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        if aspect < 1:
            gluOrtho2D(
                -self.scale,
                +self.scale,
                -self.scale / aspect,
                +self.scale / aspect)
        else:
            gluOrtho2D(
                -self.scale * aspect,
                +self.scale * aspect,
                -self.scale,
                +self.scale)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(
            self.x, self.y, +1.0,
            self.x, self.y, -1.0,
            sin(self.angle), cos(self.angle), 0.0)
开发者ID:tartley,项目名称:sole-scion,代码行数:27,代码来源:camera.py


示例7: paint

    def paint(self, func):
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()

        gl.gluOrtho2D(
            0,
            self.width,
            0,
            self.height
        )

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        gl.glViewport(0, 0, self.width, self.height)

        gl.glBindFramebufferEXT(gl.GL_DRAW_FRAMEBUFFER_EXT,
                                self.col_buffer.gl_buffer)

        gl.glFramebufferTexture2DEXT(
            gl.GL_DRAW_FRAMEBUFFER_EXT,
            gl.GL_COLOR_ATTACHMENT0_EXT,
            self.texture.target, self.texture.id, 0)

        func()

        gl.glBindFramebufferEXT(gl.GL_DRAW_FRAMEBUFFER_EXT, 0)
开发者ID:ShaneFarrell,项目名称:TGM-original,代码行数:29,代码来源:pyglet.py


示例8: gl_setup

def gl_setup():  # general GL setup
    glMatrixMode(GL_PROJECTION)
    glMatrixMode(GL_MODELVIEW)
    gluOrtho2D(0, WIDTH, 0, HEIGHT)  # dont understand, check this                # TODO
    glLoadIdentity()
    glTranslatef(CENTX, CENTY, 0)
    glClear(GL_COLOR_BUFFER_BIT)
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:field.py


示例9: update

    def update(self):
        self.x += (self.target_x - self.x) * 0.1
        self.y += (self.target_y - self.y) * 0.1
        self.scale += (self.target_scale - self.scale) * 0.1
        self.angle += (self.target_angle - self.angle) * 0.1

        "Set projection and modelview matrices ready for rendering"

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()

        gluOrtho2D(
            -self.scale * self.aspect,
            +self.scale * self.aspect,
            -self.scale,
            +self.scale)

        # Set modelview matrix to move, scale & rotate to camera position"
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(
            self.x, self.y, +1.0,
            self.x, self.y, -1.0,
            sin(self.angle), cos(self.angle), 0.0)
        print 'gluLookAt:', self.x,self.y, self.angle
开发者ID:msarch,项目名称:py,代码行数:25,代码来源:camera.py


示例10: enable_2d

 def enable_2d(self):
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.gluOrtho2D(0.0, self.width, 0.0, self.height)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glLoadIdentity()
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_CULL_FACE)
     gl.glDisable(gl.GL_LIGHTING)
开发者ID:pennomi,项目名称:banneret,代码行数:9,代码来源:renderer.py


示例11: set_state

    def set_state(self):
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.gluOrtho2D(0, self.window.width, 0, self.window.height)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glPushMatrix()
        gl.glLoadIdentity()
开发者ID:Gallardot,项目名称:GallardotStorage,代码行数:9,代码来源:pyglet_main.py


示例12: bind_window

def bind_window(w, h):
    gl.glBindFramebufferEXT(gl.GL_DRAW_FRAMEBUFFER_EXT, 0)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glLoadIdentity()
    gl.glViewport(0, 0, w, h)
    gl.glScissor(0, 0, w, h);
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    gl.gluOrtho2D(0, w, h, 0)
开发者ID:ShaneFarrell,项目名称:TGM,代码行数:9,代码来源:render_context.py


示例13: worldProjection

 def worldProjection(self):
     glMatrixMode(GL_PROJECTION)
     glLoadIdentity()
     widthRatio = self.win.width / self.win.height
     gluOrtho2D(
         -self.zoom * widthRatio,
         self.zoom * widthRatio,
         -self.zoom,
         self.zoom)
开发者ID:purplemass,项目名称:python-slideshow,代码行数:9,代码来源:polygon.py


示例14: focus

 def focus(self):
     try:
         gl.glMatrixMode(gl.GL_PROJECTION)
         gl.glLoadIdentity()
         gl.gluOrtho2D(0, settings.GAME_WIDTH + PANEL_WIDTH, 0, settings.GAME_HEIGHT + HUD_HEIGHT)
         gl.glMatrixMode(gl.GL_MODELVIEW)
         gl.glLoadIdentity()
     except Exception, e:
         time.sleep(0.0001)
         print(e, traceback.print_exc())
开发者ID:jordanupmc,项目名称:soccersimulator,代码行数:10,代码来源:interfaces.py


示例15: __enter__

    def __enter__(self):
        w, h = self.size
        cx, cy = self.center
        dx, dy = 0.5*self.get_pixel_extent()*(w, h)

        gl.glViewport(0, 0, w, h)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluOrtho2D(cx-dx, cx+dx, cy-dy, cy+dy)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
开发者ID:znah,项目名称:yoxel-voxel,代码行数:11,代码来源:zgl2.py


示例16: hud_projection

    def hud_projection(self, size):
        """
        Sets OpenGL pojection and modelview matrices such that the window
        renders (0,0) to (size.x, size,y)
        """
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluOrtho2D(0, size[0], 0, size[1])
开发者ID:tartley,项目名称:sole-scion,代码行数:11,代码来源:camera.py


示例17: ui_mode

    def ui_mode(self):
        gl.glDisable(gl.GL_DEPTH_TEST)
        gl.glDisable(gl.GL_CULL_FACE)
        gl.glDisable(gl.GL_TEXTURE_2D)
        gl.glDisable(gl.GL_LIGHTING)

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluOrtho2D(-self.w / 2, self.w / 2, -self.h / 2, self.h / 2)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
开发者ID:anden3,项目名称:Python,代码行数:12,代码来源:Craftmine.py


示例18: draw

	def draw(self, selected_unit):
		glLoadIdentity()
		gluOrtho2D(0, self.window.width, 0, self.window.height)
		if selected_unit is not None:
			if self.action_gui_batch is None:
				self.build_action_gui(selected_unit)
			if self.action_gui_batch is not None:
				self.action_gui_batch.draw()
			if self.status_gui_batch is None:
				self.build_status_gui()
			self.status_box.set_text(selected_unit.status)
			self.status_gui_batch.draw()
开发者ID:zudijyr,项目名称:Building-Sim-Game,代码行数:12,代码来源:hud.py


示例19: focus

    def focus(self, width, height):
        "Set projection and modelview matrices ready for rendering"

        # Set projection matrix suitable for 2D rendering"
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        aspect = width / height
        gluOrtho2D(-self.scale * aspect, +self.scale * aspect, -self.scale, +self.scale)

        # Set modelview matrix to move, scale & rotate to camera position"
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(self.x, self.y, +1.0, self.x, self.y, -1.0, sin(self.angle), cos(self.angle), 0.0)
开发者ID:kragniz,项目名称:pylatform,代码行数:13,代码来源:camera.py


示例20: translateForPixels

 def translateForPixels(self, x, y):
     """Returns a context manager that translates to x, y in local coords and
     then changes the scaling so that subsequent rendering happens in
     pixel space.  Useful to get around scaling."""
     cs = (0, 0, self.scene.width, self.scene.height)
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     gl.gluOrtho2D(cs[0], cs[2], cs[1], cs[3])
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     s = self._layerMapToScreen(x, y)
     gl.glTranslatef(s[0], s[1], 0.0)
     return _RestoreProjectionAndModelview()
开发者ID:wwoods,项目名称:pyglet_piss,代码行数:15,代码来源:layer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python gl_info.get_renderer函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glViewport函数代码示例发布时间: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