本文整理汇总了Python中OpenGL.GL.glEnableClientState方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glEnableClientState方法的具体用法?Python GL.glEnableClientState怎么用?Python GL.glEnableClientState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glEnableClientState方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initgl
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [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
示例2: gl_draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [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)
示例3: makeDisplayLists
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def makeDisplayLists(self):
if not self.needsRedisplay:
return
self.forgetDisplayLists()
if not self.blockRenderers:
return
lists = defaultdict(list)
showRedraw = self.renderer.showRedraw
if not (showRedraw and self.needsBlockRedraw):
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
renderers = self.blockRenderers
for blockRenderer in renderers:
if self.detailLevel not in blockRenderer.detailLevels:
continue
if blockRenderer.layer not in self.visibleLayers:
continue
l = blockRenderer.makeArrayList(self.chunkPosition, self.needsBlockRedraw and showRedraw)
lists[blockRenderer.renderstate].append(l)
if not (showRedraw and self.needsBlockRedraw):
GL.glDisableClientState(GL.GL_COLOR_ARRAY)
self.needsRedisplay = False
self.renderstateLists = lists
示例4: drawFaceVertices
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def drawFaceVertices(self, buf):
if not len(buf):
return
stride = 16
GL.glVertexPointer(3, GL.GL_FLOAT, stride, numpy.ravel(buf.ravel()))
GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype='uint8').ravel()[12:]))
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
示例5: glEnableClientState
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def glEnableClientState(cls, *enables):
try:
GL.glPushClientAttrib(GL.GL_CLIENT_ALL_ATTRIB_BITS)
for e in enables:
GL.glEnableClientState(e)
yield
finally:
GL.glPopClientAttrib()
示例6: _gl_draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def _gl_draw(self):
blockInfo = self.blockInfo
if blockInfo.ID is 0:
return
GL.glColor(1.0, 1.0, 1.0, 1.0)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glEnable(GL.GL_ALPHA_TEST)
self.materials.terrainTexture.bind()
pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
texSize = 16 * pixelScale
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
- 1, 1,
1, 1,
1, -1, ], dtype='float32'))
# hack to get end rod to render properly
# we really should use json models?
if blockInfo.ID == 198:
texOrigin = array([17*16, 20*16])
else:
texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
texOrigin = texOrigin.astype(float) * pixelScale
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
texOrigin[0], texOrigin[1],
texOrigin[0] + texSize, texOrigin[1],
texOrigin[0] + texSize, texOrigin[1] + texSize],
dtype='float32'))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glDisable(GL.GL_ALPHA_TEST)
GL.glDisable(GL.GL_TEXTURE_2D)
示例7: _drawLoadableChunkMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def _drawLoadableChunkMarkers(self):
if self.level.chunkCount:
chunkSet = set(self.level.allChunks)
sizedChunks = chunkMarkers(chunkSet)
GL.glPushAttrib(GL.GL_FOG_BIT)
GL.glDisable(GL.GL_FOG)
GL.glEnable(GL.GL_BLEND)
GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
GL.glPolygonOffset(DepthOffset.ChunkMarkers, DepthOffset.ChunkMarkers)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glColor(1.0, 1.0, 1.0, 1.0)
self.floorTexture.bind()
for size, chunks in sizedChunks.iteritems():
if not len(chunks):
continue
chunks = numpy.array(chunks, dtype='float32')
chunkPosition = numpy.zeros(shape=(chunks.shape[0], 4, 3), dtype='float32')
chunkPosition[:, :, (0, 2)] = numpy.array(((0, 0), (0, 1), (1, 1), (1, 0)), dtype='float32')
chunkPosition[:, :, (0, 2)] *= size
chunkPosition[:, :, (0, 2)] += chunks[:, numpy.newaxis, :]
chunkPosition *= 16
GL.glVertexPointer(3, GL.GL_FLOAT, 0, chunkPosition.ravel())
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, (chunkPosition[..., (0, 2)] * 16).ravel())
GL.glDrawArrays(GL.GL_QUADS, 0, len(chunkPosition) * 4)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glDisable(GL.GL_TEXTURE_2D)
GL.glDisable(GL.GL_BLEND)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
GL.glPopAttrib()
示例8: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def paintGL(self, p, opt, widget):
p.beginNativePainting()
import OpenGL.GL as gl
## set clipping viewport
view = self.getViewBox()
if view is not None:
rect = view.mapRectToItem(self, view.boundingRect())
#gl.glViewport(int(rect.x()), int(rect.y()), int(rect.width()), int(rect.height()))
#gl.glTranslate(-rect.x(), -rect.y(), 0)
gl.glEnable(gl.GL_STENCIL_TEST)
gl.glColorMask(gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE) # disable drawing to frame buffer
gl.glDepthMask(gl.GL_FALSE) # disable drawing to depth buffer
gl.glStencilFunc(gl.GL_NEVER, 1, 0xFF)
gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)
## draw stencil pattern
gl.glStencilMask(0xFF)
gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
gl.glBegin(gl.GL_TRIANGLES)
gl.glVertex2f(rect.x(), rect.y())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glEnd()
gl.glColorMask(gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE)
gl.glDepthMask(gl.GL_TRUE)
gl.glStencilMask(0x00)
gl.glStencilFunc(gl.GL_EQUAL, 1, 0xFF)
try:
x, y = self.getData()
pos = np.empty((len(x), 2))
pos[:,0] = x
pos[:,1] = y
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
try:
gl.glVertexPointerf(pos)
pen = fn.mkPen(self.opts['pen'])
color = pen.color()
gl.glColor4f(color.red()/255., color.green()/255., color.blue()/255., color.alpha()/255.)
width = pen.width()
if pen.isCosmetic() and width < 1:
width = 1
gl.glPointSize(width)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
finally:
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
finally:
p.endNativePainting()
示例9: drawToolbar
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def drawToolbar(self):
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glColor(1., 1., 1., 1.)
w, h = self.toolbarTextureSize
self.guiTexture.bind()
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array((
1, h + 1, 0.5,
w + 1, h + 1, 0.5,
w + 1, 1, 0.5,
1, 1, 0.5,
), dtype="f4"))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, numpy.array((
0, 0,
w, 0,
w, h,
0, h,
), dtype="f4"))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
for i in range(len(self.tools)):
tool = self.tools[i]
if tool.toolIconName is None:
continue
try:
if tool.toolIconName not in self.toolTextures:
filename = "toolicons" + os.sep + "{0}.png".format(tool.toolIconName)
self.toolTextures[tool.toolIconName] = mceutils.loadPNGTexture(filename)
x = 20 * i + 4
y = 4
w = 16
h = 16
self.toolTextures[tool.toolIconName].bind()
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array((
x, y + h, 1,
x + w, y + h, 1,
x + w, y, 1,
x, y, 1,
), dtype="f4"))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, numpy.array((
0, 0,
w * 16, 0,
w * 16, h * 16,
0, h * 16,
), dtype="f4"))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
except Exception:
logging.exception('Error while drawing toolbar.')
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
示例10: _drawLoadableChunkMarkers
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def _drawLoadableChunkMarkers(self):
if self.level.chunkCount:
chunkSet = set(self.level.allChunks)
sizedChunks = chunkMarkers(chunkSet)
GL.glPushAttrib(GL.GL_FOG_BIT)
GL.glDisable(GL.GL_FOG)
GL.glEnable(GL.GL_BLEND)
GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
GL.glPolygonOffset(DepthOffset.ChunkMarkers, DepthOffset.ChunkMarkers)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glColor(1.0, 1.0, 1.0, 1.0)
self.floorTexture.bind()
# chunkColor = numpy.zeros(shape=(chunks.shape[0], 4, 4), dtype='float32')
# chunkColor[:]= (1, 1, 1, 0.15)
#
# cc = numpy.array(chunks[:,0] + chunks[:,1], dtype='int32')
# cc &= 1
# coloredChunks = cc > 0
# chunkColor[coloredChunks] = (1, 1, 1, 0.28)
# chunkColor *= 255
# chunkColor = numpy.array(chunkColor, dtype='uint8')
#
# GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, chunkColor)
for size, chunks in sizedChunks.iteritems():
if not len(chunks):
continue
chunks = numpy.array(chunks, dtype='float32')
chunkPosition = numpy.zeros(shape=(chunks.shape[0], 4, 3), dtype='float32')
chunkPosition[:, :, (0, 2)] = numpy.array(((0, 0), (0, 1), (1, 1), (1, 0)), dtype='float32')
chunkPosition[:, :, (0, 2)] *= size
chunkPosition[:, :, (0, 2)] += chunks[:, numpy.newaxis, :]
chunkPosition *= 16
GL.glVertexPointer(3, GL.GL_FLOAT, 0, chunkPosition.ravel())
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, (chunkPosition[..., (0, 2)] * 16).ravel())
GL.glDrawArrays(GL.GL_QUADS, 0, len(chunkPosition) * 4)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glDisable(GL.GL_TEXTURE_2D)
GL.glDisable(GL.GL_BLEND)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
GL.glPopAttrib()
示例11: draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def draw(self):
self.needsRedraw = False
if not self.level:
return
if not self.chunkCalculator:
return
if not self.render:
return
if self.level.materials.name in ("Pocket", "Alpha"):
GL.glMatrixMode(GL.GL_TEXTURE)
GL.glScalef(1 / 2., 1 / 2., 1 / 2.)
with gl.glPushMatrix(GL.GL_MODELVIEW):
dx, dy, dz = self.origin
GL.glTranslate(dx, dy, dz)
GL.glEnable(GL.GL_CULL_FACE)
GL.glEnable(GL.GL_DEPTH_TEST)
self.level.materials.terrainTexture.bind()
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
offset = DepthOffset.PreviewRenderer if self.isPreviewer else DepthOffset.Renderer
GL.glPolygonOffset(offset, offset)
GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
self.createMasterLists()
try:
self.callMasterLists()
except GL.GLError, e:
if self.errorLimit:
self.errorLimit -= 1
traceback.print_exc()
print e
GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
GL.glDisable(GL.GL_CULL_FACE)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_TEXTURE_2D)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
# if self.drawLighting:
self.drawLoadableChunkMarkers()
示例12: drawToolbar
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def drawToolbar(self):
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glColor(1., 1., 1., 1.)
w, h = self.toolbarTextureSize
self.guiTexture.bind()
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array((
1, h + 1, 0.5,
w + 1, h + 1, 0.5,
w + 1, 1, 0.5,
1, 1, 0.5,
), dtype="f4"))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, numpy.array((
0, 0,
w, 0,
w, h,
0, h,
), dtype="f4"))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
for i in xrange(len(self.tools)):
tool = self.tools[i]
if tool.toolIconName is None:
continue
try:
if tool.toolIconName not in self.toolTextures:
filename = "toolicons" + os.sep + "{0}.png".format(tool.toolIconName)
self.toolTextures[tool.toolIconName] = mceutils.loadPNGTexture(filename)
x = 20 * i + 4
y = 4
w = 16
h = 16
self.toolTextures[tool.toolIconName].bind()
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array((
x, y + h, 1,
x + w, y + h, 1,
x + w, y, 1,
x, y, 1,
), dtype="f4"))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, numpy.array((
0, 0,
w * 16, 0,
w * 16, h * 16,
0, h * 16,
), dtype="f4"))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
except Exception:
logging.exception('Error while drawing toolbar.')
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
示例13: gl_draw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [as 别名]
def gl_draw(self):
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glEnable(GL.GL_BLEND)
self.toolbarDisplayList.call(self.drawToolbar)
GL.glColor(1.0, 1.0, 0.0)
try:
currentToolNumber = self.tools.index(self.parent.currentTool)
except ValueError:
pass
else:
# draw a bright rectangle around the current tool
(texx, texy, texw, texh) = self.currentToolTextureRect
tx = 20. * float(currentToolNumber)
ty = 0.
tw = 24.
th = 24.
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
self.guiTexture.bind()
GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array((
tx, ty, 2,
tx + tw, ty, 2,
tx + tw, ty + th, 2,
tx, ty + th, 2,
), dtype="f4"))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, numpy.array((
texx, texy + texh,
texx + texw, texy + texh,
texx + texw, texy,
texx, texy,
), dtype="f4"))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glDisable(GL.GL_TEXTURE_2D)
redOutBoxes = numpy.zeros(9 * 4 * 2, dtype='float32')
cursor = 0
for i in xrange(len(self.tools)):
t = self.tools[i]
if t.toolEnabled():
continue
redOutBoxes[cursor:cursor + 8] = [
4 + i * 20, 4,
4 + i * 20, 20,
20 + i * 20, 20,
20 + i * 20, 4,
]
cursor += 8
if cursor:
GL.glColor(1.0, 0.0, 0.0, 0.3)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, redOutBoxes)
GL.glDrawArrays(GL.GL_QUADS, 0, cursor / 2)
GL.glDisable(GL.GL_BLEND)
示例14: _drawSkyBackground
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glEnableClientState [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()