本文整理汇总了Python中opengltk.OpenGL.GL.glVertex2f方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glVertex2f方法的具体用法?Python GL.glVertex2f怎么用?Python GL.glVertex2f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glVertex2f方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawOneLine
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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()
示例2: display
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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()
示例3: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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
示例4: triangle
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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()
示例5: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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()
示例6: test_0032
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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()
示例7: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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)
示例8: drawLegendOnly
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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:
#.........这里部分代码省略.........
示例9: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [as 别名]
#.........这里部分代码省略.........
0)
GL.glScalef(float(fontScale), float(fontScale), 1);
glf.glfDrawSolidString(unit)
GL.glPopMatrix()
if mini is not None and maxi is not None:
i = 0
for v in lOnScreenLabelValues:
#calculate label position
lLabel = "%.*g" % (significantDigits,v)
lStep = (v - mini) * lUnitStep
GL.glPushMatrix()
if verticalLegend:
if leftOrBelowLabels:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale-lLabelsWidth[i]),
float(roomBelowLegend-(lLabelsHeight[i]/2+lLabelsMinAndMax[i][1])+lStep),
0)
else:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale),
float(roomBelowLegend-(lLabelsHeight[i]/2+lLabelsMinAndMax[i][1])+lStep),
0)
else:
GL.glTranslatef(
float(roomLeftToLegend-(lLabelsWidth[i]/2)+fontScale+lStep),
float(lRoomBelowLabel-lLabelsMinAndMax[i][1]),
0)
GL.glScalef(float(fontScale), float(fontScale), 1);
glf.glfDrawSolidString("%s" % lLabel)
GL.glPopMatrix()
i += 1
if len(backgroundColor) == 4:
GL.glDisable(GL.GL_BLEND)
# GL.glEnable(GL.GL_LIGHTING)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
drawLegendOnly(
fullWidth=fullWidth,
fullHeight=fullHeight,
ramp=ramp,
verticalLegend=verticalLegend,
roomLeftToLegend=roomLeftToLegend,
roomBelowLegend=roomBelowLegend,
legendShortSide=legendShortSide,
legendLongSide=legendLongSide,
interpolate=interpolate,
selected=selected,
tile=tile,
)
if selected is True:
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -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)
GL.glDisable(GL.GL_LIGHTING)
resizeSpot = []
if verticalLegend:
resizeSpot= [ roomLeftToLegend + legendShortSide,
roomBelowLegend + legendLongSide ]
else:
resizeSpot = [ roomLeftToLegend + legendLongSide,
roomBelowLegend + legendShortSide ]
GL.glColor3fv(labelColor)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(float(resizeSpot[0]+resizeSpotRadius),float(resizeSpot[1]-resizeSpotRadius))
GL.glVertex2f(float(resizeSpot[0]+resizeSpotRadius),float(resizeSpot[1]+resizeSpotRadius))
GL.glVertex2f(float(resizeSpot[0]-resizeSpotRadius),float(resizeSpot[1]+resizeSpotRadius))
GL.glVertex2f(float(resizeSpot[0]-resizeSpotRadius),float(resizeSpot[1]-resizeSpotRadius))
GL.glEnd()
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glDepthMask(GL.GL_TRUE)
# GL.glEnable(GL.GL_LIGHTING)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
else:
resizeSpot = None
return [(lPt1[0], lPt1[1]),
(lPt2[0], lPt2[1]),
(lPt3[0], lPt3[1]),
(lPt4[0], lPt4[1]) ] , resizeSpot , verticalLegend
示例10: redraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glVertex2f [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)