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


Python GL.glColor4f方法代码示例

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


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

示例1: drawConditionalLines

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def drawConditionalLines(self):
        if self.type != GL.GL_LINES or len(self.points) != 12:
            return  # Not a conditional line
        
        p = self.points
        p0 = GLU.gluProject(p[0], p[1], p[2])
        p1 = GLU.gluProject(p[3], p[4], p[5])
        c0 = GLU.gluProject(p[6], p[7], p[8])
        c1 = GLU.gluProject(p[9], p[10], p[11])
        
        winding1 = self.pointWinding(p0, p1, c0)
        winding2 = self.pointWinding(p0, p1, c1)
        if winding1 != winding2:
            return
    
        GL.glPushAttrib(GL.GL_CURRENT_BIT)
        GL.glColor4f(1.0, 1.0, 0.0, 1.0)
        GL.glBegin(self.type)
        GL.glVertex3f(p[0], p[1], p[2])
        GL.glVertex3f(p[3], p[4], p[5])
        GL.glEnd()
        GL.glPopAttrib() 
开发者ID:remig,项目名称:lic,代码行数:24,代码来源:LicModel.py

示例2: drawTerrainReticle

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def drawTerrainReticle(self):
        """
        Draws the white reticle where the cursor is pointing.
        Called by leveleditor.render
        """
        if self.optionBackup != self.options:
            self.saveBrushPreset('__temp__')
            self.optionBackup = copy.copy(self.options)
        if not hasattr(self, 'brushMode'):
            return
        if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False):
            self.setupPreview()
            self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')]

        if self.pickBlockKey == 1:  #Alt is pressed
            self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0))
        else:
            pos, direction = self.editor.blockFaceUnderCursor
            reticlePoint = self.getReticlePoint(pos, direction)
            self.editor.drawWireCubeReticle(position=reticlePoint)
            if reticlePoint != pos:
                GL.glColor4f(1.0, 1.0, 0.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*map(lambda a: a + 0.5, reticlePoint))  #Center of reticle block
                    GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction))  #Top side of surface block
            dirtyBox = self.getDirtyBox(reticlePoint, self)
            self.drawTerrainPreview(dirtyBox.origin)
            if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True):  #If dragging mouse with Linetool pressed.
                GL.glColor4f(1.0, 1.0, 1.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*map(lambda a: a + 0.5, self.lastPosition))
                    GL.glVertex3f(*map(lambda a: a + 0.5, reticlePoint)) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:34,代码来源:brush.py

示例3: __callPreviousGLDisplayLists

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def __callPreviousGLDisplayLists(self, isCurrent=False):

        # Call all previous step's CSI display list
        prevStep = self.parentItem().getPrevStep()
        if prevStep:
            # if prevStep.csi.glDispID == LicGLHelpers.UNINIT_GL_DISPID:
            prevStep.csi.__callPreviousGLDisplayLists(False)
            # else:
            #    GL.glCallList(prevStep.csi.glDispID)

        # Draw all the parts in this CSI
        # First their edges
        GL.glPushAttrib(GL.GL_CURRENT_BIT | GL_ENABLE_BIT)
        GL.glColor4f(0.0, 0.0, 0.0, 1.0)
        GL.glDisable(GL_LIGHTING)
        
        for partItem in self.parts:
            for part in partItem.parts:
                part.callGLDisplayList(isCurrent, True)
                
        GL.glPopAttrib()
        
        # Than their contents
        for partItem in self.parts:
            for part in partItem.parts:
                part.callGLDisplayList(isCurrent, False) 
开发者ID:remig,项目名称:lic,代码行数:28,代码来源:LicModel.py

示例4: drawTerrainReticle

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def drawTerrainReticle(self):
        """
        Draws the white reticle where the cursor is pointing.
        Called by leveleditor.render
        """
        if self.optionBackup != self.options:
            self.saveBrushPreset('__temp__')
            self.optionBackup = copy.copy(self.options)
        if not hasattr(self, 'brushMode'):
            return
        if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False):
            self.setupPreview()
            self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')]

        if self.pickBlockKey == 1:  #Alt is pressed
            self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0))
        else:
            pos, direction = self.editor.blockFaceUnderCursor
            reticlePoint = self.getReticlePoint(pos, direction)
            self.editor.drawWireCubeReticle(position=reticlePoint)
            if reticlePoint != pos:
                GL.glColor4f(1.0, 1.0, 0.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint])  #Center of reticle block
                    GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction))  #Top side of surface block
            dirtyBox = self.getDirtyBox(reticlePoint, self)
            self.drawTerrainPreview(dirtyBox.origin)
            if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True):  #If dragging mouse with Linetool pressed.
                GL.glColor4f(1.0, 1.0, 1.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in self.lastPosition])
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint]) 
开发者ID:Podshot,项目名称:MCEdit-Unified,代码行数:34,代码来源:brush.py

示例5: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def paintGL(self, p, opt, widget):
        p.beginNativePainting()
        import OpenGL.GL as gl
        
        ## set clipping viewport
        view = self.getViewBox()
        if view is not None:
            rect = view.mapRectToItem(self, view.boundingRect())
            #gl.glViewport(int(rect.x()), int(rect.y()), int(rect.width()), int(rect.height()))
            
            #gl.glTranslate(-rect.x(), -rect.y(), 0)
            
            gl.glEnable(gl.GL_STENCIL_TEST)
            gl.glColorMask(gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE) # disable drawing to frame buffer
            gl.glDepthMask(gl.GL_FALSE)  # disable drawing to depth buffer
            gl.glStencilFunc(gl.GL_NEVER, 1, 0xFF)  
            gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)  
            
            ## draw stencil pattern
            gl.glStencilMask(0xFF)
            gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
            gl.glBegin(gl.GL_TRIANGLES)
            gl.glVertex2f(rect.x(), rect.y())
            gl.glVertex2f(rect.x()+rect.width(), rect.y())
            gl.glVertex2f(rect.x(), rect.y()+rect.height())
            gl.glVertex2f(rect.x()+rect.width(), rect.y()+rect.height())
            gl.glVertex2f(rect.x()+rect.width(), rect.y())
            gl.glVertex2f(rect.x(), rect.y()+rect.height())
            gl.glEnd()
                       
            gl.glColorMask(gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE)
            gl.glDepthMask(gl.GL_TRUE)
            gl.glStencilMask(0x00)
            gl.glStencilFunc(gl.GL_EQUAL, 1, 0xFF)
            
        try:
            x, y = self.getData()
            pos = np.empty((len(x), 2))
            pos[:,0] = x
            pos[:,1] = y
            gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
            try:
                gl.glVertexPointerf(pos)
                pen = fn.mkPen(self.opts['pen'])
                color = pen.color()
                gl.glColor4f(color.red()/255., color.green()/255., color.blue()/255., color.alpha()/255.)
                width = pen.width()
                if pen.isCosmetic() and width < 1:
                    width = 1
                gl.glPointSize(width)
                gl.glEnable(gl.GL_LINE_SMOOTH)
                gl.glEnable(gl.GL_BLEND)
                gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
                gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
                gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
            finally:
                gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        finally:
            p.endNativePainting() 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:61,代码来源:PlotCurveItem.py

示例6: callGLDisplayList

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor4f [as 别名]
def callGLDisplayList(self, useDisplacement, paintingEdge):

        # must be called inside a glNewList/EndList pair
        if self.inverted:
            GL.glPushAttrib(GL.GL_POLYGON_BIT)
            GL.glFrontFace(GL.GL_CW)

        if self.matrix:
            matrix = list(self.matrix)
            if useDisplacement and self.displacement:
                matrix[12] += self.displacement[0]
                matrix[13] += self.displacement[1]
                matrix[14] += self.displacement[2]
            GL.glPushMatrix()
            GL.glMultMatrixf(matrix)

        if useDisplacement and (self.isSelected() or CSI.highlightNewParts):
            GL.glPushAttrib(GL.GL_CURRENT_BIT)
            GL.glColor4f(1.0, 0.0, 0.0, 1.0)
            self.drawGLBoundingBox()
            GL.glPopAttrib()

        if self.color is not None:
            GL.glPushAttrib(GL.GL_CURRENT_BIT)
        
        if paintingEdge:
            if self.color is not None and self.color.edgeRgba is not None:
                color = list(self.color.edgeRgba)
                if useDisplacement and self.isSelected():
                    color[3] *= 0.6
                GL.glColor4fv(color)
                    
            GL.glCallList(self.abstractPart.glEdgeDispID)

        else:
            if self.color is not None:
                color = list(self.color.rgba)
                if useDisplacement and self.isSelected():
                    color[3] *= 0.5
                GL.glColor4fv(color)
    
            GL.glCallList(self.abstractPart.glDispID)
        
        if self.color is not None:
            GL.glPopAttrib()
        
        # self.abstractPart.drawConditionalLines()

        if self.matrix:
            GL.glPopMatrix()

        if self.inverted:
            GL.glPopAttrib()

        if not paintingEdge:
            for arrow in self.arrows:
                arrow.callGLDisplayList(useDisplacement) 
开发者ID:remig,项目名称:lic,代码行数:59,代码来源:LicModel.py


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