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


Python GL.glLoadIdentity方法代码示例

本文整理汇总了Python中OpenGL.GL.glLoadIdentity方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glLoadIdentity方法的具体用法?Python GL.glLoadIdentity怎么用?Python GL.glLoadIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenGL.GL的用法示例。


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

示例1: initgl

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def initgl(self):
        """Initialize OpenGL for use in the window."""
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        self.load_textures()
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glClearColor(*self.clear_color)
        gl.glClearDepth(1.0)
        gl.glDepthFunc(gl.GL_LESS)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glShadeModel(gl.GL_SMOOTH)

        gl.glMatrixMode(gl.GL_PROJECTION)
        # Reset The projection matrix
        gl.glLoadIdentity()
        # Calculate aspect ratio of the window
        (width, height) = self.canvas.GetClientSize()
        glu.gluPerspective(45.0, float(width) / float(height), 0.1, 100.0)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, (0.5, 0.5, 0.5, 1.0))
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, (0.0, 0.0, 2.0, 1.0))
        gl.glEnable(gl.GL_LIGHT0) 
开发者ID:spectralpython,项目名称:spectral,代码行数:26,代码来源:hypercube.py

示例2: draw_box

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def draw_box(self, x0, y0, x1, y1):
        '''Draws a selection box in the 3-D window.
        Coordinates are with respect to the lower left corner of the window.
        '''
        import OpenGL.GL as gl
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0.0, self.size[0],
                   0.0, self.size[1],
                   -0.01, 10.0)

        gl.glLineStipple(1, 0xF00F)
        gl.glEnable(gl.GL_LINE_STIPPLE)
        gl.glLineWidth(1.0)
        gl.glColor3f(1.0, 1.0, 1.0)
        gl.glBegin(gl.GL_LINE_LOOP)
        gl.glVertex3f(x0, y0, 0.0)
        gl.glVertex3f(x1, y0, 0.0)
        gl.glVertex3f(x1, y1, 0.0)
        gl.glVertex3f(x0, y1, 0.0)
        gl.glEnd()
        gl.glDisable(gl.GL_LINE_STIPPLE)
        gl.glFlush()

        self.resize(*self.size) 
开发者ID:spectralpython,项目名称:spectral,代码行数:27,代码来源:ndwindow.py

示例3: render_rgb_indexed_colors

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def render_rgb_indexed_colors(self, **kwargs):
        '''Draws scene in the background buffer to extract mouse click info'''
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        # camera_pos_rtp is relative to the target position. To get the
        # absolute camera position, we need to add the target position.
        gl.glPushMatrix()
        camera_pos_xyz = np.array(rtp_to_xyz(*self.camera_pos_rtp)) \
            + self.target_pos
        glu.gluLookAt(
            *(list(camera_pos_xyz) + list(self.target_pos) + self.up))
        self.draw_data_set()
        gl.glPopMatrix()
        gl.glFlush() 
开发者ID:spectralpython,项目名称:spectral,代码行数:20,代码来源:ndwindow.py

示例4: drawSelf

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def drawSelf(self):
        if self._tex is None:
            filename = os.path.join("toolicons", "compass.png")

            self._tex = loadPNGTexture(filename)
            
        self._tex.bind()
        size = 0.001 * config.settings.compassSize.get()

        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glLoadIdentity()

            yaw, pitch = self.yawPitch
            if config.settings.viewMode.get() == "Chunk":
                yaw = -180
            GL.glTranslatef(1. - (size + self.x), size + self.y, 0.0)  # position on upper right corner
            GL.glRotatef(180 - yaw, 0., 0., 1.)  # adjust to north
            GL.glColor3f(1., 1., 1.)

            with gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY):
                GL.glVertexPointer(2, GL.GL_FLOAT, 0, makeQuad(-size, -size, 2 * size, 2 * size))
                GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, makeQuad(0, 0, 256, 256))

                with gl.glEnable(GL.GL_BLEND, GL.GL_TEXTURE_2D):
                    GL.glDrawArrays(GL.GL_QUADS, 0, 4) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:27,代码来源:compass.py

示例5: gl_draw

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def gl_draw(self):
        if self.schematic.chunkCount > len(self.renderer.chunkRenderers):
            self.gl_draw_thumb()
        else:
            if self.fbo is None:
                w, h = self.fboSize
                self.fbo = FramebufferTexture(w, h, self.gl_draw_tex)
            GL.glMatrixMode(GL.GL_PROJECTION)
            GL.glLoadIdentity()
            GL.glMatrixMode(GL.GL_MODELVIEW)
            GL.glLoadIdentity()
            GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
            GL.glColor(1.0, 1.0, 1.0, 1.0)
            GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                         - 1, 1,
                                                         1, 1,
                                                         1, -1, ], dtype='float32'))
            GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([0, 0, 0, 256, 256, 256, 256, 0], dtype='float32'))
            e = (GL.GL_TEXTURE_2D,)
            if not self.drawBackground:
                e += (GL.GL_ALPHA_TEST,)
            with gl.glEnable(*e):
                self.fbo.bind()
                GL.glDrawArrays(GL.GL_QUADS, 0, 4)
            GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:27,代码来源:thumbview.py

示例6: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def paintGL(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glLoadIdentity()
        GL.glTranslated(0.0, 0.0, -10.0)
        GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
        GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
        GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
        GL.glScalef(self.zoom,self.zoom,self.zoom)

        GL.glCallList(self.electrode_object)
        GL.glCallList(self.center_dir)
        if self.plug_object != 0:
            GL.glCallList(self.plug_object) 
开发者ID:simnibs,项目名称:simnibs,代码行数:15,代码来源:electrodeGUI.py

示例7: resizeGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def resizeGL(self, width, height):
        side = min(width, height)
        GL.glViewport((width - side) // 2, (height - side) // 2, side, side)
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        #GL.glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0)
        GL.glFrustum(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0)
        GL.glMatrixMode(GL.GL_MODELVIEW) 
开发者ID:simnibs,项目名称:simnibs,代码行数:10,代码来源:electrodeGUI.py

示例8: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def resize(width,height):
        gl.glViewport(0, 0, width, height+4)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, width, 0, height+4, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:8,代码来源:gui-glut.py

示例9: on_paint

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def on_paint(self, event):
        """Process the drawing event."""
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        self.canvas.SetCurrent(self.canvas.context)

        if not self.gl_initialized:
            self.initgl()
            self.gl_initialized = True
            self.print_help()

        if self.light:
            gl.glEnable(gl.GL_LIGHTING)
        else:
            gl.glDisable(gl.GL_LIGHTING)

        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()
        gl.glPushMatrix()
        glu.gluLookAt(*(list(rtp_to_xyz(
            *self.camera_pos_rtp)) + list(self.target_pos) + list(self.up)))

        self.draw_cube()

        gl.glPopMatrix()
        gl.glFlush()
        self.SwapBuffers()
        event.Skip() 
开发者ID:spectralpython,项目名称:spectral,代码行数:30,代码来源:hypercube.py

示例10: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def resize(self, width, height):
        """Reshape the OpenGL viewport based on dimensions of the window."""
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        self.size = (width, height)
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        glu.gluPerspective(self.fovy, float(width) / height,
                           self.znear, self.zfar)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity() 
开发者ID:spectralpython,项目名称:spectral,代码行数:14,代码来源:hypercube.py

示例11: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def resize(self, width, height):
        """Reshape the OpenGL viewport based on dimensions of the window."""
        import OpenGL.GL as gl
        import OpenGL.GLU as glu
        self.size = (width, height)
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        glu.gluPerspective(self.fovy, float(width) / height,
                           self.znear, self.zfar)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity() 
开发者ID:spectralpython,项目名称:spectral,代码行数:15,代码来源:ndwindow.py

示例12: setup_matrices

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def setup_matrices(self):
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        self.setup_projection()
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()
        self.setup_modelview() 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:9,代码来源:openglwidgets.py

示例13: gl_draw_all

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def gl_draw_all(self, root, offset):
        if not self.visible:
            return
        from OpenGL import GL, GLU

        rect = self.rect.move(offset)
        if self.is_gl_container:
            self.gl_draw_self(root, offset)
            suboffset = rect.topleft
            for subwidget in self.subwidgets:
                subwidget.gl_draw_all(root, suboffset)
        else:
            try:
                surface = Surface(self.size, SRCALPHA)
            except Exception:
                #size error?
                return
            self.draw_all(surface)
            data = image.tostring(surface, 'RGBA', 1)
            w, h = root.size
            GL.glViewport(0, 0, w, h)
            GL.glMatrixMode(GL.GL_PROJECTION)
            GL.glLoadIdentity()
            GLU.gluOrtho2D(0, w, 0, h)
            GL.glMatrixMode(GL.GL_MODELVIEW)
            GL.glLoadIdentity()
            GL.glRasterPos2i(max(rect.left, 0), max(h - rect.bottom, 0))
            GL.glPushAttrib(GL.GL_COLOR_BUFFER_BIT)
            GL.glEnable(GL.GL_BLEND)
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
            GL.glDrawPixels(self.width, self.height,
                            GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, fromstring(data, dtype='uint8'))
            GL.glPopAttrib()
            GL.glFlush() 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:36,代码来源:widget.py

示例14: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def paintGL(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glLoadIdentity()
        GL.glTranslated(0.0, 0.0, -10.0)
        GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
        GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
        GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
        GL.glCallList(self.object) 
开发者ID:dragondjf,项目名称:PFramer,代码行数:10,代码来源:opengl_test.py

示例15: resizeGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glLoadIdentity [as 别名]
def resizeGL(self, width, height):
        side = min(width, height)
        GL.glViewport((width - side) / 2, (height - side) / 2, side, side)

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        GL.glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0)
        GL.glMatrixMode(GL.GL_MODELVIEW) 
开发者ID:dragondjf,项目名称:PFramer,代码行数:10,代码来源:opengl_test.py


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