本文整理汇总了Python中OpenGL.GL.glMatrixMode方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glMatrixMode方法的具体用法?Python GL.glMatrixMode怎么用?Python GL.glMatrixMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glMatrixMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initgl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def initgl(self):
"""Initialize OpenGL for use in the window."""
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.load_textures()
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glClearColor(*self.clear_color)
gl.glClearDepth(1.0)
gl.glDepthFunc(gl.GL_LESS)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glShadeModel(gl.GL_SMOOTH)
gl.glMatrixMode(gl.GL_PROJECTION)
# Reset The projection matrix
gl.glLoadIdentity()
# Calculate aspect ratio of the window
(width, height) = self.canvas.GetClientSize()
glu.gluPerspective(45.0, float(width) / float(height), 0.1, 100.0)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, (0.5, 0.5, 0.5, 1.0))
gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, (0.0, 0.0, 2.0, 1.0))
gl.glEnable(gl.GL_LIGHT0)
示例2: draw_box
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def draw_box(self, x0, y0, x1, y1):
'''Draws a selection box in the 3-D window.
Coordinates are with respect to the lower left corner of the window.
'''
import OpenGL.GL as gl
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0.0, self.size[0],
0.0, self.size[1],
-0.01, 10.0)
gl.glLineStipple(1, 0xF00F)
gl.glEnable(gl.GL_LINE_STIPPLE)
gl.glLineWidth(1.0)
gl.glColor3f(1.0, 1.0, 1.0)
gl.glBegin(gl.GL_LINE_LOOP)
gl.glVertex3f(x0, y0, 0.0)
gl.glVertex3f(x1, y0, 0.0)
gl.glVertex3f(x1, y1, 0.0)
gl.glVertex3f(x0, y1, 0.0)
gl.glEnd()
gl.glDisable(gl.GL_LINE_STIPPLE)
gl.glFlush()
self.resize(*self.size)
示例3: freezeStatus
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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
示例4: gl_draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def gl_draw(self):
if self.schematic.chunkCount > len(self.renderer.chunkRenderers):
self.gl_draw_thumb()
else:
if self.fbo is None:
w, h = self.fboSize
self.fbo = FramebufferTexture(w, h, self.gl_draw_tex)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glColor(1.0, 1.0, 1.0, 1.0)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
- 1, 1,
1, 1,
1, -1, ], dtype='float32'))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([0, 0, 0, 256, 256, 256, 256, 0], dtype='float32'))
e = (GL.GL_TEXTURE_2D,)
if not self.drawBackground:
e += (GL.GL_ALPHA_TEST,)
with gl.glEnable(*e):
self.fbo.bind()
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
示例5: resizeGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def resizeGL(self, width, height):
side = min(width, height)
GL.glViewport((width - side) // 2, (height - side) // 2, side, side)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
#GL.glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0)
GL.glFrustum(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
示例6: resize
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def resize(width,height):
gl.glViewport(0, 0, width, height+4)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, width, 0, height+4, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
示例7: resize
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def resize(self, width, height):
"""Reshape the OpenGL viewport based on dimensions of the window."""
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.size = (width, height)
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
glu.gluPerspective(self.fovy, float(width) / height,
self.znear, self.zfar)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
示例8: resize
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def resize(self, width, height):
"""Reshape the OpenGL viewport based on dimensions of the window."""
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.size = (width, height)
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
glu.gluPerspective(self.fovy, float(width) / height,
self.znear, self.zfar)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
示例9: drawCeiling
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def drawCeiling(self):
GL.glMatrixMode(GL.GL_MODELVIEW)
# GL.glPushMatrix()
x, y, z = self.cameraPosition
x -= x % 16
z -= z % 16
y = self.editor.level.Height
GL.glTranslate(x, y, z)
self.ceilingList.call(self._drawCeiling)
GL.glTranslate(-x, -y, -z)
示例10: setup_matrices
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def setup_matrices(self):
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
self.setup_projection()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
self.setup_modelview()
示例11: glPushMatrix
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def glPushMatrix(cls, matrixmode):
try:
GL.glMatrixMode(matrixmode)
GL.glPushMatrix()
yield
finally:
GL.glMatrixMode(matrixmode)
GL.glPopMatrix()
示例12: drawToolMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [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()
示例13: resizeGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def resizeGL(self, width, height):
side = min(width, height)
GL.glViewport((width - side) / 2, (height - side) / 2, side, side)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
示例14: gl_draw_all
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def gl_draw_all(self, root, offset):
if not self.visible:
return
#from OpenGL import GL, GLU
rect = self.rect.move(offset)
if self.is_gl_container:
self.gl_draw_self(root, offset)
suboffset = rect.topleft
for subwidget in self.subwidgets:
subwidget.gl_draw_all(root, suboffset)
else:
try:
surface = Surface(self.size, SRCALPHA)
except:
#size error?
return
self.draw_all(surface)
data = image.tostring(surface, 'RGBA', 1)
w, h = root.size
GL.glViewport(0, 0, w, h)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GLU.gluOrtho2D(0, w, 0, h)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glRasterPos2i(max(rect.left, 0), max(h - rect.bottom, 0))
GL.glPushAttrib(GL.GL_COLOR_BUFFER_BIT)
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
GL.glDrawPixels(self.width, self.height,
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, fromstring(data, dtype='uint8'))
GL.glPopAttrib()
GL.glFlush()
示例15: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glMatrixMode [as 别名]
def paintGL(self):
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glMatrixMode(GL.GL_PROJECTION)
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)
self.drawAxis()
GL.glLoadIdentity()
GL.glTranslatef(self.xTran, self.yTran, self.zTran)
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.glScalef(-self.zoom,self.zoom,self.zoom)
if self.model != 0:
GL.glCallList(self.model)
if self.indicator:
GL.glCallList(self.indicator)
for stimulator in self.stimulator_objects:
try:
GL.glCallList(stimulator)
except:
pass
for tmp in self.tmp_objects:
try:
GL.glCallList(tmp)
except:
pass
try:
GL.glCallList(self.eegReferences)
except:
pass
try:
GL.glCallList(self.eegPositions)
except:
pass
self.model_matrix = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
self.projection_matrix = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX)