本文整理汇总了Python中OpenGL.GL.glPopMatrix方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPopMatrix方法的具体用法?Python GL.glPopMatrix怎么用?Python GL.glPopMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glPopMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_rgb_indexed_colors
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def render_rgb_indexed_colors(self, **kwargs):
'''Draws scene in the background buffer to extract mouse click info'''
import OpenGL.GL as gl
import OpenGL.GLU as glu
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# camera_pos_rtp is relative to the target position. To get the
# absolute camera position, we need to add the target position.
gl.glPushMatrix()
camera_pos_xyz = np.array(rtp_to_xyz(*self.camera_pos_rtp)) \
+ self.target_pos
glu.gluLookAt(
*(list(camera_pos_xyz) + list(self.target_pos) + self.up))
self.draw_data_set()
gl.glPopMatrix()
gl.glFlush()
示例2: freezeStatus
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def freezeStatus(string):
return
# GL.glColor(1.0, 0., 0., 1.0)
#
# # glDrawBuffer(GL.GL_FRONT)
# GL.glMatrixMode(GL.GL_PROJECTION)
# GL.glPushMatrix()
# glRasterPos(50, 100)
# for i in string:
# glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(i))
#
# # glDrawBuffer(GL.GL_BACK)
# GL.glMatrixMode(GL.GL_PROJECTION)
# GL.glPopMatrix()
# glFlush()
# display.flip()
# # while(True): pass
示例3: add_object_seg
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def add_object_seg(filename, xyz, unit, up_string, front_string, center, angle, size, segment_id, obj_info, layout_type=None):
GL.glPushMatrix()
x = xyz[0]
y = xyz[1]
z = xyz[2]
# translate in view
if layout_type is not None:
GL.glTranslatef(center[0], center[1], center[2])
else:
GL.glTranslatef(center[0], center[1], center[2] - size[2] / 2)
GL.glRotate(angle, 0, 1, 0)
GL.glScalef(size[0] * 100 / x, size[1] * 100 / y, size[2] * 100 / z)
# normalize directions, rotate object to front: front -> 0,0,1 | up -> 0,1,0
alignment = align_directions(up_string, front_string)
if not alignment:
GL.glPopMatrix()
return
# obj = OBJ_NORMAL(filename, swapyz=False)
obj = OBJ_SEG(obj_info['info'], color=[segment_id / 255.0, 0.0, 0.0], swapyz=False)
GL.glCallList(obj.gl_list)
GL.glPopMatrix()
# angle is the object rotation angle
示例4: on_paint
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def on_paint(self, event):
"""Process the drawing event."""
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.canvas.SetCurrent(self.canvas.context)
if not self.gl_initialized:
self.initgl()
self.gl_initialized = True
self.print_help()
if self.light:
gl.glEnable(gl.GL_LIGHTING)
else:
gl.glDisable(gl.GL_LIGHTING)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glLoadIdentity()
gl.glPushMatrix()
glu.gluLookAt(*(list(rtp_to_xyz(
*self.camera_pos_rtp)) + list(self.target_pos) + list(self.up)))
self.draw_cube()
gl.glPopMatrix()
gl.glFlush()
self.SwapBuffers()
event.Skip()
示例5: glPushMatrix
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def glPushMatrix(cls, matrixmode):
try:
GL.glMatrixMode(matrixmode)
GL.glPushMatrix()
yield
finally:
GL.glMatrixMode(matrixmode)
GL.glPopMatrix()
示例6: drawToolMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def drawToolMarkers(self):
if self.editor.currentTool != self:
return
if self.panel and self.replacing:
blockInfo = self.replaceBlockInfo
else:
blockInfo = self.blockInfo
color = 1.0, 1.0, 1.0, 0.35
if blockInfo:
terrainTexture = self.editor.level.materials.terrainTexture
tex = self.editor.level.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0] # xxx
tex = Texture(self.blockTexFunc(terrainTexture, tex))
# color = (1.5 - alpha, 1.0, 1.5 - alpha, alpha - 0.35)
GL.glMatrixMode(GL.GL_TEXTURE)
GL.glPushMatrix()
GL.glScale(16., 16., 16.)
else:
tex = None
# color = (1.0, 0.3, 0.3, alpha - 0.35)
GL.glPolygonOffset(DepthOffset.FillMarkers, DepthOffset.FillMarkers)
self.editor.drawConstructionCube(self.selectionBox(),
color,
texture=tex)
if blockInfo:
GL.glMatrixMode(GL.GL_TEXTURE)
GL.glPopMatrix()
示例7: callGLDisplayList
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def callGLDisplayList(self, useDisplacement=False):
if not useDisplacement:
return
# Must be called inside a glNewList/EndList pair
if self.color is not None:
color = list(self.color.rgba)
if self.isSelected():
color[3] *= 0.6
GL.glPushAttrib(GL.GL_CURRENT_BIT)
GL.glColor4fv(color)
matrix = list(self.matrix)
if self.displacement:
matrix[12] += self.displacement[0]
matrix[13] += self.displacement[1]
matrix[14] += self.displacement[2]
GL.glPushMatrix()
GL.glMultMatrixf(matrix)
# LicGLHelpers.drawCoordLines()
self.doGLRotation()
if self.isSelected():
self.drawGLBoundingBox()
GL.glCallList(self.abstractPart.glDispID)
GL.glPopMatrix()
if self.color is not None:
GL.glPopAttrib()
示例8: add_object_normal
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def add_object_normal(filename, xyz, unit, up_string, front_string, center, angle, size, beta, obj_info, layout_type=None):
GL.glPushMatrix()
x = xyz[0]
y = xyz[1]
z = xyz[2]
del rotation_matrix_list[:]
# translate in view
if layout_type is not None:
GL.glTranslatef(center[0], center[1], center[2])
else:
GL.glTranslatef(center[0], center[1], center[2] - size[2] / 2)
GL.glRotate(angle, 0, 1, 0)
rotation_matrix_list.append(rotation_matrix(angle, 0, 1, 0))
# scale object
GL.glScalef(size[0] * 100 / x, size[1] * 100 / y, size[2] * 100 / z)
# normalize directions, rotate object to front: front -> 0,0,1 | up -> 0,1,0
alignment = align_directions(up_string, front_string)
if not alignment:
GL.glPopMatrix()
return
rm = np.identity(3)
for i in range(len(rotation_matrix_list) - 1, -1, -1):
rm = rotation_matrix_list[i].dot(rm)
rm = rotation_matrix(beta, 1, 0, 0).dot(rm)
obj = OBJ_NORMAL(obj_info['info'], rotation_matrix=rm, swapyz=False, layout_type=layout_type)
GL.glCallList(obj.gl_list)
GL.glPopMatrix()
示例9: add_object
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def add_object(filename, xyz, unit, up_string, front_string, center, angle, size, obj_color, obj_info, layout_type=None): # x_min,y_min,z_min,x_max,y_max,z_max
GL.glPushMatrix()
# after unit conversion...
x = xyz[0]
y = xyz[1]
z = xyz[2]
# print center, size
# translate in view
if layout_type is not None:
GL.glTranslatef(center[0], center[1], center[2])
else:
GL.glTranslatef(center[0], center[1], center[2] - size[2] / 2)
GL.glRotate(angle, 0, 1, 0)
GL.glScalef(size[0] * 100 / x, size[1] * 100 / y, size[2] * 100 / z) # x,y,z y is up
# normalize directions, rotate object to front: front -> 0,0,1 | up -> 0,1,0
alignment = align_directions(up_string, front_string)
if not alignment:
GL.glPopMatrix()
return
# obj = OBJ_NORMAL(filename, swapyz=False)
obj = OBJ(obj_info['info'], obj_color=obj_color, swapyz=False)
GL.glCallList(obj.gl_list)
GL.glPopMatrix()
# read metadata info from csv file
示例10: drawPointAndDirs
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def drawPointAndDirs(self):
xAxis = numpy.array([1,0,0], 'float')
yAxis = numpy.array([0,1,0], 'float')
zAxis = numpy.array([0,0,1], 'float')
center =numpy.array([0,0,0], 'float')
qobj = GLU.gluNewQuadric()
sphere_radius = 0.1
cyl_height = 1
cyl_radius = 0.01
z_dir = numpy.array([0.,0.,1.], dtype = 'float64')
genList = GL.glGenLists(1)
GL.glNewList(genList, GL.GL_COMPILE)
#Cylinder along z, we want it to be allong xAxis
#Solution: use the appropriate rotation matrix
#We have to choose the right axis, perpendicular to both, and rotate by the appropriate angle, the angle between the 2 vectors
self.qglColor(QtGui.QColor.fromCmykF(0., 1., 1., 0.))
rotation_dir = numpy.cross(z_dir,xAxis)
angle = math.acos(z_dir.dot(xAxis))*180/3.14159
GL.glPushMatrix()
GL.glTranslatef(center[0],center[1],center[2])
GL.glRotatef(angle, rotation_dir[0],rotation_dir[1],rotation_dir[2])
GLU.gluCylinder(qobj,cyl_radius,cyl_radius,cyl_height,20,20)
GL.glPopMatrix()
self.qglColor(QtGui.QColor.fromCmykF(1., 0., 1., 0.))
rotation_dir = numpy.cross(z_dir,yAxis)
angle = math.acos(z_dir.dot(yAxis))*180/3.14159
GL.glPushMatrix()
GL.glTranslatef(center[0],center[1],center[2])
GL.glRotatef(angle, rotation_dir[0],rotation_dir[1],rotation_dir[2])
GLU.gluCylinder(qobj,cyl_radius,cyl_radius,cyl_height,20,20)
GL.glPopMatrix()
GL.glEndList()
return genList
示例11: drawAxis
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def drawAxis(self):
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
width = float(self.width())
height = float(self.height())
frustrumx = 60*width/self.sizeHint().width()
frustrumy = 60*height/self.sizeHint().height()
GL.glFrustum(-frustrumx, frustrumx, frustrumy, -frustrumy, 200, 500)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
qobj = GLU.gluNewQuadric()
GL.glTranslatef(1.7*frustrumx, 1.7*frustrumy, -400)
GL.glRotatef(self.xRot / 16.0, 1.0, 0.0, 0.0)
GL.glRotatef(self.yRot / 16.0, 0.0, 1.0, 0.0)
GL.glRotatef(self.zRot / 16.0, 0.0, 0.0, 1.0)
GL.glDisable(GL.GL_LIGHTING)
GL.glBegin(GL.GL_LINES)
self.qglColor(RED)
GL.glVertex3f(-20.0,0,0) #X is inverted
GL.glVertex3f(0.,0.,0.)
self.qglColor(GREEN)
GL.glVertex3f(0,20,0)
GL.glVertex3f(0.,0.,0.)
self.qglColor(BLUE)
GL.glVertex3f(0,0,20)
GL.glVertex3f(0.,0.,0.)
GL.glEnd()
GL.glEnable(GL.GL_LIGHTING)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
#Scale for HeatMap
示例12: on_paint
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def on_paint(self, event):
'''Renders the entire scene.'''
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.canvas.SetCurrent(self.canvas.context)
if not self.gl_initialized:
self.initgl()
self.gl_initialized = True
self.print_help()
self.resize(*self.size)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
while len(self._display_commands) > 0:
self._display_commands.pop(0)()
if self._refresh_display_lists:
self.create_display_lists()
gl.glPushMatrix()
# camera_pos_rtp is relative to target position. To get the absolute
# camera position, we need to add the target position.
camera_pos_xyz = np.array(rtp_to_xyz(*self.camera_pos_rtp)) \
+ self.target_pos
glu.gluLookAt(
*(list(camera_pos_xyz) + list(self.target_pos) + self.up))
if self.show_axes_tf:
gl.glCallList(self.gllist_id)
self.draw_data_set()
gl.glPopMatrix()
gl.glFlush()
if self._selection_box is not None:
self.draw_box(*self._selection_box)
self.SwapBuffers()
event.Skip()
示例13: _drawSkyBackground
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def _drawSkyBackground(self):
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
quad = numpy.array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32')
if self.editor.level.dimNo == -1:
colors = numpy.array([0x90, 0x00, 0x00, 0xff,
0x90, 0x00, 0x00, 0xff,
0x90, 0x00, 0x00, 0xff,
0x90, 0x00, 0x00, 0xff, ], dtype='uint8')
elif self.editor.level.dimNo == 1:
colors = numpy.array([0x22, 0x27, 0x28, 0xff,
0x22, 0x27, 0x28, 0xff,
0x22, 0x27, 0x28, 0xff,
0x22, 0x27, 0x28, 0xff, ], dtype='uint8')
else:
colors = numpy.array([0x48, 0x49, 0xBA, 0xff,
0x8a, 0xaf, 0xff, 0xff,
0x8a, 0xaf, 0xff, 0xff,
0x48, 0x49, 0xBA, 0xff, ], dtype='uint8')
alpha = 1.0
if alpha > 0.0:
if alpha < 1.0:
GL.glEnable(GL.GL_BLEND)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, quad)
GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, colors)
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
if alpha < 1.0:
GL.glDisable(GL.GL_BLEND)
GL.glDisableClientState(GL.GL_COLOR_ARRAY)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
示例14: _drawToolMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def _drawToolMarkers(self):
GL.glColor(1.0, 1.0, 1.0, 0.5)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glMatrixMode(GL.GL_MODELVIEW)
for player in self.editor.level.players:
try:
pos = self.editor.level.getPlayerPosition(player)
yaw, pitch = self.editor.level.getPlayerOrientation(player)
dim = self.editor.level.getPlayerDimension(player)
self.inOtherDimension[dim].append(player)
self.playerPos[dim][pos] = player
self.revPlayerPos[dim][player] = pos
if player != "Player" and config.settings.downloadPlayerSkins.get():
self.playerTexture[player] = loadPNGTexture(self.playercache.getPlayerSkin(player, force_download=False))
else:
self.playerTexture[player] = self.charTex
if dim != self.editor.level.dimNo:
continue
x, y, z = pos
GL.glPushMatrix()
GL.glTranslate(x, y, z)
GL.glRotate(-yaw, 0, 1, 0)
GL.glRotate(pitch, 1, 0, 0)
GL.glColor(1, 1, 1, 1)
self.drawCharacterHead(0, 0, 0, (x,y,z), self.editor.level.dimNo)
GL.glPopMatrix()
# GL.glEnable(GL.GL_BLEND)
drawTerrainCuttingWire(FloatBox((x - .5, y - .5, z - .5), (1, 1, 1)),
c0=(0.3, 0.9, 0.7, 1.0),
c1=(0, 0, 0, 0),
)
#GL.glDisable(GL.GL_BLEND)
except Exception, e:
print repr(e)
continue
示例15: _drawToolMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glPopMatrix [as 别名]
def _drawToolMarkers(self):
GL.glColor(1.0, 1.0, 1.0, 0.5)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glMatrixMode(GL.GL_MODELVIEW)
for player in self.editor.level.players:
try:
pos = self.editor.level.getPlayerPosition(player)
yaw, pitch = self.editor.level.getPlayerOrientation(player)
dim = self.editor.level.getPlayerDimension(player)
self.inOtherDimension[dim].append(player)
self.playerPos[dim][pos] = player
self.revPlayerPos[dim][player] = pos
if player != "Player" and config.settings.downloadPlayerSkins.get():
# print 7
r = self.playercache.getPlayerSkin(player, force_download=False)
if not isinstance(r, (str, unicode)):
r = r.join()
self.playerTexture[player] = loadPNGTexture(r)
else:
self.playerTexture[player] = self.charTex
if dim != self.editor.level.dimNo:
continue
x, y, z = pos
GL.glPushMatrix()
GL.glTranslate(x, y, z)
GL.glRotate(-yaw, 0, 1, 0)
GL.glRotate(pitch, 1, 0, 0)
GL.glColor(1, 1, 1, 1)
self.drawCharacterHead(0, 0, 0, (x,y,z), self.editor.level.dimNo)
GL.glPopMatrix()
# GL.glEnable(GL.GL_BLEND)
drawTerrainCuttingWire(FloatBox((x - .5, y - .5, z - .5), (1, 1, 1)),
c0=(0.3, 0.9, 0.7, 1.0),
c1=(0, 0, 0, 0),
)
#GL.glDisable(GL.GL_BLEND)
except Exception, e:
print "Exception in editortools.player.PlayerPositionTool._drawToolMarkers:", repr(e)
import traceback
print traceback.format_exc()
continue