本文整理汇总了Python中opengltk.OpenGL.GL.glCallList方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glCallList方法的具体用法?Python GL.glCallList怎么用?Python GL.glCallList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glCallList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def DisplayFunction(self):
""" display function. may be re-implemented by subclass
"""
#print "Common2d3dObject.DisplayFunction", self
if self.dpyList is not None:
currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag')
if currentcontext != self.dpyList[1]:
warnings.warn("""DisplayFunction failed because the current context is the wrong one""")
#print "currentcontext != self.dpyList[1]", currentcontext, self.dpyList[1]
else:
#print '#%d'%self.dpyList[0], currentcontext, "glCallList Common2d3d"
GL.glCallList(self.dpyList[0])
示例2: chooseTemplate
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def chooseTemplate(self):
GL.glNewList(self.templateDSPL[0], GL.GL_COMPILE)
#print '+%d'%self.templateDSPL[0], "glNewList Ellipsoids0"
if self.invertNormals:
#print "GLU_INSIDE reversed normals"
#print '#%d'%(self.templateDSPL[0]+2), "glCallList Ellipsoids2"
GL.glCallList(self.templateDSPL[0]+2)
else:
#print "GLU_OUTSIDE regular normals"
#print '#%d'%(self.templateDSPL[0]+1), "glCallList Ellipsoids1"
GL.glCallList(self.templateDSPL[0]+1)
#print '*%d'%GL.glGetIntegerv(GL.GL_LIST_INDEX), "glEndList Ellipsoids0"
GL.glEndList()
示例3: chooseTemplate
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def chooseTemplate(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
# make sure we are not already in a newlist
if GL.glGetIntegerv(GL.GL_LIST_INDEX) == [0]:
GL.glNewList(self.templateDSPL[0], GL.GL_COMPILE)
#print '+%d'%self.templateDSPL[0], "glNewList Spheres0"
if self.invertNormals:
#print "GLU_INSIDE reversed normals"
#print '#%d'%(self.templateDSPL[0]+2), "glCallList Spheres2"
GL.glCallList(self.templateDSPL[0]+2)
else:
#print "GLU_OUTSIDE regular normals"
#print '#%d'%(self.templateDSPL[0]+1), "glCallList Spheres1"
GL.glCallList(self.templateDSPL[0]+1)
#print '*%d'%GL.glGetIntegerv(GL.GL_LIST_INDEX), "glEndList Spheres0"
GL.glEndList()
示例4: render
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def render(self, mode='render'):
# call with mode='csg' to render simple shape to setup Zbuffer for CSG
# call with mode='render' to render by calling geom's draw function
if self.geom:
#import traceback
#print traceback.print_stack()
#print self.geom
#print "========================================================="
root = self.geom.viewer.rootObject
instance = [0]
p = self.geom.parent
while p:
instance.append(0)
p = p.parent
#mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
#print 'mat OK', mat
GL.glPushMatrix()
GL.glLoadIdentity()
self.geom.viewer.currentCamera.BuildTransformation()
self.geom.BuildMat(self.geom, root, True, instance)
#mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
#print 'mat PB', mat
#print 'render ', mode, self.geom
if mode=='csg':
if self.dpyListCSG is None:
self.redoDisplayListCSG()
GL.glCallList(self.dpyListCSG)
elif mode=='render':
obj = self.geom
if not obj.inheritMaterial:
obj.InitMaterial(0)
obj.InitColor(0)
obj.DisplayFunction()
GL.glPopMatrix()
示例5: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def Draw(self):
""" Draw function of the geom
return status 0 or 1
If you want fast rendering, you need to set self.templateDSPL
using MakeTemplate.
"""
#print "Ellipsoids.Draw"
assert self.templateDSPL is not None
currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag')
if currentcontext != self.templateDSPL[1]:
warnings.warn("""draw failed because the current context is the wrong one""")
#print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[1]
return 0
centers = self.vertexSet.vertices.array
if len(centers) == 0: return
scaling = self.scaling
orientation = self.orientation
vertices = self.vertexSet.vertices.array
if len(vertices) != len(scaling) or len(vertices) != len(orientation):
return
if self.inheritMaterial:
fp = None
bp = None
else:
fp = self.materials[GL.GL_FRONT]
if not self.frontAndBack:
bp = self.materials[GL.GL_BACK]
face = GL.GL_FRONT
else:
bp = None
face = GL.GL_FRONT_AND_BACK
for i in xrange(len(vertices)):
GL.glPushName(i)
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fp.prop[m][i] )
if bp:
for m in (0,1,2,3,4):
if bp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
bp.prop[m][i] )
GL.glPushMatrix()
GL.glTranslatef(float(vertices[i][0]),
float(vertices[i][1]),
float(vertices[i][2]))
GL.glMultMatrixf( orientation[i].ravel() )
GL.glScalef(float(scaling[i][0]),
float(scaling[i][1]),
float(scaling[i][2]))
#print '#%d'%self.templateDSPL[0], "glCallList Ellipsoids0"
GL.glCallList(self.templateDSPL[0])
GL.glPopMatrix()
GL.glPopName()
return True
示例6: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
def DisplayFunction(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""display a set of indexed geometric primitives"""
if self.dpyList:
# print "DisplayFunction", self.dpyList, self.fullName
lDrawOutline = (self.getDrawOutlineMode('front'), self.getDrawOutlineMode('back'))
if (lDrawOutline[0] or lDrawOutline[1]) and self.viewer.hasOffsetExt:
outl = self.outline
if self.GetPolyMode('front') == GL.GL_FILL \
or self.GetPolyMode('back') == GL.GL_FILL:
mode = GL.GL_POLYGON_OFFSET_FILL
GL.glEnable(mode)
self.viewer.polyOffset( outl.factor, outl.unit)
Geom.DisplayFunction(self)
GL.glDisable(mode)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
if not outl.colorAsMaterial:
if outl.lighting:
GL.glMaterialfv( GL.GL_FRONT_AND_BACK,
GL.GL_EMISSION,
outl.color )
else:
GL.glDisable(GL.GL_LIGHTING)
GL.glColor4fv (outl.color)
GL.glLineWidth(outl.lineWidth)
if lDrawOutline[0] is False or lDrawOutline[1] is False:
GL.glEnable(GL.GL_CULL_FACE)
if lDrawOutline[0]:
GL.glCullFace(GL.GL_BACK)
elif lDrawOutline[1]:
GL.glCullFace(GL.GL_FRONT)
else:
GL.glDisable(GL.GL_CULL_FACE)
if outl.dpyList:
currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag')
if currentcontext != outl.dpyList[1]:
warnings.warn("""DisplayFunction failed because the current context is the wrong one""")
#print "currentcontext != outl.dpyList[1]", currentcontext, outl.dpyList[1]
else:
#print '#%d'%outl.dpyList[0], currentcontext, "glCallList IndexedGeom"
GL.glCallList(outl.dpyList[0])
GL.glEnable(GL.GL_CULL_FACE)
GL.glEnable(GL.GL_LIGHTING)
else:
Geom.DisplayFunction(self)
else:
Geom.DisplayFunction(self)
示例7: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glCallList [as 别名]
#.........这里部分代码省略.........
if fp.binding[m] == viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fpProp[m][0])
if fp.binding[1] == viewerConst.OVERALL:
GL.glColor4fv(colorFront[0])
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fpProp[m][0])
if fp.binding[1] != viewerConst.OVERALL:
GL.glColor4fv(colorFront[0])
if bp:
for m in (0,1,2,3,4):
if bp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
bp.prop[m][0])
#print self.name
#if fp: print fp.prop[1], fp.binding
#else: print
if self.fastSpheres:
#print "self.fastSpheres", self.fastSpheres
if self.oneRadius == viewerConst.NO:
radii = self.vertexSet.radii.array
#FIXME: quick fix because can be called from base class Set
# method after centers have been set BUT before radii have been
# set
if len(self.vertexSet.vertices) != len(radii):
return 0
else:
radii = Numeric.ones( centers.shape[0] ) * self.radius
radii.shape = (-1,1)
coords = Numeric.concatenate ( (centers, radii), 1 )
## if not self.inheritMaterial:
## mat = self.materials[GL.GL_FRONT]
## fpProp = []
## for propInd in range(4):
## b, p = mat.GetProperty(propInd)
## fpProp.append(p)
## fpProp.append(mat.prop[4])
## #fpProp = self.materials[GL.GL_FRONT].prop[:5]
## else:
## fpProp = None
#print 'FUGU OVERWRITE COLOR', fpProp
#import numpy
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, numpy.array((.6,.6,.6,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, numpy.array((1.,1.,1.,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, numpy.array((.4,.4,.4,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, numpy.array((0,0,0,1), 'f'))
#GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 1.)
status = glDrawSphereSet(
self.templateDSPL[0],
coords.astype('f'),
fpProp, #self.materials[GL.GL_FRONT].prop,
highlight=self.highlight,
)
#print "Spheres, status: ", status
return status
else:
resetMaterialMemory()
#print "SLOW Spheres"
if self.oneRadius == viewerConst.NO:
radii = self.vertexSet.radii.array
else:
radii = Numeric.ones( centers.shape[0] ) * self.radius
if len(self.vertexSet.vertices) != len(radii):
return 0
for i in xrange(centers.shape[0]):
GL.glPushName(i)
GL.glPushMatrix()
GL.glTranslatef(float(centers[i][0]),
float(centers[i][1]),
float(centers[i][2]))
if not self.oneRadius:
GL.glScalef(float(radii[i]),float(radii[i]),float(radii[i]))
else:
GL.glScalef(float(self.radius), float(self.radius), float(self.radius))
#print '#%d'%self.templateDSPL[0], "glCallList Spheres0"
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fp.prop[m][0], geom=self)
GL.glCallList(self.templateDSPL[0])
GL.glPopMatrix()
GL.glPopName()
return 1