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


Python GL.glEnd方法代码示例

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


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

示例1: draw_box

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

示例2: drawPlane

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def drawPlane(num_divs=200, div_size=10):
        # Plane parallel to x-z at origin with normal -y
        minx = -num_divs*div_size
        minz = -num_divs*div_size
        maxx = num_divs*div_size
        maxz = num_divs*div_size
        #gl.glLineWidth(2)
        #gl.glColor3f(0.7,0.7,1.0)
        gl.glColor3f(0.7,0.7,0.7)
        gl.glBegin(gl.GL_LINES)
        for n in range(2*num_divs):
            gl.glVertex3f(minx+div_size*n,0,minz)
            gl.glVertex3f(minx+div_size*n,0,maxz)
            gl.glVertex3f(minx,0,minz+div_size*n)
            gl.glVertex3f(maxx,0,minz+div_size*n)
        gl.glEnd() 
开发者ID:luigifreda,项目名称:pyslam,代码行数:18,代码来源:viewer3D.py

示例3: drawConditionalLines

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

示例4: __init__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def __init__(self, obj_info, rotation_matrix, swapyz=False, layout_type=None):
        """Loads a Wavefront OBJ file. """
        self.vertices = obj_info.vertices
        self.normals = obj_info.normals
        self.texcoords = obj_info.texcoords
        self.faces = obj_info.faces
        self.rotation_matrix = rotation_matrix

        # load the mesh to OPENGL
        self.gl_list = GL.glGenLists(1)
        GL.glNewList(self.gl_list, GL.GL_COMPILE)
        for face in self.faces:
            vertices, normals, _, _ = face
            GL.glBegin(GL.GL_POLYGON)
            for i in range(len(vertices)):
                normal_color = self.rotation_matrix.dot(self.normals[normals[i] - 1])
                GL.glColor3f((normal_color[0] + 1) / 2, (-normal_color[2] + 1) / 2, (normal_color[1] + 1) / 2)
                GL.glVertex3fv(self.vertices[vertices[i] - 1])
            GL.glEnd()
        GL.glEndList() 
开发者ID:thusiyuan,项目名称:holistic_scene_parsing,代码行数:22,代码来源:render_scene.py

示例5: plane_xy

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def plane_xy (self, center_x,center_y, center_z, size_x, size_y,color) :
        GL.glBegin(GL.GL_QUADS)
        self.qglColor(color)

        px = center_x+size_x/2
        mx =center_x-size_x/2
        py = center_y+size_y/2
        my =center_y-size_y/2

        GL.glVertex3d(px,py, center_z)
        GL.glVertex3d(mx,py, center_z)
        GL.glVertex3d(mx,my, center_z)
        GL.glVertex3d(px,my, center_z)

        GL.glEnd() 
开发者ID:simnibs,项目名称:simnibs,代码行数:17,代码来源:electrodeGUI.py

示例6: ellipse_xy

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def ellipse_xy (self, center_x, center_y, center_z, x_axis, y_axis, color):
        Pi = 3.14159265358979323846
        nbr_sides = 100

        GL.glBegin(GL.GL_POLYGON)
        self.qglColor(color)
        for i in range(nbr_sides):
             angle1 = (i * 2 * Pi) / nbr_sides
             x1 = center_x + x_axis/2 * math.sin(angle1)
             y1 = center_y + y_axis/2 * math.cos(angle1)
             GL.glVertex3d(x1, y1, center_z)
        GL.glEnd() 
开发者ID:simnibs,项目名称:simnibs,代码行数:14,代码来源:electrodeGUI.py

示例7: ellipse

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def ellipse(self, center, normal, u, v, dimensions):
        dim_x = dimensions[0]
        dim_y = dimensions[1]
        GL.glBegin(GL.GL_POLYGON)
        Pi = 3.14159265358979323846
        nbr_sides = 20
        GL.glNormal3f(normal[0],normal[1],normal[2])
        for i in range(nbr_sides):
            angle = (i * 2 * Pi) / nbr_sides
            vect = center+normal+( dim_x/2)*u*math.sin(angle)+ \
                +( dim_y/2)*v*math.cos(angle)
            GL.glVertex3d(vect[0], vect[1], vect[2])

        GL.glEnd() 
开发者ID:simnibs,项目名称:simnibs,代码行数:16,代码来源:head_model_OGL.py

示例8: rectangle

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def rectangle(self, center, normal, x_axis, y_axis, dimensions):
        GL.glBegin(GL.GL_QUADS)
        GL.glNormal3f(normal[0],normal[1],normal[2])
        x_dim = dimensions[0]/2.0
        y_dim = dimensions[1]/2.0
        v1 = center+normal+x_dim*x_axis+y_dim*y_axis
        v2 = center+normal+x_dim*x_axis-y_dim*y_axis
        v3 = center+normal-x_dim*x_axis-y_dim*y_axis
        v4 = center+normal-x_dim*x_axis+y_dim*y_axis
        GL.glVertex3d(v1[0], v1[1], v1[2])
        GL.glVertex3d(v2[0], v2[1], v2[2])
        GL.glVertex3d(v3[0], v3[1], v3[2])
        GL.glVertex3d(v4[0], v4[1], v4[2])
        GL.glEnd() 
开发者ID:simnibs,项目名称:simnibs,代码行数:16,代码来源:head_model_OGL.py

示例9: glBegin

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

示例10: drawPlane

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def drawPlane(ndivs=100, ndivsize=1):
    # Plane parallel to x-z at origin with normal -y
    minx = -ndivs*ndivsize
    minz = -ndivs*ndivsize
    maxx = ndivs*ndivsize
    maxz = ndivs*ndivsize
    gl.glLineWidth(1)
    gl.glColor3f(0.7,0.7,1.0)
    gl.glBegin(gl.GL_LINES)
    for n in range(2*ndivs):
        gl.glVertex3f(minx+ndivsize*n,0,minz)
        gl.glVertex3f(minx+ndivsize*n,0,maxz)
        gl.glVertex3f(minx,0,minz+ndivsize*n)
        gl.glVertex3f(maxx,0,minz+ndivsize*n)
    gl.glEnd() 
开发者ID:luigifreda,项目名称:pyslam,代码行数:17,代码来源:simpleDraw.py

示例11: drawGLBoundingBox

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

示例12: cuboid

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def cuboid(self, center_x, center_y,center_z, size_x, size_y, size_z, color, wireframe):

        if wireframe :
            GL.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE ) 

        GL.glBegin(GL.GL_QUADS)
        self.qglColor(color)

        px = center_x+size_x/2
        mx =center_x-size_x/2
        py = center_y+size_y/2
        my =center_y-size_y/2
        pz = center_z+size_z/2
        mz =center_z-size_z/2


        GL.glVertex3d(px,py, pz)
        GL.glVertex3d(px,my, pz)
        GL.glVertex3d(mx,my, pz)
        GL.glVertex3d(mx,py, pz)

        GL.glVertex3d(px,py, mz)
        GL.glVertex3d(mx,py, mz)
        GL.glVertex3d(mx,my, mz)
        GL.glVertex3d(px,my, mz)

        self.qglColor(color.darker(250))

        GL.glVertex3d(px,py, pz)
        GL.glVertex3d(mx,py, pz)
        GL.glVertex3d(mx,py, mz)
        GL.glVertex3d(px,py, mz)

        GL.glVertex3d(px,my, pz)
        GL.glVertex3d(mx,my, pz)
        GL.glVertex3d(mx,my, mz)
        GL.glVertex3d(px,my, mz)
        
        GL.glVertex3d(px,py, pz)
        GL.glVertex3d(px,my, pz)
        GL.glVertex3d(px,my, mz)
        GL.glVertex3d(px,py, mz)

        GL.glVertex3d(mx,py, pz)
        GL.glVertex3d(mx,my, pz)
        GL.glVertex3d(mx,my, mz)
        GL.glVertex3d(mx,py, mz)


        GL.glEnd()
        if wireframe:
            GL.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL ); 
开发者ID:simnibs,项目名称:simnibs,代码行数:54,代码来源:electrodeGUI.py

示例13: paintGL

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

示例14: create_axes_list

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def create_axes_list(self):
        '''Creates display lists to render unit length x,y,z axes.'''
        import OpenGL.GL as gl
        gl.glNewList(self.gllist_id, gl.GL_COMPILE)
        gl.glBegin(gl.GL_LINES)
        gl.glColor3f(1.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(1.0, 0.0, 0.0)
        gl.glColor3f(0.0, 1.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 1.0, 0.0)
        gl.glColor3f(-.0, 0.0, 1.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 1.0)

        gl.glColor3f(1.0, 1.0, 1.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(-1.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, -1.0, 0.0)
        gl.glVertex3f(0.0, 0.0, 0.0)
        gl.glVertex3f(0.0, 0.0, -1.0)
        gl.glEnd()

        def label_axis(x, y, z, label):
            gl.glRasterPos3f(x, y, z)
            glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_18,
                                  str(label))
        def label_axis_for_feature(x, y, z, feature_ind):
            feature = self.octant_features[feature_ind[0]][feature_ind[1]]
            label_axis(x, y, z, self.labels[feature])

        if self._have_glut:
            try:
                import OpenGL.GLUT as glut
                if bool(glut.glutBitmapString):
                    if self.quadrant_mode == 'independent':
                        label_axis(1.05, 0.0, 0.0, 'x')
                        label_axis(0.0, 1.05, 0.0, 'y')
                        label_axis(0.0, 0.0, 1.05, 'z')
                    elif self.quadrant_mode == 'mirrored':
                        label_axis_for_feature(1.05, 0.0, 0.0, (0, 0))
                        label_axis_for_feature(0.0, 1.05, 0.0, (0, 1))
                        label_axis_for_feature(0.0, 0.0, 1.05, (0, 2))
                        label_axis_for_feature(-1.05, 0.0, 0.0, (6, 0))
                        label_axis_for_feature(0.0, -1.05, 0.0, (6, 1))
                        label_axis_for_feature(0.0, 0.0, -1.05, (6, 2))
                    else:
                        label_axis_for_feature(1.05, 0.0, 0.0, (0, 0))
                        label_axis_for_feature(0.0, 1.05, 0.0, (0, 1))
                        label_axis_for_feature(0.0, 0.0, 1.05, (0, 2))
            except:
                pass
        gl.glEndList() 
开发者ID:spectralpython,项目名称:spectral,代码行数:56,代码来源:ndwindow.py

示例15: makeObject

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnd [as 别名]
def makeObject(self):
        genList = GL.glGenLists(1)
        GL.glNewList(genList, GL.GL_COMPILE)

        GL.glBegin(GL.GL_QUADS)

        x1 = +0.06
        y1 = -0.14
        x2 = +0.14
        y2 = -0.06
        x3 = +0.08
        y3 = +0.00
        x4 = +0.30
        y4 = +0.22

        self.quad(x1, y1, x2, y2, y2, x2, y1, x1)
        self.quad(x3, y3, x4, y4, y4, x4, y3, x3)

        self.extrude(x1, y1, x2, y2)
        self.extrude(x2, y2, y2, x2)
        self.extrude(y2, x2, y1, x1)
        self.extrude(y1, x1, x1, y1)
        self.extrude(x3, y3, x4, y4)
        self.extrude(x4, y4, y4, x4)
        self.extrude(y4, x4, y3, x3)

        Pi = 3.14159265358979323846
        NumSectors = 200

        for i in range(NumSectors):
            angle1 = (i * 2 * Pi) / NumSectors
            x5 = 0.30 * math.sin(angle1)
            y5 = 0.30 * math.cos(angle1)
            x6 = 0.20 * math.sin(angle1)
            y6 = 0.20 * math.cos(angle1)

            angle2 = ((i + 1) * 2 * Pi) / NumSectors
            x7 = 0.20 * math.sin(angle2)
            y7 = 0.20 * math.cos(angle2)
            x8 = 0.30 * math.sin(angle2)
            y8 = 0.30 * math.cos(angle2)

            self.quad(x5, y5, x6, y6, x7, y7, x8, y8)

            self.extrude(x6, y6, x7, y7)
            self.extrude(x8, y8, x5, y5)

        GL.glEnd()
        GL.glEndList()

        return genList 
开发者ID:dragondjf,项目名称:PFramer,代码行数:53,代码来源:opengl_test.py


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