本文整理汇总了Python中pyglet.gl.glEnable方法的典型用法代码示例。如果您正苦于以下问题:Python gl.glEnable方法的具体用法?Python gl.glEnable怎么用?Python gl.glEnable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.gl
的用法示例。
在下文中一共展示了gl.glEnable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _gl_enable_color_material
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def _gl_enable_color_material():
gl.glColorMaterial(gl.GL_FRONT_AND_BACK,
gl.GL_AMBIENT_AND_DIFFUSE)
gl.glEnable(gl.GL_COLOR_MATERIAL)
gl.glShadeModel(gl.GL_SMOOTH)
gl.glMaterialfv(gl.GL_FRONT,
gl.GL_AMBIENT,
rendering.vector_to_gl(
0.192250, 0.192250, 0.192250))
gl.glMaterialfv(gl.GL_FRONT,
gl.GL_DIFFUSE,
rendering.vector_to_gl(
0.507540, 0.507540, 0.507540))
gl.glMaterialfv(gl.GL_FRONT,
gl.GL_SPECULAR,
rendering.vector_to_gl(
.5082730, .5082730, .5082730))
gl.glMaterialf(gl.GL_FRONT,
gl.GL_SHININESS,
.4 * 128.0)
示例2: render
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def render(self):
# Enable blending
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
# Enable transparency
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc(gl.GL_GREATER, .1)
# Load textures
self.texture = pyglet.image.TextureGrid(
pyglet.image.ImageGrid(
pyglet.image.load(
self.test_data.get_file('images', 'multitexture.png')), 1, 4))
self.background = pyglet.image.load(
self.test_data.get_file('images', 'grey_background.png')).get_texture()
# Create vertex list showing the multi texture
self.vertex_list = pyglet.graphics.vertex_list(4,
('v2f', (32, 332, 64, 332, 64, 364, 32, 364)),
('0t3f', self.texture[1].tex_coords),
('1t3f', self.texture[2].tex_coords),
('2t3f', self.texture[3].tex_coords))
示例3: draw_triangle_left
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def draw_triangle_left(self):
if self.show_triangle_left:
w = 200
h = 200
x = self.window.width // 4 - w // 2
y = (self.window.height - h) // 2
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glBegin(gl.GL_TRIANGLES)
gl.glColor4f(1, 0, 0, 1)
gl.glVertex3f(x, y, -1)
gl.glColor4f(0, 1, 0, 1)
gl.glVertex3f(x+w, y, 0)
gl.glColor4f(0, 0, 1, 1)
gl.glVertex3f(x, y+h, 1)
gl.glEnd()
gl.glDisable(gl.GL_DEPTH_TEST)
gl.glColor4f(1, 1, 1, 1)
示例4: rendering_window
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def rendering_window(draw, h, w):
window = pyglet.window.Window(width=w, height=h,
visible=False)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
# gl.glEnable(gl.GL_LINE_SMOOTH)
# gl.glEnable(gl.GL_POLYGON_SMOOTH)
# gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
# gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST)
@window.event
def on_draw():
pyglet.clock.tick()
window.clear()
gl.glLoadIdentity()
draw()
pyglet.clock.set_fps_limit(30)
pyglet.clock.schedule_interval(lambda dt: None, 1.0/30)
示例5: _setup_3d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def _setup_3d(self):
w, h = self.get_size()
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glDepthFunc(gl.GL_LEQUAL)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glEnable(gl.GL_CULL_FACE)
viewport = self.get_viewport_size()
gl.glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1]))
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluPerspective(*self.perspective)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
y, x = self.rotation
gl.glRotatef(x, 0, 1, 0)
gl.glRotatef(-y, math.cos(math.radians(x)),
0, math.sin(math.radians(x)))
# NOTE: for GL render, its x-z plane is the ground plane,
# so we unpack the position using `(x, z, y)` instead of `(x, y, z)`
x, z, y = self.position
if not self.debug_mode:
y += self.perspective_over_drone[0]
z += self.perspective_over_drone[1]
gl.glTranslatef(-x, -y, -z)
示例6: _gl_enable_blending
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def _gl_enable_blending():
# enable blending for transparency
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA,
gl.GL_ONE_MINUS_SRC_ALPHA)
示例7: _gl_enable_smooth_lines
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def _gl_enable_smooth_lines():
# make the lines from Path3D objects less ugly
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
# set the width of lines to 4 pixels
gl.glLineWidth(4)
# set PointCloud markers to 4 pixels in size
gl.glPointSize(4)
示例8: draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def draw(self, x, y):
gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_CURRENT_BIT)
gl.glColor4f(1, 1, 1, 1)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
self.texture.blit(x - self.hot_x, y - self.hot_y, 0)
gl.glPopAttrib()
示例9: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def on_draw(self):
self.window.clear()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
self.camera()
gl.glEnable(self.background.target)
gl.glEnable(gl.GL_BLEND)
gl.glBindTexture(self.background.target, self.background.id)
W = 10000.
graphics.draw(4, gl.GL_QUADS,
('v2f', (-W, -W, W, -W, W, W, -W, W)),
('t2f', (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.))
)
gl.glDisable(self.background.target)
for lane in self.world.lanes:
self.draw_lane_surface(lane)
self.draw_lane_lines(lane)
for obj in self.world.objects:
self.draw_object(obj)
for car in self.world.cars:
self.draw_car(car.trajectory[-1], car.color)
gl.glPopMatrix()
self.label.text = self.task_name
self.label.draw()
self.iter +=1
if self.iter%10 == 0:
print('Iterations: ', self.iter)
if self.iter == self.max_iters:
self.event_loop.exit()
示例10: set_3d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def set_3d(self, size):
"""Configure OpenGL to draw in 3d."""
width, height = size
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, width, height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.gluPerspective(65.0, width / float(height), 0.1, 60.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
x, y = self.player.rotation
GL.glRotatef(x, 0, 1, 0)
GL.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
x, y, z = self.player.position
GL.glTranslatef(-x, -y, -z)
示例11: _bind_texture
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def _bind_texture(self, i):
gl.glActiveTexture((gl.GL_TEXTURE0, gl.GL_TEXTURE1, gl.GL_TEXTURE2)[i])
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture[i].id)
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE)
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_ALPHA, gl.GL_REPLACE if i == 0 else gl.GL_ADD)
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
示例12: enable_alpha
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def enable_alpha(self):
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
示例13: buffer_texture
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def buffer_texture(width, height):
id_ = gl.GLuint()
gl.glGenTextures(1, byref(id_))
gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_TEXTURE_BIT)
gl.glActiveTexture(gl.GL_TEXTURE0)
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glBindTexture(gl.GL_TEXTURE_2D, id_)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MIN_FILTER,
gl.GL_LINEAR)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER,
gl.GL_LINEAR)
gl.glTexImage2D(
gl.GL_TEXTURE_2D, 0, gl.GL_RGBA,
width, height,
0,
gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
(gl.GLubyte * (width*height * 4))(),
)
gl.glFlush()
gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
gl.glPopAttrib()
return id_
示例14: set_state
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def set_state(self):
# Toggle smooth lines
gl.glEnable(gl.GL_POLYGON_SMOOTH)
gl.glEnable(gl.GL_BLEND)
示例15: quad_aligned
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glEnable [as 别名]
def quad_aligned(x, y, w, h, color):
quad_data = pyglet.graphics.vertex_list_indexed(
4,
[0, 1, 2, 2, 3, 0],
('v2i', (x, y,
x + w, y,
x + w, y + h,
x, y + h)),
('c4B', color * 4))
gl.glEnable(gl.GL_BLEND)
quad_data.draw(pyglet.gl.GL_TRIANGLES)
gl.glDisable(gl.GL_BLEND)