本文整理汇总了Python中opengltk.OpenGL.GL.glEnable方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glEnable方法的具体用法?Python GL.glEnable怎么用?Python GL.glEnable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glEnable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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: _Enable
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def _Enable(self, side):
"""Activate the clipping plane"""
eqnt = self.eqn * side
#eqnt[3] = 0.0 - eqnt[3]
GL.glClipPlane(self.clipPlaneNames[self.num], eqnt)
GL.glEnable(self.clipPlaneNames[self.num])
示例3: getHistogram
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def getHistogram(self):
GL.glHistogram(GL.GL_HISTOGRAM, 256, GL.GL_RGB, GL.GL_FALSE)
GL.glEnable(GL.GL_HISTOGRAM)
self.redraw()
values = Numeric.zeros( (256,3), Numeric.UInt16)
#seg faults
GL.glGetHistogram(GL.GL_HISTOGRAM, GL.GL_TRUE, GL.GL_RGB,
GL.GL_UNSIGNED_SHORT, values)
return values
示例4: SetupGL
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def Draw(self):
#print "Sticker.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);
lLabelbounds = self.calculateSize()
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
posxFromLeft = int(floor( posxFromLeft ) )
posyFrombottom = int(floor( posyFrombottom ) )
if (self.position[1] == 0.):
posyFrombottom -= 1
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
GL.glTranslatef(float(posxFromLeft), float(posyFrombottom), 0)
self.drawSticker(lLabelbounds)
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
示例6: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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
示例7: display
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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()
示例8: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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);
示例9: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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)
示例10: redraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def redraw(self, event=None, filter=None):
if self.imarray is None:
return
if filter:
self.master.lift()
GL.glConvolutionFilter2D(GL.GL_CONVOLUTION_2D, GL.GL_LUMINANCE,
3, 3, GL.GL_LUMINANCE, GL.GL_FLOAT,
filter)
## GL.glConvolutionParameterfv(GL.GL_CONVOLUTION_2D,
## GL.GL_CONVOLUTION_FILTER_SCALE,
## (3., 3.,3.,3.))
## s= self.scale
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_RED_SCALE, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_BLUE_SCALE, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_GREEN_SCALE, s)
## s = self.bias
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_RED_BIAS, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_BLUE_BIAS, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_GREEN_BIAS, s)
## GL.GL_CONVOLUTION_FILTER_SCALE,
## (3., 3.,3.,3.))
## GL.glConvolutionParameteriv(GL.GL_CONVOLUTION_2D,
## GL.GL_CONVOLUTION_FILTER_BIAS,
## (1500, 1500, 1500, 1500))
GL.glEnable(GL.GL_CONVOLUTION_2D)
self.tk.call(self._w, 'makecurrent')
GL.glClearColor(0.0, 0.0, 0.0, 0.0)
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glRasterPos2i( 0, 0)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
if self.mode=='RGB':
_gllib.glDrawPixels( self.width, self.height,
GL.GL_RGB, GL.GL_UNSIGNED_BYTE, self.imarray)
elif self.mode in ['L','P']:
_gllib.glDrawPixels( self.width, self.height,
GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE,
self.imarray)
GL.glDisable(GL.GL_CONVOLUTION_2D)
示例11: _WidthAndStipple
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def _WidthAndStipple(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""Set the line or points width
"""
#print "_WidthAndStipple", self.stippleLines , self.inheritStippleLines , self
GL.glPointSize(self.getPointWidth())
GL.glLineWidth(self.getLineWidth())
if self.getStippleLines() in (True, 1):
GL.glEnable(GL.GL_LINE_STIPPLE)
ls = self.linestipple
GL.glLineStipple(ls.factor, ls.pattern)
else:
GL.glDisable(GL.GL_LINE_STIPPLE)
if self.getStipplePolygons() in (True, 1):
GL.glEnable(GL.GL_POLYGON_STIPPLE)
ps = self.polygonstipple
GL.glPolygonStipple(self.polygonstipple.pattern)
else:
GL.glDisable(GL.GL_POLYGON_STIPPLE)
示例12: extrude
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def extrude(self):
"""Virtual Method to do the extrusion along a 3D path with a 2D shape
using the gle extrusion. We then get the geometry information
using the extrusion method in Feedback mode. This will then be
used to build a triangle strip."""
from gle import glec
gle.gleSetJoinStyle ( self.joinStyle | self.normalStyle )
glec.gleFeedBack()
#DisplayFunction of the old GlePolyCylinder
GL.glColorMaterial (GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT)
GL.glEnable (GL.GL_COLOR_MATERIAL)
#glEnable(GL_LIGHTING)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
colors = self.materials[GL.GL_FRONT].prop[0][:,:3]
gle.glePolyCylinder(self.trace3D, colors, self.radius)
GL.glDisable (GL.GL_COLOR_MATERIAL)
glec.gleTextureMode(0)
v,n,s = glec.gleGetTriangleMesh()
return v,n,s
示例13: setupLightModel
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def setupLightModel(self):
"""
"""
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
# this method has to be called explicitly by the derived classes if
# a default lighting model is wanted
GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, [1.0, 1.0, 1.0, 0.0]);
GL.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, [.5, .5, .5, 1.0])
GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, [-1.0, 1.0, 1.0, 0.0]);
GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
#GL.glEnable(GL.GL_LIGHTING)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
GL.glEnable(GL.GL_LIGHT0)
GL.glEnable(GL.GL_LIGHT1)
示例14: setupLightModel
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [as 别名]
def setupLightModel(self):
# this method has to be called explicitly by the derived classes if
# a default lighting model is wanted
GL.glLight(GL.GL_LIGHT0, GL.GL_AMBIENT, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT0, GL.GL_DIFFUSE, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT0, GL.GL_SPECULAR, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT0, GL.GL_POSITION, [1.0, 1.0, 1.0, 0.0]);
GL.glLight(GL.GL_LIGHT1, GL.GL_AMBIENT, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT1, GL.GL_DIFFUSE, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT1, GL.GL_SPECULAR, [.5, .5, .5, 1.0])
GL.glLight(GL.GL_LIGHT1, GL.GL_POSITION, [-1.0, 1.0, 1.0, 0.0]);
GL.glLightModel(GL.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
GL.glEnable(GL.GL_LIGHTING)
GL.glEnable(GL.GL_LIGHT0)
GL.glEnable(GL.GL_LIGHT1)
示例15: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glEnable [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)