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


Python GL.glBlendFunc方法代码示例

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


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

示例1: redraw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glBlendFunc [as 别名]
    def redraw(self):
        """ redraw the Material editor opengl sphere that shows the effect
of the modifications
"""
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()

        self.tk.call(self._w, 'makecurrent')
        GL.glClearColor(0,0,0,0)
        self.initProjection()
        self.Configure()
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        """ draw the black background squares """
        GL.glDisable( GL.GL_LIGHTING )
        GL.glColor3f( 0.1, 0.1, 0.1 )
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2, 0, 2); GL.glVertex3f(-2, 2, 2)
        GL.glVertex3f( 0, 2, 2); GL.glVertex3f( 0, 0, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f( 0,-2, 2); GL.glVertex3f( 0, 0, 2)
        GL.glVertex3f( 2, 0, 2); GL.glVertex3f( 2,-2, 2)
        GL.glEnd()

        """ draw the grey background squares """
        GL.glColor3f( 0.3, 0.3, 0.3 )
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f(-2,-2, 2); GL.glVertex3f(-2, 0, 2)
        GL.glVertex3f( 0, 0, 2); GL.glVertex3f( 0,-2, 2)
        GL.glEnd()
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3f( 0, 0, 2); GL.glVertex3f( 0, 2, 2)
        GL.glVertex3f( 2, 2, 2); GL.glVertex3f( 2, 0, 2)
        GL.glEnd()

        """ enable the sphere transparancy """
        GL.glEnable(GL.GL_BLEND)
        GL.glDepthMask(GL.GL_FALSE)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        """ draw the sphere """
        #GL.glEnable(GL.GL_LIGHTING)
        if self.viewer is not None:
            self.viewer.enableOpenglLighting()
        self.setMaterial()
        extractedGlutSolidSphere(1.6, 30, 30, 0)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:49,代码来源:MaterialEditor.py

示例2: drawLegendOnly

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glBlendFunc [as 别名]
def drawLegendOnly(
                    fullWidth,
                    fullHeight,
                    ramp,
                    verticalLegend=True,
                    roomLeftToLegend=0,
                    roomBelowLegend=50,
                    legendShortSide=10,
                    legendLongSide=150,
                    interpolate=True,
                    selected=False,
                    tile=None,
                    ):

    if ramp is None or len(ramp) == 0:
        return

    if tile is not None and selected is True:
        selected = False

    # deducted values
    if verticalLegend is True:
        lRoomToLegendCloseLongSide = roomLeftToLegend
        lRoomToLegendCloseShortSide = roomBelowLegend
        if legendShortSide < 1:
            legendShortSide = 1
        if legendLongSide < 1:
            legendLongSide = 1
    else:
        lRoomToLegendCloseLongSide = roomBelowLegend 
        lRoomToLegendCloseShortSide = roomLeftToLegend 
        if legendShortSide < 1:
            legendShortSide = 1
        if legendLongSide < 1:
            legendLongSide = 1

    lRoomToLegendFarLongSide = lRoomToLegendCloseLongSide + legendShortSide 

    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    if tile is None:
        GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
    else:
        GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    GL.glDisable( GL.GL_LIGHTING )

    GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
    GL.glDisable(GL.GL_DEPTH_TEST)
    GL.glDepthMask(GL.GL_FALSE)
    
    if len(ramp[0]) == 4: # there are alpha values, draw checkered bg
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
        #draw a bunch of quads as background
        lCheckerSquareSize = legendShortSide * .5
        if lCheckerSquareSize != 0:
            nbquads = int(legendLongSide / lCheckerSquareSize)
        else:
            nbquads = 1
        c1 = ( 0.1, 0.1, 0.1 )
        c2 = ( 0.3, 0.3, 0.3 )
        c = c1
        x2 = None
        for i in range(nbquads+1):
            GL.glColor3fv(c)
            if i==nbquads and nbquads != 0:
                x1=x2
                x2=legendLongSide
            else:
                x1 = i*lCheckerSquareSize
                x2 = min (x1+lCheckerSquareSize, legendLongSide)

            GL.glBegin(GL.GL_QUADS)
            if verticalLegend is True:
                GL.glVertex2f(float(lRoomToLegendCloseLongSide),
                              float(lRoomToLegendCloseShortSide + x1))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize), 
                              float(lRoomToLegendCloseShortSide + x1))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize), 
                              float(lRoomToLegendCloseShortSide + x2))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide), 
                              float(lRoomToLegendCloseShortSide + x2))
            else:
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
                              float(lRoomToLegendCloseLongSide))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
                              float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
                              float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
                              float(lRoomToLegendCloseLongSide))
            GL.glEnd()
    
            if c==c1:
                c=c2
            else:
#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:103,代码来源:Legend.py

示例3: drawLegendLabelName

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glBlendFunc [as 别名]

#.........这里部分代码省略.........
        else:
            lPt1 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
                    -fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
                    0)
            lPt2 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
                    -fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
                    0)
            lPt3 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
                    lRoomToLegendFarLongSide,0)
            lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
                    lRoomToLegendFarLongSide,0)

    if selected is True:
        labelColor2 = (.5, .5, .5)
    else:
        labelColor2 = labelColor

    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    if tile is None:
        GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
    else:
        GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    GL.glDisable( GL.GL_LIGHTING )

    GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL )
    
    if len(backgroundColor) == 4:
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

    #because of an unexplained bug on michel's laptop,
    #we don't draw the background when there is no frame 
    #(so michel has a way to manage the legend)
    if frame is True:
        #draw transparent background
        GL.glDepthMask(GL.GL_FALSE) 
        if len(backgroundColor) == 3:
            GL.glColor3fv(backgroundColor)
        else:
            GL.glColor4fv(backgroundColor)           
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3fv(lPt1)
        GL.glVertex3fv(lPt2)
        GL.glVertex3fv(lPt3)
        GL.glVertex3fv(lPt4)
        GL.glEnd()
        GL.glDepthMask(GL.GL_TRUE) 

    #draw frame
    if frame is True:
        GL.glPolygonMode(GL.GL_FRONT, GL.GL_LINE )
        GL.glLineWidth(1)
        GL.glColor3fv(labelColor2)    
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3fv(lPt1)
        GL.glVertex3fv(lPt2)
        GL.glVertex3fv(lPt3)
        GL.glVertex3fv(lPt4)
        GL.glEnd()
        GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
    
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:69,代码来源:Legend.py


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