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


Python GL.glMatrixMode方法代码示例

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


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

示例1: initgl

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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 glMatrixMode [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: freezeStatus

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def freezeStatus(string):
        return

    #        GL.glColor(1.0, 0., 0., 1.0)
    #
    #        # glDrawBuffer(GL.GL_FRONT)
    #        GL.glMatrixMode(GL.GL_PROJECTION)
    #        GL.glPushMatrix()
    #        glRasterPos(50, 100)
    #        for i in string:
    #            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(i))
    #
    #        # glDrawBuffer(GL.GL_BACK)
    #        GL.glMatrixMode(GL.GL_PROJECTION)
    #        GL.glPopMatrix()
    #        glFlush()
    #        display.flip()
    #        # while(True): pass 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:20,代码来源:leveleditor.py

示例4: gl_draw

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例5: resizeGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例6: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例7: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例8: resize

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例9: drawCeiling

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def drawCeiling(self):
        GL.glMatrixMode(GL.GL_MODELVIEW)
        # GL.glPushMatrix()
        x, y, z = self.cameraPosition
        x -= x % 16
        z -= z % 16
        y = self.editor.level.Height
        GL.glTranslate(x, y, z)
        self.ceilingList.call(self._drawCeiling)
        GL.glTranslate(-x, -y, -z) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:12,代码来源:camera.py

示例10: setup_matrices

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例11: glPushMatrix

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def glPushMatrix(cls, matrixmode):
        try:
            GL.glMatrixMode(matrixmode)
            GL.glPushMatrix()
            yield
        finally:
            GL.glMatrixMode(matrixmode)
            GL.glPopMatrix() 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:10,代码来源:glutils.py

示例12: drawToolMarkers

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def drawToolMarkers(self):
        if self.editor.currentTool != self:
            return

        if self.panel and self.replacing:
            blockInfo = self.replaceBlockInfo
        else:
            blockInfo = self.blockInfo

        color = 1.0, 1.0, 1.0, 0.35
        if blockInfo:
            terrainTexture = self.editor.level.materials.terrainTexture
            tex = self.editor.level.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0]  # xxx
            tex = Texture(self.blockTexFunc(terrainTexture, tex))

            # color = (1.5 - alpha, 1.0, 1.5 - alpha, alpha - 0.35)
            GL.glMatrixMode(GL.GL_TEXTURE)
            GL.glPushMatrix()
            GL.glScale(16., 16., 16.)

        else:
            tex = None
            # color = (1.0, 0.3, 0.3, alpha - 0.35)

        GL.glPolygonOffset(DepthOffset.FillMarkers, DepthOffset.FillMarkers)
        self.editor.drawConstructionCube(self.selectionBox(),
                                         color,
                                         texture=tex)

        if blockInfo:
            GL.glMatrixMode(GL.GL_TEXTURE)
            GL.glPopMatrix() 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:34,代码来源:fill.py

示例13: resizeGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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

示例14: gl_draw_all

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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:
                #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:Podshot,项目名称:MCEdit-Unified,代码行数:36,代码来源:widget.py

示例15: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def paintGL(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        width = float(self.width())
        height = float(self.height())
        frustrumx = 60*width/self.sizeHint().width()
        frustrumy = 60*height/self.sizeHint().height()
        GL.glFrustum(-frustrumx, frustrumx, frustrumy, -frustrumy, 200, 500)
        GL.glMatrixMode(GL.GL_MODELVIEW)

        self.drawAxis()

        GL.glLoadIdentity()
        GL.glTranslatef(self.xTran, self.yTran, self.zTran)
        GL.glRotatef(self.xRot / 16.0, 1.0, 0.0, 0.0)
        GL.glRotatef(self.yRot / 16.0, 0.0, 1.0, 0.0)
        GL.glRotatef(self.zRot / 16.0, 0.0, 0.0, 1.0)
        GL.glScalef(-self.zoom,self.zoom,self.zoom)

        if self.model != 0:
            GL.glCallList(self.model)

        if self.indicator:
            GL.glCallList(self.indicator)

        for stimulator in self.stimulator_objects:
            try:
                GL.glCallList(stimulator)
            except:
                pass

        for tmp in self.tmp_objects:
            try:
                GL.glCallList(tmp)
            except:
                pass

        try:
            GL.glCallList(self.eegReferences)
        except:
            pass

        try:
            GL.glCallList(self.eegPositions)
        except:
            pass

        self.model_matrix = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
        self.projection_matrix = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX) 
开发者ID:simnibs,项目名称:simnibs,代码行数:52,代码来源:head_model_OGL.py


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