本文整理汇总了Python中pyglet.gl.glEnableClientState函数的典型用法代码示例。如果您正苦于以下问题:Python glEnableClientState函数的具体用法?Python glEnableClientState怎么用?Python glEnableClientState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glEnableClientState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
def draw(self, transformation, **kwargs):
transformation.scale(self.width, self.height, 1)
color = self.color + (self.opacity,)
gl.glColor4fv((gl.GLfloat * 4)(*color))
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glVertexPointer(2, gl.GL_FLOAT, 0, self.vertices)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
示例2: on_draw
def on_draw(self):
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
if self.app.show_fps:
self.fps_display.draw()
self.app.on_draw()
示例3: _draw_rects
def _draw_rects(shape_list, vertex_vbo_id, texture_coord_vbo_id):
"""
Draw a set of rectangles using vertex buffers. This is more efficient
than drawing them individually.
"""
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)
# GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
# GL.glMatrixMode(GL.GL_MODELVIEW)
# GL.glDisable(GL.GL_BLEND)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, vertex_vbo_id)
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, texture_coord_vbo_id)
offset = 0
for shape in shape_list:
if shape.can_cache:
texture_coord_vbo_id = None
GL.glColor4f(1, 1, 1, shape.alpha)
_render_rect_filled(shape, offset,
shape.texture.texture_id, texture_coord_vbo_id)
offset += 4
else:
shape.draw()
示例4: on_draw
def on_draw(self):
"""
Render the screen.
"""
start = time.time()
float_size = ctypes.sizeof(ctypes.c_float)
record_len = 10 * float_size
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glColor4ub(255, 0, 0, 255)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.rect_vbo.vbo_id)
GL.glVertexPointer(2, GL.GL_FLOAT, record_len, 0)
for i in range(len(self.shape_list)):
shape = self.shape_list[i]
GL.glLoadIdentity()
GL.glTranslatef(shape.x, shape.y, 0)
GL.glDrawArrays(GL.GL_QUADS, i * 8, 8)
# GL.glDrawArrays(GL.GL_QUADS,
# 0,
# self.rect_vbo.size)
elapsed = time.time() - start
print(elapsed)
示例5: update_display
def update_display(verts,tex_coords,texture=bird_texture):
gl.glClearColor(0.2, 0.4, 0.5, 1.0)
gl.glEnable(texture.target)
gl.glBindTexture(texture.target, texture.id)
gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc (gl.GL_GREATER, .1)
#gl.glEnable(gl.GL_BLEND)
#gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
n=len(verts[:])
#TODO verts._buffer.ctypes.data is awkward
gl.glVertexPointer(3, vert_dtype.gl, 0, verts[:].ctypes.data)
gl.glTexCoordPointer(3, tex_dtype.gl, 0, tex_coords[:].ctypes.data)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)
#unset state
gl.glPopAttrib()
gl.glDisable(texture.target)
示例6: __init__
def __init__(self):
pts = generate_cyl_points().T
colors = np.zeros_like(pts)
colors[:,1]=1.0 # all green
n_pts = len(pts)
pts = map(float,pts.flat) # convert to flat list of floats
colors = map(float, colors.flat)
# Create ctypes arrays of the lists
vertices = (gl.GLfloat * (n_pts*3))(*pts)
colors = (gl.GLfloat * (n_pts*3))(*colors)
# Create a list of triangle indices.
indices = range(n_pts)
indices = (gl.GLuint * n_pts)(*indices)
# Compile a display list
self.list = gl.glGenLists(1)
gl.glNewList(self.list, gl.GL_COMPILE)
gl.glPushClientAttrib(gl.GL_CLIENT_VERTEX_ARRAY_BIT)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertices)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glColorPointer(3, gl.GL_FLOAT, 0, colors)
gl.glDrawElements(gl.GL_POINTS, len(indices), gl.GL_UNSIGNED_INT, indices)
gl.glPopClientAttrib()
gl.glEndList()
示例7: on_draw
def on_draw(self):
"""
Render the screen.
"""
start = time.time()
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glDisable(GL.GL_BLEND)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.vertex_vbo_id)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.color_vbo_id)
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
GL.glColorPointer(3, GL.GL_FLOAT, 0, 0)
offset = 0
for shape in self.shape_list:
render_rect_filled(shape, offset)
offset += 4
elapsed = time.time() - start
print(elapsed)
示例8: draw_bounding_box
def draw_bounding_box(self, x, y, screen_height):
bb = self.get_bounding_box()
bb = [bb['min_x'], bb['min_y'], bb['max_x'], bb['max_y']]
vertices = ()
for _ in bb:
vertices += (_.x,)
vertices += (screen_height - _.y,)
# get opengl vertices of type GLfloat
vertices_gl = (GLfloat * len(vertices))(*vertices)
# set the color
glColor4ub(0, 255, 0, 255);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
# turn on blend for alpha channel
glEnable(GL_BLEND)
# tell open GL were passing a vertex array
glEnableClientState(GL_VERTEX_ARRAY)
# create a pointer to vertices_gl
glVertexPointer(2, GL_FLOAT, 0, vertices_gl)
# draw the array
glDrawArrays(GL_POLYGON, 0, len(vertices) // 2)
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
示例9: start_render
def start_render():
"""
Get set up to render. Required to be called before drawing anything to the
screen.
"""
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
示例10: __init__
def __init__(self, radius, inner_radius, slices, inner_slices):
# Create the vertex and normal arrays.
vertices = []
normals = []
u_step = 2 * pi / (slices - 1)
v_step = 2 * pi / (inner_slices - 1)
u = 0.
for i in range(slices):
cos_u = cos(u)
sin_u = sin(u)
v = 0.
for j in range(inner_slices):
cos_v = cos(v)
sin_v = sin(v)
d = (radius + inner_radius * cos_v)
x = d * cos_u
y = d * sin_u
z = inner_radius * sin_v
nx = cos_u * cos_v
ny = sin_u * cos_v
nz = sin_v
vertices.extend([x, y, z])
normals.extend([nx, ny, nz])
v += v_step
u += u_step
# Create ctypes arrays of the lists
vertices = (GLfloat * len(vertices))(*vertices)
normals = (GLfloat * len(normals))(*normals)
# Create a list of triangle indices.
indices = []
for i in range(slices - 1):
for j in range(inner_slices - 1):
p = i * inner_slices + j
indices.extend([p, p + inner_slices, p + inner_slices + 1])
indices.extend([p, p + inner_slices + 1, p + 1])
indices = (GLuint * len(indices))(*indices)
# Compile a display list
self.list = glGenLists(1)
glNewList(self.list, GL_COMPILE)
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_NORMAL_ARRAY)
glVertexPointer(3, GL_FLOAT, 0, vertices)
glNormalPointer(GL_FLOAT, 0, normals)
glDrawElements(GL_TRIANGLES, len(indices), GL_UNSIGNED_INT, indices)
glPopClientAttrib()
glEndList()
示例11: display
def display(self, mode_2d=False):
glPushMatrix()
glTranslatef(self.offset_x, self.offset_y, 0)
glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_COLOR_ARRAY)
self._display_movements(mode_2d)
glDisableClientState(GL_COLOR_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)
glPopMatrix()
示例12: __enter__
def __enter__(self):
for idx in self.state:
texuint = 0
if hasattr(idx, "__len__"):
texunit = idx[1]
idx = idx[0]
if idx in self.ClientState:
if idx == gl.GL_TEXTURE_COORD_ARRAY:
gl.glClientActiveTexture(GL_TEXTURE0 + texunit)
gl.glEnableClientState(idx)
else:
gl.glEnable(idx)
示例13: draw
def draw(self):
gl.glClearColor(0.2, 0.4, 0.5, 1.0)
gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable (gl.GL_BLEND)
gl.glEnable (gl.GL_LINE_SMOOTH);
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
#TODO verts._buffer.ctypes.data is awkward
gl.glVertexPointer(2, self.vert_dtype.gl, 0, self.verts._buffer.ctypes.data)
gl.glColorPointer(3, self.color_dtype.gl, 0, self.colors._buffer.ctypes.data)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(self.verts._buffer)//2)
示例14: draw_hud
def draw_hud(self):
'''
Draw any display items overlaid on the world, such as FPS counter
'''
self.projection.set_screen()
self.modelview.set_identity()
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
self.clock_display.draw()
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
示例15: update_display
def update_display(render_verts, colors):
gl.glClearColor(0.2, 0.4, 0.5, 1.0)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_BLEND)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
n = len(render_verts[:])
# TODO verts._buffer.ctypes.data is awkward
gl.glVertexPointer(3, vert_dtype.gl, 0, render_verts[:].ctypes.data)
gl.glColorPointer(3, color_dtype.gl, 0, colors[:].ctypes.data)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)