本文整理汇总了Python中opengltk.OpenGL.GL.glMatrixMode方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glMatrixMode方法的具体用法?Python GL.glMatrixMode怎么用?Python GL.glMatrixMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glMatrixMode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initProjection
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def initProjection(self):
GL.glMatrixMode (GL.GL_PROJECTION)
GL.glLoadIdentity ()
GL.glOrtho(-10., 10., -10., 10., -10., 10.)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glTranslatef(0, 0, 10.0)
示例2: initProjection
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def initProjection(self):
if self.imarray is None:
return
self.tk.call(self._w, 'makecurrent')
GL.glViewport(0, 0, self.width, self.height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glOrtho(0, float(self.width), 0, float(self.height), -1.0, 1.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
示例3: reshape
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def reshape(self, w, h):
GL.glViewport( 0, 0, w, h)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
if(w <= h):
GLU.gluOrtho2D( 0.0, 30.0, 0.0, 30.0 * h/w)
else:
GLU.gluOrtho2D( 0.0, 30.0 * w/h, 0.0, 30.0)
GL.glMatrixMode( GL.GL_MODELVIEW)
示例4: initProjection
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def initProjection(self):
""" guillaume: prepare the opengl matrices
for drawing the widget
(for instance the sliders in the case of the MaterialEditor)
"""
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
GL.glMatrixMode (GL.GL_PROJECTION)
GL.glLoadIdentity ()
GL.glOrtho(0., 1., 0., 1., -2.5, 2.5)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glTranslatef(0, 0, 2.0)
示例5: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def Draw(self):
#print "StickerImage.Draw", self
if self.image is None:
return
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
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
# this accept negative values were GL.glRasterPos2f(x,y) doesn't
GL.glRasterPos2f(0, 0)
_gllib.glBitmap(0, 0, 0, 0, posxFromLeft, posyFrombottom, 0)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
if self.image.mode == 'RGBA':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'RGB':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'L':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
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 glMatrixMode [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
示例7: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [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()
示例8: reshape
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def reshape(self, w, h):
GL.glViewport( 0, 0, w, h)
GL.glMatrixMode( GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glFrustum( -1.0, 1.0, -1.0, 1.0, 1.5, 20.0)
GL.glMatrixMode( GL.GL_MODELVIEW)
示例9: setup_viewport
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def setup_viewport(self):
GL.glMatrixMode( GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glOrtho( 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)
示例10: drawLegendOnly
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [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:
#.........这里部分代码省略.........
示例11: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
#.........这里部分代码省略.........
else:
if leftOrBelowLabels is False:
lPt1 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
lRoomToLegendCloseLongSide,0)
lPt2 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
lRoomToLegendCloseLongSide,0)
lPt3 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
fontScale+lRoomToLegendCloseLongSide \
+ legendShortSide \
+ lMaxLabelsHeight,
0)
lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
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)
示例12: reshape
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def reshape(self, w, h):
GL.glViewport( 0, 0, w, h)
GL.glMatrixMode( GL.GL_PROJECTION)
GL.glLoadIdentity()
GLU.gluOrtho2D( 0.0, w, 0.0, h)
示例13: beginTile
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
def beginTile(self):
if self.CurrentTile <= 0:
self.setup()
# Save user's viewport, will be restored after last tile rendered
self.ViewportSave = GL.glGetIntegerv(GL.GL_VIEWPORT)
# which tile (by row and column) we're about to render
if self.RowOrder==TR_BOTTOM_TO_TOP:
self.CurrentRow = self.CurrentTile / self.Columns
self.CurrentColumn = self.CurrentTile % self.Columns
elif self.RowOrder==TR_TOP_TO_BOTTOM:
self.CurrentRow = self.Rows - (self.CurrentTile / self.Columns) - 1
self.CurrentColumn = self.CurrentTile % self.Columns
else:
raise RuntimeError
assert(self.CurrentRow < self.Rows)
assert(self.CurrentColumn < self.Columns)
border = self.TileBorder
# Compute actual size of this tile with border
if self.CurrentRow < self.Rows-1:
tileHeight = self.TileHeight
else:
tileHeight = self.ImageHeight - (self.Rows-1) * \
(self.TileHeightNB) + 2 * border
if self.CurrentColumn < self.Columns-1:
tileWidth = self.TileWidth
else:
tileWidth = self.ImageWidth - (self.Columns-1) * \
(self.TileWidthNB) + 2 * border
# Save tile size, with border
self.CurrentTileWidth = tileWidth
self.CurrentTileHeight = tileHeight
GL.glViewport(0, 0, tileWidth, tileHeight) #tile size including border
# save current matrix mode
matrixMode = GL.glGetIntegerv(GL.GL_MATRIX_MODE)[0]
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
# compute projection parameters
self.tileleft = left = self.Left + (self.Right - self.Left) \
* (self.CurrentColumn * self.TileWidthNB - border) \
/ self.ImageWidth
self.tileright = right = left + (self.Right - self.Left) * \
self.TileWidth / self.ImageWidth
self.tilebottom = bottom = self.Bottom + (self.Top - self.Bottom) \
* (self.CurrentRow * self.TileHeightNB - border) / \
self.ImageHeight
self.tiletop = top = bottom + (self.Top - self.Bottom) * self.TileHeight / \
self.ImageHeight
if self.Perspective:
GL.glFrustum(float(left), float(right),
float(bottom), float(top),
float(self.Near), float(self.Far))
else:
GL.glOrtho(float(left), float(right),
float(bottom), float(top),
float(self.Near), float(self.Far))
# restore user's matrix mode
GL.glMatrixMode(int(matrixMode))
示例14:
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMatrixMode [as 别名]
### initialize glut
GLUT.glutInit (sys.argv)
GLUT.glutInitDisplayMode (GLUT.GLUT_DOUBLE | GLUT.GLUT_RGB | GLUT.GLUT_DEPTH)
GLUT.glutCreateWindow ("join styles")
GLUT.glutDisplayFunc (DrawStuff)
#GLUT.glutMotionFunc (MouseMotion)
# initialize GL
GL.glClearDepth (1.0)
GL.glEnable (GL.GL_DEPTH_TEST)
GL.glClearColor (0.0, 0.0, 0.0, 0.0)
GL.glShadeModel (GL.GL_SMOOTH)
GL.glMatrixMode (GL.GL_PROJECTION)
# roughly, measured in centimeters
GL.glFrustum (-9.0, 9.0, -9.0, 9.0, 50.0, 150.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
# initialize lighting
GL.glLightfv (GL.GL_LIGHT0, GL.GL_POSITION, lightOnePosition)
GL.glLightfv (GL.GL_LIGHT0, GL.GL_DIFFUSE, lightOneColor)
GL.glEnable (GL.GL_LIGHT0)
GL.glLightfv (GL.GL_LIGHT1, GL.GL_POSITION, lightTwoPosition)
GL.glLightfv (GL.GL_LIGHT1, GL.GL_DIFFUSE, lightTwoColor)
GL.glEnable (GL.GL_LIGHT1)
GL.glEnable (GL.GL_LIGHTING)
GL.glEnable (GL.GL_NORMALIZE)
GL.glColorMaterial (GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE)
GL.glEnable (GL.GL_COLOR_MATERIAL)