本文整理汇总了Python中opengltk.OpenGL.GL.glRasterPos2f方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glRasterPos2f方法的具体用法?Python GL.glRasterPos2f怎么用?Python GL.glRasterPos2f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glRasterPos2f方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRasterPos2f [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