本文整理汇总了Python中opengltk.OpenGL.GL.glPolygonMode方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPolygonMode方法的具体用法?Python GL.glPolygonMode怎么用?Python GL.glPolygonMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glPolygonMode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [as 别名]
def Draw(self):
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glClear( GL.GL_STENCIL_BUFFER_BIT)
GL.glDisable(GL.GL_FOG)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
OpenCSG.render(self.primitives, self.algo, self.depthalgo)
GL.glDepthFunc(GL.GL_EQUAL)
# FIXME should only enable fog if it is on in camera
GL.glEnable(GL.GL_FOG)
self.SetupGL()
for p in self.pyprimitives:
p.render()
GL.glDepthFunc(GL.GL_LESS);
示例2: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [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()
示例3: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [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)
示例4: SetupGL
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [as 别名]
def SetupGL(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""Setup OpenGL rendering state for this object
"""
#print "SetupGL", self
if not self.inheritMaterial:
self.InitMaterial()
self.InitColor()
if self.GetLighting():
#glEnable(GL_LIGHTING)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
shading = self.GetShading()
if shading != GL.GL_NONE:
if self.normals is not None:
if (shading==GL.GL_SMOOTH and \
len(self.normals)!=len(self.vertexSet)) or \
(shading==GL.GL_FLAT and \
len(self.normals)!=len(self.faceSet)):
self.GetNormals()
self.viewer.objectsNeedingRedo[self] = None
GL.glShadeModel(shading)
else: # no lighting
GL.glDisable(GL.GL_LIGHTING)
if not self.inheritCulling:
if self.culling in (GL.GL_BACK, GL.GL_FRONT, GL.GL_FRONT_AND_BACK):
GL.glCullFace(self.culling)
GL.glEnable(GL.GL_CULL_FACE)
else: GL.glDisable(GL.GL_CULL_FACE)
if not self.inheritFrontPolyMode:
mode =self.frontPolyMode
if self.frontPolyMode==viewerConst.OUTLINED:
mode = GL.GL_FILL
if self.frontAndBack:
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, mode)
else:
GL.glPolygonMode(GL.GL_FRONT, mode)
if not self.inheritBackPolyMode:
mode = self.backPolyMode
if self.backPolyMode==viewerConst.OUTLINED:
mode = GL.GL_FILL
GL.glPolygonMode(GL.GL_BACK, mode)
#self._AntiAliasing()
self._WidthAndStipple()
示例5: drawLegendOnly
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [as 别名]
def drawLegendOnly(
fullWidth,
fullHeight,
ramp,
verticalLegend=True,
roomLeftToLegend=0,
roomBelowLegend=50,
legendShortSide=10,
legendLongSide=150,
interpolate=True,
selected=False,
tile=None,
):
if ramp is None or len(ramp) == 0:
return
if tile is not None and selected is True:
selected = False
# deducted values
if verticalLegend is True:
lRoomToLegendCloseLongSide = roomLeftToLegend
lRoomToLegendCloseShortSide = roomBelowLegend
if legendShortSide < 1:
legendShortSide = 1
if legendLongSide < 1:
legendLongSide = 1
else:
lRoomToLegendCloseLongSide = roomBelowLegend
lRoomToLegendCloseShortSide = roomLeftToLegend
if legendShortSide < 1:
legendShortSide = 1
if legendLongSide < 1:
legendLongSide = 1
lRoomToLegendFarLongSide = lRoomToLegendCloseLongSide + legendShortSide
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
if tile is None:
GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
else:
GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable( GL.GL_LIGHTING )
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDepthMask(GL.GL_FALSE)
if len(ramp[0]) == 4: # there are alpha values, draw checkered bg
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
#draw a bunch of quads as background
lCheckerSquareSize = legendShortSide * .5
if lCheckerSquareSize != 0:
nbquads = int(legendLongSide / lCheckerSquareSize)
else:
nbquads = 1
c1 = ( 0.1, 0.1, 0.1 )
c2 = ( 0.3, 0.3, 0.3 )
c = c1
x2 = None
for i in range(nbquads+1):
GL.glColor3fv(c)
if i==nbquads and nbquads != 0:
x1=x2
x2=legendLongSide
else:
x1 = i*lCheckerSquareSize
x2 = min (x1+lCheckerSquareSize, legendLongSide)
GL.glBegin(GL.GL_QUADS)
if verticalLegend is True:
GL.glVertex2f(float(lRoomToLegendCloseLongSide),
float(lRoomToLegendCloseShortSide + x1))
GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize),
float(lRoomToLegendCloseShortSide + x1))
GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize),
float(lRoomToLegendCloseShortSide + x2))
GL.glVertex2f(float(lRoomToLegendCloseLongSide),
float(lRoomToLegendCloseShortSide + x2))
else:
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
float(lRoomToLegendCloseLongSide))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
float(lRoomToLegendCloseLongSide))
GL.glEnd()
if c==c1:
c=c2
else:
#.........这里部分代码省略.........
示例6: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [as 别名]
#.........这里部分代码省略.........
fontScale+lRoomToLegendCloseLongSide \
+ legendShortSide \
+ lMaxLabelsHeight,
0)
else:
lPt1 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
-fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
0)
lPt2 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
-fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
0)
lPt3 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
lRoomToLegendFarLongSide,0)
lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
lRoomToLegendFarLongSide,0)
if selected is True:
labelColor2 = (.5, .5, .5)
else:
labelColor2 = labelColor
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
if tile is None:
GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
else:
GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable( GL.GL_LIGHTING )
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL )
if len(backgroundColor) == 4:
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
#because of an unexplained bug on michel's laptop,
#we don't draw the background when there is no frame
#(so michel has a way to manage the legend)
if frame is True:
#draw transparent background
GL.glDepthMask(GL.GL_FALSE)
if len(backgroundColor) == 3:
GL.glColor3fv(backgroundColor)
else:
GL.glColor4fv(backgroundColor)
GL.glBegin(GL.GL_QUADS)
GL.glVertex3fv(lPt1)
GL.glVertex3fv(lPt2)
GL.glVertex3fv(lPt3)
GL.glVertex3fv(lPt4)
GL.glEnd()
GL.glDepthMask(GL.GL_TRUE)
#draw frame
if frame is True:
GL.glPolygonMode(GL.GL_FRONT, GL.GL_LINE )
GL.glLineWidth(1)
GL.glColor3fv(labelColor2)
GL.glBegin(GL.GL_QUADS)
GL.glVertex3fv(lPt1)
GL.glVertex3fv(lPt2)
GL.glVertex3fv(lPt3)
示例7: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [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)
示例8: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPolygonMode [as 别名]
def DisplayFunction(self):
"""Draw a square with diagonals to represent the clipping plane
"""
#print "ClippingPlane.DisplayFunction"
#trans = self.eqn[3]*(self.eqn[:3]*self.n)
resetMaterialMemory()
trans = self.translation
GL.glPushMatrix()
#GL.glTranslatef(-trans[0],-trans[1],-trans[2])
GL.glTranslatef(float(trans[0]),
float(trans[1]),
float(trans[2]))
GL.glMultMatrixf(self.rotation)
GL.glScalef(float(self.scale[0]),
float(self.scale[1]),
float(self.scale[2]))
if self.polyMode == GL.GL_QUADS:
GL.glPushAttrib(GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT |
GL.GL_POLYGON_BIT)
GL.glDisable(GL.GL_LIGHTING)
GL.glMaterialWithCheck(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,
self.color)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
GL.glBegin (GL.GL_QUADS)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopAttrib()
else:
# MS disabling GL.GL_BLEND breaks display of transparent surfaces
## if self.antialiased==True:
## GL.glEnable(GL.GL_LINE_SMOOTH)
## GL.glEnable(GL.GL_BLEND)
## else:
## GL.glDisable(GL.GL_LINE_SMOOTH)
## GL.glDisable(GL.GL_BLEND)
GL.glColor4fv (self.color)
GL.glLineWidth(self.lineWidth)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
# could and should be a display list made once for all planes
GL.glBegin (GL.GL_LINE_STRIP)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopMatrix()