當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。