本文整理汇总了Python中pyglet.gl.glEnd函数的典型用法代码示例。如果您正苦于以下问题:Python glEnd函数的具体用法?Python glEnd怎么用?Python glEnd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glEnd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blit_buffer
def blit_buffer(self, framebuffer, parent_width, parent_height, **kwargs):
"""Draw the texture into the parent scene
.. warning:
This method's arguments are not part of the API yet and may change
at any time.
"""
gl.glViewport(0, 0, parent_width, parent_height)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glBindTexture(gl.GL_TEXTURE_2D, framebuffer.texture_id)
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glColor4fv((gl.GLfloat * 4)(*self.color + (self.opacity, )))
gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA) # premultipl.
gl.glBegin(gl.GL_TRIANGLE_STRIP)
gl.glTexCoord2f(0, 0)
gl.glVertex2i(0, 0)
gl.glTexCoord2f(0, parent_height)
gl.glVertex2i(0, parent_height)
gl.glTexCoord2f(parent_width, 0)
gl.glVertex2i(parent_width, 0)
gl.glTexCoord2f(parent_width, parent_height)
gl.glVertex2i(parent_width, parent_height)
gl.glEnd()
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glViewport(0, 0, parent_width, parent_height)
示例2: draw_points
def draw_points(self):
self.points_lock.acquire()
try:
from pyglet.gl import glBegin, glEnd, GL_POINTS, glColor4f, glVertex2f
glBegin(GL_POINTS)
for i in xrange(0, len(self.points)):
p = self.points[i]
parameter_index = self.parameter_indices[0]
state_index = self.state_indices[0]
glColor4f(1, 1, 1, p.age / (self.age_max*2.0))
glVertex2f(p.parameters[parameter_index], p.state[state_index])
p.state = self.system.iterate(p.state, p.parameters)
p.age += 1
#if p.age >= self.age_max:
# self.points[i] = OrbitPoint(tool=self, varying_parameter=p.parameters[parameter_index])
glEnd()
except Exception, detail:
print 'draw_points()', type(detail), detail
示例3: draw_button
def draw_button(self, x, y, point_down, over):
if over and self.pressed:
border = SCROLL_BAR_PRESSED
elif over:
border = SCROLL_BAR_OVER
else:
border = SCROLL_BAR_BORDER
draw_rectangle(x, y, x + self.width, y + self.buttonHeight,
border)
draw_rectangle(x + 1, y + 1, x + self.width - 1,
y + self.buttonHeight - 1, SCROLL_BAR_BUTTON)
glBegin(GL_TRIANGLES)
glColor4ub(*SCROLL_BAR_POINTER)
singleX = self.width / 3.0
upperX = self.width / 2.0
singleY = self.buttonHeight / 3.0
if point_down:
y -= 1
glVertex2f(singleX + x, singleY * 2 + y)
glVertex2f(upperX + x, singleY + y)
glVertex2f(singleX * 2 + x, singleY * 2 + y)
else:
glVertex2f(singleX + x, singleY + y)
glVertex2f(upperX + x, singleY * 2 + y)
glVertex2f(singleX * 2 + x, singleY + y)
glEnd()
示例4: on_draw
def on_draw(self):
self.parent.set_caption(str(pyglet.clock.get_fps()))
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glColor4ub(*[255,255,255,255])
self.room.bg.blit(0,0)
self.room.render()
gl.glColor4ub(255,255,255,255)
self.player.draw()
self.room.lightbatch.draw()
self.player.draw_eye()
self.player.draw_integrity()
if self.pause:
gl.glColor4ub(50,50,50,150)
left = self.message['text'].x-self.message['text'].width/2 -5
down = self.message['text'].y-self.message['text'].height/2 -5
right = self.message['text'].x+self.message['text'].width/2 + 5
up = self.message['text'].y+self.message['text'].height/2 + 5
gl.glRecti(left,down,right,up)
gl.glLineWidth(2)
gl.glColor4ub(200,200,200,200)
gl.glBegin(gl.GL_LINE_LOOP)
gl.glVertex2i(left,down)
gl.glVertex2i(left,up)
gl.glVertex2i(right,up)
gl.glVertex2i(right,down)
gl.glEnd()
gl.glLineWidth(1)
gl.glColor4ub(255,255,255,255)
self.message['text'].draw()
self.message['helper'].draw()
self.message['sprite'].draw()
示例5: draw
def draw(self):
from miru.context import context
gl.glEnable(gl.GL_LINE_STIPPLE)
gl.glLineStipple(1, 0x51315)
gl.glColor4f(*self.color)
for c in self.metaCamera.cameras:
vp = c.projection
x = vp.x == 0 and 1 or vp.x
width = vp.x == 0 and vp.width - 1 or vp.width
width = (vp.x + vp.width) >= context.window.width and width - 1 or width
y = vp.y == 0 and 1 or vp.y
height = vp.y == 0 and vp.height - 1 or vp.height
height = (vp.y + vp.height) >= context.window.height and height - 1 or height
gl.glBegin(gl.GL_LINE_LOOP)
gl.glVertex2f(x, y)
gl.glVertex2f(x, y + height)
gl.glVertex2f(x + width, y + height)
gl.glVertex2f(x + width, y)
gl.glEnd()
gl.glDisable(gl.GL_LINE_LOOP)
gl.glColor4f(1,1,1,1)
示例6: draw_block
def draw_block(block):
transformed = [world_to_screen(block.GetWorldPoint(p)) for p in POINTS]
gl.glColor3f(1.0, 0.1, 0)
gl.glBegin(gl.GL_LINE_LOOP)
for p in transformed:
gl.glVertex2f(*p)
gl.glEnd()
示例7: rectangle
def rectangle(x1, y1, x2, y2):
gl.glBegin(gl.GL_TRIANGLE_STRIP)
gl.glVertex2f(x1, y1)
gl.glVertex2f(x1, y2)
gl.glVertex2f(x2, y1)
gl.glVertex2f(x2, y2)
gl.glEnd()
示例8: render_boid
def render_boid(self):
glBegin(GL_TRIANGLES)
glColor3f(*self.color)
glVertex2f(-(self.size), 0.0)
glVertex2f(self.size, 0.0)
glVertex2f(0.0, self.size * 3.0)
glEnd()
示例9: render1
def render1(self):
if len(self.v) == 4 : gl.glBegin(gl.GL_QUADS)
elif len(self.v) > 4 : gl.glBegin(gl.GL_POLYGON)
else: gl.glBegin(gl.GL_TRIANGLES)
for p in self.v:
gl.glVertex3f(p[0], p[1],0) # draw each vertex
gl.glEnd()
示例10: draw_circle
def draw_circle(cx, cy, r, num_segments=None, mode=gl.GL_POLYGON, color=(1, 1, 1, 1)):
if not num_segments:
num_segments = get_num_circle_segments(r)
theta = 2 * math.pi / float(num_segments)
tangetial_factor = math.tan(theta)
radial_factor = math.cos(theta)
x = float(r)
y = 0.0
gl.glColor4f(color[0], color[1], color[2], color[3])
gl.glBegin(mode)
for i in xrange(num_segments):
gl.glVertex2f(x + cx, y + cy)
tx = y * -1
ty = x
x += tx * tangetial_factor
y += ty * tangetial_factor
x *= radial_factor
y *= radial_factor
gl.glEnd()
示例11: render_indicators
def render_indicators(self, W, H):
gl.glBegin(gl.GL_QUADS)
s = W/40.0
h = H/40.0
gl.glColor4f(0,0,0,1)
gl.glVertex3f(W, 0, 0)
gl.glVertex3f(W, 5*h, 0)
gl.glVertex3f(0, 5*h, 0)
gl.glVertex3f(0, 0, 0)
def vertical_ind(place, val, color):
gl.glColor4f(color[0], color[1], color[2], 1)
gl.glVertex3f((place+0)*s, h + h*val, 0)
gl.glVertex3f((place+1)*s, h + h*val, 0)
gl.glVertex3f((place+1)*s, h, 0)
gl.glVertex3f((place+0)*s, h, 0)
def horiz_ind(place, val, color):
gl.glColor4f(color[0], color[1], color[2], 1)
gl.glVertex3f((place+0)*s, 4*h , 0)
gl.glVertex3f((place+val)*s, 4*h, 0)
gl.glVertex3f((place+val)*s, 2*h, 0)
gl.glVertex3f((place+0)*s, 2*h, 0)
true_speed = np.sqrt(np.square(self.car.hull.linearVelocity[0]) + np.square(self.car.hull.linearVelocity[1]))
vertical_ind(5, 0.02*true_speed, (1,1,1))
vertical_ind(7, 0.01*self.car.wheels[0].omega, (0.0,0,1)) # ABS sensors
vertical_ind(8, 0.01*self.car.wheels[1].omega, (0.0,0,1))
vertical_ind(9, 0.01*self.car.wheels[2].omega, (0.2,0,1))
vertical_ind(10,0.01*self.car.wheels[3].omega, (0.2,0,1))
horiz_ind(20, -10.0*self.car.wheels[0].joint.angle, (0,1,0))
horiz_ind(30, -0.8*self.car.hull.angularVelocity, (1,0,0))
gl.glEnd()
self.score_label.text = "%04i" % self.reward
self.score_label.draw()
示例12: run
def run(self):
while not self.has_exit:
dt = pyglet.clock.tick()
self.dispatch_events()
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glLoadIdentity()
self.shader.use()
self.shader["real"] = self.real
self.shader["w"] = self.w
self.shader["imag"] = self.imag
self.shader["h"] = self.h
gl.glBegin(gl.GL_QUADS)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, self.height, 0.0)
gl.glVertex3f(self.width, self.height, 0.0)
gl.glVertex3f(self.width, 0.0, 0.0)
gl.glEnd()
self.shader.stop()
if self.show_fps:
self.fps.draw()
if self.auto_zoom_in:
self.zoom_in(dt)
if self.auto_zoom_out:
self.zoom_out(dt)
self.key_move(dt=dt)
self.flip()
示例13: draw
def draw(self, scale, pos):
LINE_COLOUR = (255, 255, 255)
# gl.glEnable(gl.GL_DEPTH_TEST);
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_DONT_CARE)
gl.glBegin(gl.GL_LINES)
for link in self.links:
if link.highlight:
gl.glColor3ub(*self.colour)
gl.glColor3ub(*self.colour)
else:
gl.glColor3ub(*LINE_COLOUR)
gl.glColor3ub(*LINE_COLOUR)
if link.highlight:
depth = 0.5
else:
depth = 0.5
gl.glVertex3f(*util.add_tup(pos, util.scale_tup(link.points[0].pos, scale)) + (depth,))
gl.glVertex3f(*util.add_tup(pos, util.scale_tup(link.points[1].pos, scale)) + (depth,))
print util.add_tup(pos, util.scale_tup(link.points[0].pos, scale))
gl.glEnd()
示例14: _set_texture
def _set_texture(self, t):
self._texture = t
from pyglet import gl
try:
gl.glFramebufferTexture2DEXT(
gl.GL_FRAMEBUFFER_EXT,
gl.GL_COLOR_ATTACHMENT0_EXT,
t.target, t.id, 0,
)
except gl.GLException:
# HACK: Some Intel card return errno == 1286L
# which means GL_INVALID_FRAMEBUFFER_OPERATION_EXT
# but IT ACTUALLY WORKS FINE!!
pass
gl.glViewport(0, 0, t.width, t.height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluOrtho2D(0, t.width, 0, t.height)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
# ATI cards hack
gl.glBegin(gl.GL_LINES)
gl.glEnd()
示例15: draw_points
def draw_points(self):
self.points_lock.acquire()
try:
from pyglet.gl import glCallList, glBegin, GL_LINE_STRIP, glColor4f, glVertex2f, glEnd
# line from previous iterate to next iterate of function
glBegin(GL_LINE_STRIP)
glColor4f(1, 1, 1, 0.3)
state_index = self.state_indices[0]
for i in [1, 2]:
state_previous = self.point.state[state_index]
self.point.state = self.system.iterate(self.point.state, self.point.parameters)
glVertex2f(state_previous, state_previous)
glVertex2f(state_previous, self.point.state[state_index])
glEnd()
# call display lists, doesn't work in init_points()
if self.server.iteration <= 1:
glCallList(self.iterate_list)
glCallList(self.reflection_list)
except Exception, detail:
print "draw_points()", type(detail), detail