本文整理汇总了Python中opengltk.OpenGL.GL.glStencilFunc方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glStencilFunc方法的具体用法?Python GL.glStencilFunc怎么用?Python GL.glStencilFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glStencilFunc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cyldrawWithSharpColorBoundaries
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glStencilFunc [as 别名]
def cyldrawWithSharpColorBoundaries(self,
x, y, radx, rady,
colxf=None, colxb=None,
colyf=None, colyb=None, face=None,
highlightX=0, highlightY=0):
# 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)
sz2 = sz * .5
valueCos = (y[2]-x[2])/sz
valueCos = min(valueCos, 1)
valueCos = max(valueCos, -1)
rx = -180.0*math.acos(valueCos)/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.)
if colyf:
for m in (0,1,2,3,4):
if colyf[m] is not None:
glMaterialWithCheck( face, viewerConst.propConst[m],
colyf[m], check=self.checkMat)
if colyf[1] is not None:
GL.glColor4fv(colyf[1])
if colyb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colyb[m] is not None:
self.checkMat = 0
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colyb[m], check=self.checkMat)
# this tests (colxf==colyf)
self.checkMat = 1
idem = (highlightX == highlightY)
if idem is True:
if colxf is None:
if colyf is not None:
idem = False
else:
if colyf is None:
idem = False
else:
lencol = len(colxf)
if lencol != len(colyf):
idem = False
else:
for i in range(lencol):
if colxf[i] is not None:
if bool(numpy.alltrue(colxf[i] == colyf[i])) is False:
idem = False
break
if idem is True:
if colxb is None:
if colyb is not None:
idem = False
else:
if colyb is None:
idem = False
else:
lencol = len(colxb)
if lencol != len(colyb):
idem = False
else:
for i in range(lencol):
if colxb[i] is not None:
if bool(numpy.alltrue(colxb[i] == colyb[i])) is False:
idem = False
break
quality = self.quality * 5
if idem is True:
if highlightX != 0:
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
solidCylinder(float(rady), float(radx), sz, quality, 1, self.invertNormals)
GL.glStencilFunc(GL.GL_ALWAYS, 0, 1)
else:
solidCylinder(float(rady), float(radx), sz, quality, 1, self.invertNormals)
else:
midRadius = (radx + rady) * .5
if highlightX != 0:
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
solidCylinder(midRadius, float(radx), sz2, quality, 1, self.invertNormals)
GL.glStencilFunc(GL.GL_ALWAYS, 0, 1)
else:
#.........这里部分代码省略.........
示例2: drawVertexArray
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glStencilFunc [as 别名]
def drawVertexArray(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
""" drawVertexArray
"""
#print "drawVertexArray", self.name
if hasattr(self, 'faceSet') and len(self.faceSet.faces.array) > 0:
# vertices
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
# normals
if len(self.vertexSet.normals.array) > 0:
GL.glEnableClientState(GL.GL_NORMAL_ARRAY)
# colors
if hasattr(self, 'colorPointerIsOn') and self.colorPointerIsOn is True:
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
from DejaVu import preventIntelBug_WhiteTriangles
if preventIntelBug_WhiteTriangles:
GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE)
else:
GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE)
GL.glEnable( GL.GL_COLOR_MATERIAL )
if DejaVu.enableVBO is True:
from opengltk.extent import _glextlib
# vertices
_glextlib.glBindBufferARB(_glextlib.GL_ARRAY_BUFFER_ARB,
int(self.vertexArrayFlagBufferList[0]))
_gllib.glVertexPointer(len(self.vertexSet.vertices.array[0]),
GL.GL_FLOAT, 0, 0)
# normals
if len(self.vertexSet.normals.array) > 0:
_glextlib.glBindBufferARB(_glextlib.GL_ARRAY_BUFFER_ARB,
int(self.vertexArrayFlagBufferList[1]))
_gllib.glNormalPointer(GL.GL_FLOAT, 0, 0)
# colors
if hasattr(self, 'colorPointerIsOn') and self.colorPointerIsOn is True:
_glextlib.glBindBufferARB(_glextlib.GL_ARRAY_BUFFER_ARB,
int(self.vertexArrayFlagBufferList[3]))
_gllib.glColorPointer(4, GL.GL_FLOAT, 0, 0)
else:
# vertices
_gllib.glVertexPointer(len(self.vertexSet.vertices.array[0]),
GL.GL_FLOAT, 0, self.vertexSet.vertices.array)
# normals
if len(self.vertexSet.normals.array) > 0:
_gllib.glNormalPointer(GL.GL_FLOAT, 0, self.vertexSet.normals.array)
# colors
if hasattr(self, 'colorPointerIsOn') and self.colorPointerIsOn is True:
_gllib.glColorPointer(4, GL.GL_FLOAT, 0, self.colorArray)
# Draw faces
if self.primitiveType == GL.GL_LINE_STRIP:
lPrimitiveType = GL.GL_LINES
elif self.primitiveType == GL.GL_TRIANGLES:
#print "triangles' length:", len(self.faceSet.faces.array[0])
lPrimitiveType = GL.GL_TRIANGLES
elif self.primitiveType == GL.GL_QUADS:
#print "quads' length:", len(self.faceSet.faces.array[0])
lPrimitiveType = GL.GL_QUADS
else:
#print "what's that ?" , self.primitiveType
lPrimitiveType = self.primitiveType
lNumOfNonHighlightedIndices = len(self.faceSet.faces.array) - self.numOfHighlightedIndex
if DejaVu.enableVBO is True:
_glextlib.glBindBufferARB(_glextlib.GL_ELEMENT_ARRAY_BUFFER,
int(self.vertexArrayFlagBufferList[2])) #this protect from unexplained segfault
if self.disableStencil is False and self.numOfHighlightedIndex > 0:
# highlighted
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
_gllib.glDrawElements(lPrimitiveType,
self.numOfHighlightedIndex*len(self.faceSet.faces.array[0]),
GL.GL_UNSIGNED_INT,
0
)
GL.glStencilFunc(GL.GL_ALWAYS, 0, 1)
# non highlighted
_gllib.glDrawElements(lPrimitiveType,
lNumOfNonHighlightedIndices * len(self.faceSet.faces.array[0]),
GL.GL_UNSIGNED_INT,
self.numOfHighlightedIndex * len(self.faceSet.faces.array[0]) * 4
)
else:
_gllib.glDrawElements(lPrimitiveType,
len(self.faceSet.faces.array)*len(self.faceSet.faces.array[0]),
GL.GL_UNSIGNED_INT,
0
)
_glextlib.glBindBufferARB(_glextlib.GL_ELEMENT_ARRAY_BUFFER, 0 ) #this protect from unexplained segfault
else:
if self.disableStencil is False and self.numOfHighlightedIndex > 0:
# highlighted
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
_gllib.glDrawElements(lPrimitiveType,
self.numOfHighlightedIndex*len(self.faceSet.faces.array[0]),
GL.GL_UNSIGNED_INT,
self.faceSet.faces.array
#.........这里部分代码省略.........