本文整理汇总了Python中OpenGL.GL.glEnable方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glEnable方法的具体用法?Python GL.glEnable怎么用?Python GL.glEnable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glEnable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def __init__(self, size, cam):
app.Canvas.__init__(self, show=False, size=size)
self.shape = (size[1], size[0])
self.yz_flip = np.eye(4, dtype=np.float32)
self.yz_flip[1, 1], self.yz_flip[2, 2] = -1, -1
self.set_cam(cam)
# Set up shader programs
self.program_col = gloo.Program(_vertex_code_colored, _fragment_code_colored)
self.program_tex = gloo.Program(_vertex_code_textured, _fragment_code_textured)
# Texture where we render the color/depth and its FBO
self.col_tex = gloo.Texture2D(shape=self.shape + (3,))
self.fbo = gloo.FrameBuffer(self.col_tex, gloo.RenderBuffer(self.shape))
self.fbo.activate()
gloo.set_state(depth_test=True, blend=False, cull_face=True)
gl.glEnable(gl.GL_LINE_SMOOTH)
gloo.set_clear_color((0.0, 0.0, 0.0))
gloo.set_viewport(0, 0, *self.size)
示例2: viewer_init
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def viewer_init(self, w, h):
pangolin.CreateWindowAndBind('Map Viewer', w, h)
gl.glEnable(gl.GL_DEPTH_TEST)
self.scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(w, h, 420, 420, w//2, h//2, 0.2, 10000),
pangolin.ModelViewLookAt(0, -10, -8,
0, 0, 0,
0, -1, 0))
self.handler = pangolin.Handler3D(self.scam)
# Create Interactive View in window
self.dcam = pangolin.CreateDisplay()
self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, w/h)
self.dcam.SetHandler(self.handler)
# hack to avoid small Pangolin, no idea why it's *2
self.dcam.Resize(pangolin.Viewport(0,0,w*2,h*2))
self.dcam.Activate()
示例3: renderImage
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def renderImage(self, context):
width, height = self.getSize()
gl.glViewport(0, 0, width, height)
gl.glDisable(gl.GL_SCISSOR_TEST)
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc(gl.GL_GREATER, 0)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
self.frameBuffer.bind()
self.renderer.render(context)
self.frameBuffer.unbind()
#TODO Restore blend state. Any other states that need restoring...?
gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA)
示例4: initgl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [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)
示例5: draw_box
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [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)
示例6: initgl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def initgl(self):
'''App-specific initialization for after GLUT has been initialized.'''
import OpenGL.GL as gl
self.gllist_id = gl.glGenLists(9)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glDisable(gl.GL_LIGHTING)
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glDisable(gl.GL_FOG)
gl.glDisable(gl.GL_COLOR_MATERIAL)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glShadeModel(gl.GL_FLAT)
self.set_data(self.data, classes=self.classes, features=self.features)
try:
import OpenGL.GLUT as glut
glut.glutInit()
self._have_glut = True
except:
pass
示例7: drawFaceVertices
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def drawFaceVertices(self, buf):
if 0 == len(buf):
return
stride = elementByteLength
GL.glVertexPointer(3, GL.GL_FLOAT, stride, (buf.ravel()))
GL.glTexCoordPointer(2, GL.GL_FLOAT, stride, (buf.ravel()[3:]))
GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype=numpy.uint8).ravel()[20:]))
GL.glDepthMask(False)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
GL.glLineWidth(2.0)
GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
GL.glPolygonOffset(DepthOffset.TerrainWire, DepthOffset.TerrainWire)
with gl.glEnable(GL.GL_POLYGON_OFFSET_FILL, GL.GL_DEPTH_TEST):
GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
GL.glDepthMask(True)
示例8: drawTerrainCuttingWire
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def drawTerrainCuttingWire(box,
c0=(0.75, 0.75, 0.75, 0.4),
c1=(1.0, 1.0, 1.0, 1.0)):
# glDepthMask(False)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glDepthFunc(GL.GL_LEQUAL)
GL.glColor(*c1)
GL.glLineWidth(2.0)
drawCube(box, cubeType=GL.GL_LINE_STRIP)
GL.glDepthFunc(GL.GL_GREATER)
GL.glColor(*c0)
GL.glLineWidth(1.0)
drawCube(box, cubeType=GL.GL_LINE_STRIP)
GL.glDepthFunc(GL.GL_LEQUAL)
GL.glDisable(GL.GL_DEPTH_TEST)
# glDepthMask(True)
示例9: _drawCeiling
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def _drawCeiling():
lines = []
minz = minx = -256
maxz = maxx = 256
for x in range(minx, maxx + 1, 16):
lines.append((x, 0, minz))
lines.append((x, 0, maxz))
for z in range(minz, maxz + 1, 16):
lines.append((minx, 0, z))
lines.append((maxx, 0, z))
GL.glColor(0.3, 0.7, 0.9)
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array(lines, dtype='float32'))
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glDepthMask(False)
GL.glDrawArrays(GL.GL_LINES, 0, len(lines))
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDepthMask(True)
示例10: drawToolReticle
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def drawToolReticle(self):
if self.movingPlayer is None:
return
pos, direction = self.editor.blockFaceUnderCursor
dim = self.editor.level.getPlayerDimension(self.movingPlayer)
pos = (pos[0], pos[1] + 2, pos[2])
x, y, z = pos
# x,y,z=map(lambda p,d: p+d, pos, direction)
GL.glEnable(GL.GL_BLEND)
GL.glColor(1.0, 1.0, 1.0, 0.5)
self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
GL.glDisable(GL.GL_BLEND)
GL.glEnable(GL.GL_DEPTH_TEST)
self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
#drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
GL.glDisable(GL.GL_DEPTH_TEST)
示例11: initializeGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def initializeGL(self):
"""Initialize OpenGL, VBOs, upload data on the GPU, etc."""
# First check for supported GL version
gl_version = float(gl.glGetString(gl.GL_VERSION)[:3])
if gl_version < 3.3:
return
# background color
gl.glClearColor(0, 0, 0, 0)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
# self.mcp_data = mcpUBO()
self.globaldata = ndUBO()
self.mcp_col_shader = BlueSkyProgram('mcp.vert', 'color.frag')
self.mcp_tex_shader = BlueSkyProgram('mcp.vert', 'texture.frag')
self.mcp_txt_shader = BlueSkyProgram('mcp_text.vert', 'mcp_text.frag')
self.color_shader = BlueSkyProgram('normal.vert', 'color.frag')
self.text_shader = BlueSkyProgram('text.vert', 'text.frag')
self.text_shader.bind_uniform_buffer('global_data', self.globaldata)
self.create_objects()
self.update_lcd()
示例12: __init__
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def __init__(self, obj_info, color=None, swapyz=False):
"""Loads a Wavefront OBJ file. """
self.vertices = obj_info.vertices
self.normals = obj_info.normals
self.texcoords = obj_info.texcoords
self.faces = obj_info.faces
self.color = color
self.gl_list = GL.glGenLists(1)
GL.glNewList(self.gl_list, GL.GL_COMPILE)
# GL.glEnable(GL.GL_TEXTURE_2D)
GL.glFrontFace(GL.GL_CCW)
# GL.glDisable(GL.GL_LIGHT0)
# GL.glDisable(GL.GL_LIGHTING)
for face in self.faces:
vertices, normals, _, _ = face
GL.glColor3f(self.color[0], self.color[1], self.color[2])
GL.glBegin(GL.GL_POLYGON)
for i in range(len(vertices)):
# if normals[i] > 0:
# GL.glNormal3fv(self.normals[normals[i] - 1])
GL.glVertex3fv(self.vertices[vertices[i] - 1])
GL.glEnd()
GL.glDisable(GL.GL_TEXTURE_2D)
GL.glEndList()
示例13: drawFaceVertices
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def drawFaceVertices(self, buf):
if not len(buf):
return
stride = elementByteLength
GL.glVertexPointer(3, GL.GL_FLOAT, stride, (buf.ravel()))
GL.glTexCoordPointer(2, GL.GL_FLOAT, stride, (buf.ravel()[3:]))
GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype=numpy.uint8).ravel()[20:]))
GL.glDepthMask(False)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
GL.glLineWidth(2.0)
GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
GL.glPolygonOffset(DepthOffset.TerrainWire, DepthOffset.TerrainWire)
with gl.glEnable(GL.GL_POLYGON_OFFSET_FILL, GL.GL_DEPTH_TEST):
GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
GL.glDepthMask(True)
示例14: initializeGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def initializeGL(self):
self.setClearColor(QtGui.QColor.fromCmykF(0.1, .0, 0.2, 1.0))
self.electrode_object, self.plug_object = \
self.drawElectrode(self.electrode_struct)
self.center_dir = self.drawPointAndDirs()
GL.glShadeModel(GL.GL_FLAT)
GL.glEnable(GL.GL_DEPTH_TEST)
示例15: initializeGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnable [as 别名]
def initializeGL(self):
self.setClearColor(WHITE)
GL.glShadeModel(GL.GL_SMOOTH)
light_ambient = [0.0, 0.0, 0.0, 1.0]
GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnable(GL.GL_LIGHTING)
GL.glEnable(GL.GL_LIGHT0)
GL.glEnable(GL.GL_COLOR_MATERIAL)
GL.glEnable(GL.GL_NORMALIZE)
GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE)