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


Python gl.gluOrtho2D函数代码示例

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


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


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