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


Python gl.glLoadIdentity函数代码示例

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


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

示例1: 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

示例2: translate

 def translate(self,dx,dy,dz):
     glPushMatrix()
     glLoadIdentity()
     glTranslatef(dx,dy,dz)
     glMultMatrixf(self.matrix)
     self.matrix=get_model_matrix()
     glPopMatrix()
开发者ID:fos,项目名称:fos-legacy,代码行数:7,代码来源:camera.py

示例3: _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

示例4: predraw

def predraw(w,h):
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION,vec(1,1,10, 3))
    gl.glLightModelfv(
        gl.GL_LIGHT_MODEL_AMBIENT|gl.GL_LIGHT_MODEL_TWO_SIDE,
        vec(1,1,1, 1.0)
    )

    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()
    #glOrtho(-1, 1, -1, 1, -1, 1)
    #(w,h) = self.get_size()
    gl.glScalef(
        float(min(w,h))/w,
        -float(min(w,h))/h,
        1
    )

    gl.gluPerspective(45.0, 1, 0.1, 1000.0)
    gl.gluLookAt(
        camera.x,
        camera.y,
        camera.z,
        0,0,0,
        camera.up[0],
        camera.up[1],
        camera.up[2]
    )
开发者ID:alcemirfernandes,项目名称:PinealLoopProject,代码行数:27,代码来源:windows.py

示例5: 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

示例6: _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

示例7: 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

示例8: 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

示例9: draw_text

def draw_text(text, start_x, start_y, color, size):
    """
    Draw text to the screen.

    Args:
        :text: Text to display.
        :start_x: x coordinate of top left text point.
        :start_y: y coordinate of top left text point.
        :color: color, specified in a list of 3 or 4 bytes in RGB or
         RGBA format.

    Example:

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> arcade.set_background_color(arcade.color.WHITE)
    >>> arcade.start_render()
    >>> arcade.draw_text("Text Example", 250, 300, arcade.color.BLACK, 10)
    >>> arcade.finish_render()
    >>> arcade.quick_run(0.25)
    """

    if len(color) == 3:
        color = (color[0], color[1], color[2], 255)

    label = pyglet.text.Label(text,
                              font_name='Times New Roman',
                              font_size=size,
                              x=start_x, y=start_y,
                              color=color)
    GL.glLoadIdentity()

    label.draw()
开发者ID:sions,项目名称:arcade,代码行数:33,代码来源:draw_commands.py

示例10: on_draw

def on_draw():
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glLoadIdentity()

    # Gradient sky
    l, b = world_to_screen((0, 0))
    r, t = world_to_screen((W, H))
    horizon = 177 / 255.0, 202 / 255.0, 1.0
    zenith = 68 / 255.0, 0.5, 1.0
    pyglet.graphics.draw(4, gl.GL_QUADS,
        ('v2f', [l, b, l, t, r, t, r, b]),
        ('c3f', sum([horizon, zenith, zenith, horizon], ())),
    )

    cx, cy = camera
    tx, ty = world_to_screen((-cx + W * 0.5, -cy + H * 0.5))
    gl.glTranslatef(tx, ty, 0)
    batch.draw()

    # Water
    l, b = world_to_screen((0, 0))
    r, t = world_to_screen((1000, WATER_LEVEL))
    gl.glEnable(gl.GL_BLEND)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    pyglet.graphics.draw(4, gl.GL_QUADS,
        ('v2f', [l, b, l, t, r, t, r, b]),
        ('c4f', [0, 0.2, 0.8, 0.5] * 4),
    )
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:28,代码来源:combined.py

示例11: draw

    def draw(self, frame):
        # The gneneral plan here is:
        #  1. Get the dots in the range of 0-255.
        #  2. Create a texture with the dots data.
        #  3. Draw the texture, scaled up with nearest-neighbor.
        #  4. Draw a mask over the dots to give them a slightly more realistic look.

        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glLoadIdentity()

        # Draw the dots in this color:
        #gl.glColor3f(1.0, 0.5, 0.25)

        gl.glScalef(1, -1, 1)
        gl.glTranslatef(0, -DMD_SIZE[1]*DMD_SCALE, 0)

        #data = frame.get_data_mult()
        
        #this new jk_get_data will read the dots using the dmd function
        #and convert them via the map to rGB.
        data = self.jk_get_data(frame)

        image = pyglet.image.ImageData(DMD_SIZE[0], DMD_SIZE[1], 'RGB', data, pitch=DMD_SIZE[0] * 3)  

        gl.glTexParameteri(image.get_texture().target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        image.blit(0, 0, width=DMD_SIZE[0]*DMD_SCALE, height=DMD_SIZE[1]*DMD_SCALE)

        del image

        gl.glScalef(DMD_SCALE/float(MASK_SIZE), DMD_SCALE/float(MASK_SIZE), 1.0)
        gl.glColor4f(1.0, 1.0, 1.0, 1.0)
        self.mask_texture.blit_tiled(x=0, y=0, z=0, width=DMD_SIZE[0]*MASK_SIZE, height=DMD_SIZE[1]*MASK_SIZE)
开发者ID:horseyhorsey,项目名称:SkeletonProcVisualPinball10,代码行数:33,代码来源:desktop_pyglet.py

示例12: 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

示例13: select_object

def select_object(x, y, objects=None):

    from miru.context import context

    if objects is None:
        objects = context.camera.objects

    # following technique is adapted from 
    # http://www.cse.msu.edu/~cse872/tutorial9.html
    
    w = context.window.width
    h = context.window.height


    select_buffer = ctypes.cast((100 * gl.GLuint)(), ctypes.POINTER(gl.GLuint))
    gl.glSelectBuffer(100, select_buffer)
  
    viewport = (4 * gl.GLint)()
    gl.glGetIntegerv(gl.GL_VIEWPORT, viewport)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glLoadIdentity()

    # rotate the camera first
    angle = context.camera.angle
    gl.glRotatef(angle.z, 0, 0, 1)
    gl.glRotatef(angle.y, 0, 1, 0)
    gl.glRotatef(angle.x, 1, 0, 0)

    gl.gluPickMatrix(x, y, 3, 3, viewport)
    gl.glRenderMode(gl.GL_SELECT)
    gl.gluPerspective(45., w / float(h), 0.1, 1000.)
    gl.glMatrixMode(gl.GL_MODELVIEW)

    gl.glInitNames()
    gl.glPushName(-1)
    
    context.camera.render(select_pass=1, visible=objects)

    gl.glFlush()
    hits = gl.glRenderMode(gl.GL_RENDER)
    gl.glPopName()

    selected = None
    if hits:
        try:
            m = sys.maxint << 100
            idx = 0
            for i in range(0, 100, 4):
                if not select_buffer[i]:
                    selected = objects[idx]
                    break
                m = min(select_buffer[i+1], m)
                if m == select_buffer[i+1]:
                    idx = select_buffer[i+3]
        except IndexError:
            pass
    
    context.window.on_resize(context.window.width, context.window.height)

    return selected
开发者ID:Knio,项目名称:miru,代码行数:60,代码来源:utils.py

示例14: run

  def run(self, dt):
    ## UPDATE ##
    # timestep ala http://gafferongames.com/game-physics/fix-your-timestep/
    if dt > .25: # avoid spiral of death (updating taking longer than framerate)
      dt = .25
    self.accumulatedFrameTime += dt
    while self.accumulatedFrameTime >= self.updateRate:
      self.accumulatedFrameTime -= self.updateRate
      self.levelTime = time.time() - self.levelStartTime
      for entity in self.groups['updating']:
        entity.update(self.updateRate) # update all entities
      self._processRemoving()
      self._processAdding()
      for level in self.groups['level']:
        level.update(self.updateRate) # this will do the physics

    ## DRAW ##
    gl.glClearColor(0,0,0, 0)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glLoadIdentity()

    self.camera.track() # does camera work (such as what it focuses on)
    for name in self.drawLayerNames:
      shift = Vec2d() if name.startswith('UI') else None
      with self.camera.shiftView(shift):
        for entity in self.drawLayers[name]: # TODO: not iterate over batched things
          entity.draw()
        self.drawLayersBatch[name].draw()

    self.fps_display.draw()
开发者ID:DomNomNom,项目名称:Jumpy2D,代码行数:30,代码来源:Engine.py

示例15: draw

    def draw(self):
        self.loadStartPosition()
        gl.glRotatef(90.0, 0.0, 0.0, 1.0)
        gl.glBegin(gl.GL_QUADS)
        gl.glColor3f(1.0, 1.0, 0.0)
        tenth = math.pi * 2.0 / 10.0
        for z in [-0.1, 0.1]:
            for i in xrange(5):
                a = float(i) * tenth * 2.0
                gl.glVertex3f(0.0, 0.0, z)
                gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), z)
                gl.glVertex3f(math.cos(a), math.sin(a), z)
                gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), z)
        for i in xrange(5):
            a = float(i) * tenth * 2.0
            gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
            gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), -0.1)
            gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
            gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), -0.1)
        gl.glEnd()

        self.loadStartPosition()
        gl.glTranslatef(0.0, 0.0, 0.1)
        gl.glScalef(0.01, 0.01, 0.0)
        self.label.draw()

        gl.glLoadIdentity()
开发者ID:benatkin,项目名称:pyglet-stuff,代码行数:31,代码来源:goldstar.py


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