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


Python OpenGL.GL属性代码示例

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


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

示例1: setupGLState

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def setupGLState(self):
        """
        This method is responsible for preparing the GL state options needed to render 
        this item (blending, depth testing, etc). The method is called immediately before painting the item.
        """
        for k,v in self.__glOpts.items():
            if v is None:
                continue
            if isinstance(k, basestring):
                func = getattr(GL, k)
                func(*v)
            else:
                if v is True:
                    glEnable(k)
                else:
                    glDisable(k) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:18,代码来源:GLGraphicsItem.py

示例2: paintGL

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def paintGL(self, f=1.0):
        """ 
        Assumes a current GL context.  Assumes that context has been transformed so the
        view runs from (0,0) to page width & height with (0,0) in the bottom left corner.
        """

        if self.isDirty:
            self.resetPixmap()
            if self.nextCSIIsDirty:
                nextStep = self.parentItem().getNextStep()
                if nextStep:
                    nextStep.csi.isDirty = nextStep.csi.nextCSIIsDirty = True
                self.nextCSIIsDirty = False

        LicGLHelpers.pushAllGLMatrices()

        pos = self.mapToItem(self.getPage(), self.mapFromParent(self.pos()))
        dx = pos.x() + (self.rect().width() / 2.0) + self.center.x()
        dy = -self.getPage().PageSize.height() + pos.y() + (self.rect().height() / 2.0) + self.center.y()
        LicGLHelpers.rotateToView(CSI.defaultRotation, CSI.defaultScale * self.scaling * f, dx * f, dy * f, 0.0)
        LicGLHelpers.rotateView(*self.rotation)

        GL.glCallList(self.glDispID)
        LicGLHelpers.popAllGLMatrices() 
开发者ID:remig,项目名称:lic,代码行数:26,代码来源:LicModel.py

示例3: __init__

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def __init__(self, filename=None):

        self.name = self.filename = filename
        self.invertNext = False
        self.winding = GL.GL_CCW
        self.parts = []
        self.primitives = []
        self.glDispID = LicGLHelpers.UNINIT_GL_DISPID
        self.glEdgeDispID = LicGLHelpers.UNINIT_GL_DISPID
        self.isPrimitive = False  # primitive here means sub-part or part that's internal to another part
        self.isSubmodel = False
        self._boundingBox = None
        
        self.pliScale = 1.0
        self.pliRotation = [0.0, 0.0, 0.0]

        self.width = self.height = -1
        self.leftInset = self.bottomInset = -1
        self.center = QPointF() 
开发者ID:remig,项目名称:lic,代码行数:21,代码来源:LicModel.py

示例4: initSize

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def initSize(self, size, pBuffer, extraRotation=[0.0, 0.0, 0.0], extraScale=1.0):
        """
        Initialize this part's display width, height, empty corner insets and center point.
        To do this, draw this part to the already initialized GL buffer.
        These dimensions are required to properly lay out PLIs and CSIs.

        Parameters:
            size: Width & height of GL buffer to render to, in pixels.  Note that buffer is assumed square

        Returns:
            True if part rendered successfully.
            False if the part has been rendered partially or wholly out of frame.
        """

        #TODO: If a part is rendered at a size > 256, draw it smaller in the PLI
        # - this sounds like a great way to know when to shrink a PLI image...
        rotation = SubmodelPreview.defaultRotation if self.isSubmodel else PLI.defaultRotation
        scaling = SubmodelPreview.defaultScale if self.isSubmodel else PLI.defaultScale
        params = LicGLHelpers.initImgSize(size, self.glDispID, self.filename, scaling * extraScale, rotation, extraRotation)
        if params is None:
            return False

        self.width, self.height, self.center, self.leftInset, self.bottomInset = params
        return True 
开发者ID:remig,项目名称:lic,代码行数:26,代码来源:LicModel.py

示例5: drawConditionalLines

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

示例6: setGLOptions

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def setGLOptions(self, opts):
        """
        Set the OpenGL state options to use immediately before drawing this item.
        (Note that subclasses must call setupGLState before painting for this to work)
        
        The simplest way to invoke this method is to pass in the name of
        a predefined set of options (see the GLOptions variable):
        
        ============= ======================================================
        opaque        Enables depth testing and disables blending
        translucent   Enables depth testing and blending
                      Elements must be drawn sorted back-to-front for
                      translucency to work correctly.
        additive      Disables depth testing, enables blending.
                      Colors are added together, so sorting is not required.
        ============= ======================================================
        
        It is also possible to specify any arbitrary settings as a dictionary. 
        This may consist of {'functionName': (args...)} pairs where functionName must 
        be a callable attribute of OpenGL.GL, or {GL_STATE_VAR: bool} pairs 
        which will be interpreted as calls to glEnable or glDisable(GL_STATE_VAR).
        
        For example::
            
            {
                GL_ALPHA_TEST: True,
                GL_CULL_FACE: False,
                'glBlendFunc': (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),
            }
            
        
        """
        if isinstance(opts, basestring):
            opts = GLOptions[opts]
        self.__glOpts = opts.copy()
        self.update() 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:38,代码来源:GLGraphicsItem.py

示例7: setDepthValue

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def setDepthValue(self, value):
        """
        Sets the depth value of this item. Default is 0.
        This controls the order in which items are drawn--those with a greater depth value will be drawn later.
        Items with negative depth values are drawn before their parent.
        (This is analogous to QGraphicsItem.zValue)
        The depthValue does NOT affect the position of the item or the values it imparts to the GL depth buffer.
        """
        self.__depthValue = value 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:11,代码来源:GLGraphicsItem.py

示例8: initializeGL

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def initializeGL(self):
        """
        Called after an item is added to a GLViewWidget. 
        The widget's GL context is made current before this method is called.
        (So this would be an appropriate time to generate lists, upload textures, etc.)
        """
        pass 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:9,代码来源:GLGraphicsItem.py

示例9: getInterface

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def getInterface():
    try:
        import OpenGL
        import OpenGL.GL as gl
        import OpenGL.GLUT as glut

        # Doing 'from OpenGL.GL import *' does not import to 
        # this module's namespace, so go over the module's
        # __dict__ contents and add them to this module's
        # globals()

        globalDict = globals()
        for key in gl.__dict__:            
            if key not in globalDict:
                globalDict[key] = gl.__dict__[key]

        for key in glut.__dict__:
            if key not in globalDict:
                globalDict[key] = glut.__dict__[key]

        print('Done importing OpenGL.  A window should appear to show ' +
              'pixels and image frames')

    except RuntimeError as err:
        print('RuntimeError {0}: {1}'.format(err.errno. err.strerror))
        print('Could not import PyOpenGL.  Will not display pixels and frames')
        return None

    return ImageOpenGL() 
开发者ID:gregjames,项目名称:Sim2600,代码行数:31,代码来源:imageOpenGL.py

示例10: __callPreviousGLDisplayLists

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

示例11: createGLDisplayList

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def createGLDisplayList(self):
        """
        Create a display list that includes all previous CSIs plus this one,
        for a single display list giving a full model rendering up to this step.
        """

        if self.glDispID == LicGLHelpers.UNINIT_GL_DISPID:
            self.glDispID = GL.glGenLists(1)
        GL.glNewList(self.glDispID, GL.GL_COMPILE)
        # LicGLHelpers.drawCoordLines()
        self.__callPreviousGLDisplayLists(True)
        GL.glEndList() 
开发者ID:remig,项目名称:lic,代码行数:14,代码来源:LicModel.py

示例12: drawGLBoundingBox

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def drawGLBoundingBox(self):
        b = self.abstractPart.getBoundingBox()
        GL.glBegin(GL.GL_LINE_LOOP)
        GL.glVertex3f(b.x1, b.y1, b.z1)
        GL.glVertex3f(b.x2, b.y1, b.z1)
        GL.glVertex3f(b.x2, b.y2, b.z1)
        GL.glVertex3f(b.x1, b.y2, b.z1)
        GL.glEnd()

        GL.glBegin(GL.GL_LINE_LOOP)
        GL.glVertex3f(b.x1, b.y1, b.z2)
        GL.glVertex3f(b.x2, b.y1, b.z2)
        GL.glVertex3f(b.x2, b.y2, b.z2)
        GL.glVertex3f(b.x1, b.y2, b.z2)
        GL.glEnd()

        GL.glBegin(GL.GL_LINES)
        GL.glVertex3f(b.x1, b.y1, b.z1)
        GL.glVertex3f(b.x1, b.y1, b.z2)
        GL.glVertex3f(b.x1, b.y2, b.z1)
        GL.glVertex3f(b.x1, b.y2, b.z2)
        GL.glVertex3f(b.x2, b.y1, b.z1)
        GL.glVertex3f(b.x2, b.y1, b.z2)
        GL.glVertex3f(b.x2, b.y2, b.z1)
        GL.glVertex3f(b.x2, b.y2, b.z2)
        GL.glEnd() 
开发者ID:remig,项目名称:lic,代码行数:28,代码来源:LicModel.py

示例13: callGLDisplayList

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def callGLDisplayList(self, useDisplacement=False):
        if not useDisplacement:
            return

        # Must be called inside a glNewList/EndList pair
        if self.color is not None:
            color = list(self.color.rgba)
            if self.isSelected():
                color[3] *= 0.6
            GL.glPushAttrib(GL.GL_CURRENT_BIT)
            GL.glColor4fv(color)

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

        # LicGLHelpers.drawCoordLines()
        self.doGLRotation()

        if self.isSelected():
            self.drawGLBoundingBox()

        GL.glCallList(self.abstractPart.glDispID)
        GL.glPopMatrix()

        if self.color is not None:
            GL.glPopAttrib() 
开发者ID:remig,项目名称:lic,代码行数:33,代码来源:LicModel.py

示例14: getBoundingBox

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def getBoundingBox(self):
        if self._boundingBox:
            return self._boundingBox
        
        p = self.points
        box = BoundingBox(p[0], p[1], p[2])
        box.growByPoints(p[3], p[4], p[5])
        if self.type != GL.GL_LINES:
            box.growByPoints(p[6], p[7], p[8])
            if self.type == GL.GL_QUADS:
                box.growByPoints(p[9], p[10], p[11])
                
        self._boundingBox = box
        return box 
开发者ID:remig,项目名称:lic,代码行数:16,代码来源:LicModel.py

示例15: makeImageItem

# 需要导入模块: import OpenGL [as 别名]
# 或者: from OpenGL import GL [as 别名]
def makeImageItem(self, layout, size):
        gv = pyqtgraph.GraphicsView()
        if self.useOpenGL and GL:
            gv.useOpenGL()
        layout.addWidget(gv)
        vb = pyqtgraph.ViewBox()
        vb.setAspectLocked(True)
        vb.enableAutoRange(axis=pyqtgraph.ViewBox.XYAxes, enable=True)

        gv.setCentralItem(vb)
        img = pyqtgraph.ImageItem(border="w")
        vb.addItem(img)
        vb.setRange(QtCore.QRectF(0, 0, size, size))
        return img 
开发者ID:AOtools,项目名称:soapy,代码行数:16,代码来源:gui.py


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