本文整理汇总了Python中opengltk.OpenGL.GL.glEnd方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glEnd方法的具体用法?Python GL.glEnd怎么用?Python GL.glEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def redraw(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
self.tk.call(self._w, 'makecurrent')
GL.glDisable( GL.GL_DEPTH_TEST )
GL.glDisable( GL.GL_LIGHTING )
#GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
GL.glBegin(GL.GL_QUADS)
GL.glColor3f(0.,0.,0.)
GL.glVertex2f(0., 1.); GL.glVertex2f(0., 0.)
GL.glColor3f(float(self.rgbMax[0]),float(self.rgbMax[1]),float(self.rgbMax[2]))
GL.glVertex2f( 1., 0.); GL.glVertex2f( 1., 1.)
GL.glEnd()
GL.glEnable(GL.GL_COLOR_LOGIC_OP)
GL.glLogicOp(GL.GL_XOR)
GL.glLineWidth(2)
GL.glColor3f(.5,.5,.5)
GL.glBegin(GL.GL_LINES)
x1 = self.v-0.01
x2 = self.v+0.01
GL.glVertex2f(float(x1), 1.); GL.glVertex2f(float(x1), 0.)
GL.glVertex2f(float(x2), 0.); GL.glVertex2f(float(x2), 1.)
GL.glEnd()
GL.glDisable(GL.GL_COLOR_LOGIC_OP)
示例2: drawOneLine
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def drawOneLine(self, x1, y1, x2, y2):
GL.glBegin( GL.GL_LINES)
try:
GL.glVertex2f( x1, y1)
GL.glVertex2f( x2, y2)
finally:
GL.glEnd()
示例3: arcdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def arcdraw(self, x, n, radius, colxf=None):
# determine scale and rotation of template
import math
sz=0.0
y = [0, 0, 0]
for i in (0,1,2):
y[i] = x[i]+n[i]
for i in (0,1,2):
sz=sz+(x[i]-y[i])*(x[i]-y[i])
sz = sqrt(sz)
if sz==0.0:
return
rx = -180.0*acos((y[2]-x[2])/sz)/pi
rz = -180.0*atan2(y[0]-x[0],y[1]-x[1])/pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0:
GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
GL.glScalef(float(radius),float(radius),float(sz))
# draw circle
GL.glColor4fv(colxf)
GL.glBegin(GL.GL_LINE_STRIP)
for i in range(self.nsegments+1):
GL.glVertex3fv(self.v[i])
GL.glEnd()
GL.glPopMatrix()
示例4: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def Draw(self):
#print"Box.Draw"
self.oldFPM = self.frontPolyMode
if self.frontPolyMode == GL.GL_LINE:
GL.glDisable(GL.GL_LIGHTING)
#c is 8x3 array
c= self.vertexSet.vertices.array
#lines parallel to x-axis should be red, y->blue and z->green
col = ((1,0,0),(0,1,0),(0,0,1))
#these groups of 4 pairs of points define lines parallel to x, y, and z axes
alines=[[(c[0],c[1]),(c[2],c[3]),(c[4],c[5]),(c[6],c[7])],
[(c[0],c[3]),(c[1],c[2]),(c[4],c[7]),(c[5],c[6])],
[(c[0],c[4]),(c[1],c[5]),(c[3],c[7]),(c[2],c[6])]]
namectr=0
for i in range(3):
if not self.inheritMaterial:
GL.glColor3fv(col[i])
for vpairs in alines[i]:
GL.glPushName(namectr)
GL.glBegin(GL.GL_LINES)
GL.glVertex3dv(list(vpairs[0]))
GL.glVertex3dv(list(vpairs[1]))
GL.glEnd()
GL.glPopName()
namectr=namectr+1
self.viewer.enableOpenglLighting()
return 1
else:
return IndexedPolygons.Draw(self)
示例5: triangle
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def triangle(self):
GL.glBegin( GL.GL_TRIANGLES)
try:
GL.glColor3f( 1.0, 0.0, 0.0)
GL.glVertex2f( 5.0, 5.0)
GL.glColor3f( 0.0, 1.0, 0.0)
GL.glVertex2f( 25.0, 5.0)
GL.glColor3f( 0.0, 0.0, 1.0)
GL.glVertex2f( 5.0, 25.0)
finally:
GL.glEnd()
示例6: arrowdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def arrowdraw(self, x, y, colxf=None, colxb=None,
colyf=None, colyb=None,face=None):
# draw a cylinder going from x to y
# col for materials
# face can be GL_FRONT_AND_BACK or something else
# determine scale and rotation of template
import math
sz=0.0
for i in (0,1,2): sz=sz+(x[i]-y[i])*(x[i]-y[i])
if sz <= 0.0: return
sz = math.sqrt(sz)
rx = -180.0*math.acos((y[2]-x[2])/sz)/math.pi
dx = y[0]-x[0]
dy = y[1]-x[1]
if math.fabs(dx) < 0.00001 and math.fabs(dy) < 0.00001:
rz = 0.0
else:
rz = -180.0*math.atan2(dx,dy)/math.pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0: GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
# draw arrow
GL.glBegin(GL.GL_LINES)
if colxf:
for m in (0,1,2,3,4):
if colxf[m] is not None:
glMaterialWithCheck( face, viewerConst.propConst[m],
colxf[m] )
if colxb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colxb[m] is not None:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colxb[m] )
GL.glVertex3f(float(self.v[0][0]), float(self.v[0][1]), float(self.v[0][2]*sz))
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]), float(self.v[1][2]*sz))
for i in range(self.npoly):
h = i+2
vx = self.v[h]
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]),
float(self.v[1][2]*sz))
GL.glVertex3f(float(vx[0]*sz), float(vx[1]*sz), float(vx[2]*sz))
GL.glEnd()
GL.glPopMatrix()
示例7: drawpolygons
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def drawpolygons(self):
g = self.geom
vertices = g.getVertices()
faces = g.getFaces()
normals = g.getFNormals()
GL.glDisable(GL.GL_CULL_FACE)
for i,f in enumerate(faces):
GL.glBegin(GL.GL_POLYGON)
GL.glNormal3fv(normals[i])
for vi in f:
GL.glVertex3fv(vertices[vi])
GL.glEnd()
i+=1
示例8: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def Draw(self):
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
Insert2d.Draw(self)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_LIGHTING);
width = self.size[0]
height = self.size[1]
fullWidth = self.viewer.currentCamera.width
fullHeight = self.viewer.currentCamera.height
# we want the anchor of the image to be at the given position
posxFromLeft = self.position[0] * fullWidth - self.anchor[0] * width
posyFrombottom = (1.-self.position[1]) * fullHeight - (1.-self.anchor[1]) * height
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
GL.glColor4fv(self.color)
xo, yo = self.position
dx, dy = self.size
GL.glBegin(GL.GL_QUADS);
GL.glVertex2f(xo, yo)
GL.glVertex2f(xo+dx, yo)
GL.glVertex2f(xo+dx, yo+dy)
GL.glVertex2f(xo, yo+dy)
GL.glEnd()
# used for picking
# self.polygonContour = [ (posxFromLeft, posyFrombottom),
# (posxFromLeft+width, posyFrombottom),
# (posxFromLeft+width, posyFrombottom+height),
# (posxFromLeft, posyFrombottom+height)
# ]
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnable(GL.GL_LIGHTING);
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
return 1
示例9: test_0032
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def test_0032(self ):
import Tkinter
root = Tkinter.Tk()
vi = OGLTkWidget(root)
GL.glBegin( GL.GL_TRIANGLES)
GL.glColor3f( 1.0, 0.0, 0.0)
GL.glVertex2f( 5.0, 5.0)
GL.glColor3f( 0.0, 1.0, 0.0)
GL.glVertex2f( 25.0, 5.0)
GL.glColor3f( 0.0, 0.0, 1.0)
GL.glVertex2f( 5.0, 25.0)
GL.glEnd()
root.after(500, root.quit )
root.mainloop()
root.destroy()
示例10: display
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def display(self):
GL.glClear( GL.GL_COLOR_BUFFER_BIT)
# select white for all lines
GL.glColor3f( 1.0, 1.0, 1.0)
# in 1st row, 3 lines, each with a different stipple
GL.glEnable( GL.GL_LINE_STIPPLE)
GL.glLineStipple( 1, 0x0101) # dotted
self.drawOneLine( 50.0, 125.0, 150.0, 125.0)
GL.glLineStipple( 1, 0x00FF) # dashed
self.drawOneLine( 150.0, 125.0, 250.0, 125.0);
GL.glLineStipple( 1, 0x1C47) # dash/dot/dash
self.drawOneLine( 250.0, 125.0, 350.0, 125.0)
# in 2nd row, 3 wide lines, each with different stipple
GL.glLineWidth( 5.0)
GL.glLineStipple( 1, 0x0101) # dotted
self.drawOneLine( 50.0, 100.0, 150.0, 100.0)
GL.glLineStipple( 1, 0x00FF) # dashed
self.drawOneLine( 150.0, 100.0, 250.0, 100.0)
GL.glLineStipple( 1, 0x1C47) # dash/dot/dash
self.drawOneLine( 250.0, 100.0, 350.0, 100.0)
GL.glLineWidth( 1.0)
# in 3rd row, 6 lines, with dash/dot/dash stipple
# as part of a single connected line strip
GL.glLineStipple( 1, 0x1C47) # dash/dot/dash
GL.glBegin( GL.GL_LINE_STRIP)
try:
for i in range( 0, 7):
GL.glVertex2f( 50.0 + (i * 50.0), 75.0)
finally:
GL.glEnd()
# in 4th row, 6 independent lines with same stipple */
for i in range( 0, 6):
self.drawOneLine( 50.0 + (i * 50.0), 50.0, 50.0 + ((i+1) * 50.0), 50.0)
# in 5th row, 1 line, with dash/dot/dash stipple
# and a stipple repeat factor of 5
GL.glLineStipple( 5, 0x1C47) # dash/dot/dash
self.drawOneLine( 50.0, 25.0, 350.0, 25.0)
GL.glDisable( GL.GL_LINE_STIPPLE)
GL.glFlush()
示例11: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def pickDraw(self):
"""called by the picking process to operate the selection
"""
#print "colorMapLegend.pickDraw", self
# we draw just flat quad of the insert2d
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
#GL.glLoadIdentity()
GL.glLoadMatrixf(self.viewer.currentCamera.pickMatrix)
GL.glOrtho(0, float(self.viewer.currentCamera.width),
0, float(self.viewer.currentCamera.height), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
#GL.glColor3f(1,0,0)
if self.resizeSpot is not None:
GL.glPushName(1)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
float(self.resizeSpot[1]-self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
float(self.resizeSpot[1]+self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
float(self.resizeSpot[1]+self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
float(self.resizeSpot[1]-self.resizeSpotRadius))
GL.glEnd()
GL.glPopName()
GL.glPushName(0)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2fv(self.polygonContour[0])
GL.glVertex2fv(self.polygonContour[1])
GL.glVertex2fv(self.polygonContour[2])
GL.glVertex2fv(self.polygonContour[3])
GL.glEnd()
GL.glPopName()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
示例12: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def Draw(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
GL.glEnable(GL.GL_AUTO_NORMAL)
GL.glEnable(GL.GL_NORMALIZE)
if self.theNurb is None:
self.theNurb = GLU.gluNewNurbsRenderer()
GLU.gluNurbsProperty(self.theNurb, GLU.GLU_SAMPLING_TOLERANCE,
25.0)
GLU.gluNurbsProperty(self.theNurb, GLU.GLU_DISPLAY_MODE,
GLU.GLU_OUTLINE_POLYGON)
GLU.gluNurbsCallback(self.theNurb, GLU.GLU_ERROR, self.nurbsError)
GLU.gluBeginSurface(self.theNurb)
_glulib.gluNurbsSurface( self.theNurb,
8, self.knots,
8, self.knots,
4*3,
3,
self.ctlpoints,
4, 4,
GL.GL_MAP2_VERTEX_3)
GLU.gluEndSurface(self.theNurb)
GL.glPointSize(5.0)
GL.glDisable(GL.GL_LIGHTING)
GL.glColor3f(1.0, 1.0, 0.0)
GL.glBegin(GL.GL_POINTS)
for i in range(4):
for j in range(4):
GL.glVertex3fv(self.ctlpoints[i][j])
GL.glEnd()
GL.glDisable(GL.GL_AUTO_NORMAL)
GL.glDisable(GL.GL_NORMALIZE)
示例13: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def drawSticker(self, lLabelbounds):
if self.framePolygonMode != GL.GL_NONE:
lenFrameColor = len(self.frameColor)
if lenFrameColor == 4:
GL.glColor4fv(self.frameColor)
elif lenFrameColor == 3:
GL.glColor3fv(self.frameColor)
GL.glPolygonMode(GL.GL_FRONT, self.framePolygonMode)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(0, 0)
GL.glVertex2f(float(self.size[0]), 0)
GL.glVertex2f(float(self.size[0]), float(self.size[1]))
GL.glVertex2f(0, float(self.size[1]))
GL.glEnd()
GL.glScalef(float(self.fontScales[0]),
float(self.fontScales[1]),
0)
GL.glTranslatef(float(self.frameSpace[0]),
float(self.frameSpace[1]),
0)
# this corrects the glf draw function to start the label at the proper position
GL.glTranslatef(1, float(-lLabelbounds[1]), 0)
lenFontColor = len(self.fontColor)
if lenFontColor == 4:
GL.glColor4fv(self.fontColor)
elif lenFontColor == 3:
GL.glColor3fv(self.fontColor)
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
if self.wireFont in [0, False]:
glf.glfDrawSolidString(self.label)
else:
glf.glfDrawWiredString(self.label)
示例14: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
#.........这里部分代码省略.........
sE = self.stripEnd
self.sE = sE
self.sB= sB
for stripNum in range(len(sB)):
#print 'stripNum',stripNum
GL.glPushName(stripNum)
GL.glBegin(GL.GL_TRIANGLE_STRIP)
# per part material properties
if frontMat:
if frontMatBind[noCol] == PER_PART:
if self.isNewColor(c=frontMat[noCol][stripNum]):
GL.glColor4fv(frontMat[noCol][stripNum])
if n is not None:
if frontMat:
for j in range(5):
if frontMatBind[j]==PER_PART:
glMaterialWithCheck( face,
propConst[j],
frontMat[j][stripNum] )
if backMat and not self.frontAndBack:
for j in range(5):
if backMatBind[j] == PER_PART:
glMaterialWithCheck( GL.GL_BACK,
propConst[j],
backMat[j][stripNum] )
# loop over each vertex in a strip
i = 0
for ind in range(sB[stripNum],sE[stripNum]):
if ind >= len(vert):
print 'ERROR',ind
v = vert[ind]
# normals for flat or smooth shading
if n is not None:
if self.shading==GL.GL_FLAT:
if i > 1:
GL.glNormal3dv(n[sB[stripNum]+i-(2*(stripNum+1))])
elif self.shading==GL.GL_SMOOTH:
GL.glNormal3fv(n[ind])
else:
pass
# per face (per triangle) material properties
if n is None:
if frontMat:
if frontMatBind[noCol] == PER_FACE:
if i > 1:
if self.isNewColor(c=frontMat[noCol][sB[stripNum]+i-(2*(stripNum+1))]):
GL.glColor4fv(frontMat[noCol][sB[stripNum]+i-(2*(stripNum+1))])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_FACE:
if i > 1:
glMaterialWithCheck( face,
propConst[k],
frontMat[k][sB[stripNum]+i-(2*(stripNum+1))] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_FACE:
if i > 1 and i%2==0:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][sB[stripNum]+i-(2*(stripNum+1))] )
# per vertex material properties
if n is None:
if frontMat:
if frontMatBind[noCol] == PER_VERTEX:
if self.isNewColor(c=frontMat[noCol][sB[stripNum]+i]):
GL.glColor4fv(frontMat[noCol][sB[stripNum]+i])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_VERTEX:
glMaterialWithCheck( face,
propConst[k],
frontMat[k][sB[stripNum]+i] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_VERTEX:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][sB[stripNum]+i] )
# draw vertex
#GL.glVertex3dv(v)
gllib.glVertex3fv(v)
i = i + 1
GL.glEnd()
GL.glPopName()
return 1
示例15: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnd [as 别名]
def Draw(self):
c = self.vertexSet.vertices.array
if len(c)==0: return
GL.glDisable(GL.GL_LIGHTING)
if self.materials[GL.GL_FRONT]:
mat = self.materials[GL.GL_FRONT]
binding = self.materials[GL.GL_FRONT].binding[mat.diff]
else:
binding = viewerConst.OVERALL
if binding == viewerConst.INHERIT:
for i in xrange(c.shape[0]): #loop over lines
GL.glPushName(i)
GL.glBegin(self.primitiveType)
for v in c[i]:
#GL.glVertex3dv(v.tolist())
#gllib.glVertex3dv(v)
gllib.glVertex3fv(v)
GL.glEnd()
GL.glPopName()
elif binding == viewerConst.OVERALL:
if self.materials[GL.GL_FRONT]:
col = mat.prop[mat.diff][0]
GL.glColor4fv(col)
for i in xrange(c.shape[0]): #loop over lines
GL.glPushName(i)
GL.glBegin(self.primitiveType)
for v in c[i]:
#GL.glVertex3dv(v.tolist())
#gllib.glVertex3dv(v)
gllib.glVertex3fv(v)
GL.glEnd()
GL.glPopName()
elif binding == viewerConst.PER_VERTEX:
if self.materials[GL.GL_FRONT]:
col = mat.prop[mat.diff]
vi = 0
for i in xrange(c.shape[0]):
GL.glPushName(i)
GL.glBegin(self.primitiveType)
for v in c[i]:
GL.glColor4fv(col[vi])
vi = vi + 1
#GL.glVertex3dv(v.tolist())
#gllib.glVertex3dv(v)
gllib.glVertex3fv(v)
GL.glEnd()
GL.glPopName()
elif binding == viewerConst.PER_PART: # i.e. line
if self.materials[GL.GL_FRONT]:
col = mat.prop[mat.diff]
for i in xrange(c.shape[0]):
GL.glColor4fv(col[i])
GL.glPushName(i)
GL.glBegin(self.primitiveType)
for v in c[i]:
#GL.glVertex3dv(v.tolist())
#gllib.glVertex3dv(v)
gllib.glVertex3fv(v)
GL.glEnd()
GL.glPopName()
#glEnable(GL_LIGHTING)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
return True