python - Pyglet not running properly on AMD HD4250 -
i building python program using pyglet. source code runs fine on computer exept laptop. laptop 1 amd graphics card: hd4250. xubuntu 13.04 amd64, , graphics drivers x11 open source ones. how looks:
when adding clear statement in constructor screen gets build properly, incredebly slow. refresh @ max 2 times per 30 seconds , barely respond input. how can fix this?
it not seem opengl problem: when using qt opengl (c++ also) there no problems @ all.
some (hopefully relevant) code:
def draw(self): pyglet.text.label('start screen', font_name='arial', font_size=16, x=self.window.get_size()[0]/2, y=self.window.get_size()[1]-20, anchor_x='center', anchor_y='center').draw() pyglet.text.label('this side looking @ enemy', font_name='arial', font_size=16, x=self.window.get_size()[0]/2, y=self.window.get_size()[1]-60, anchor_x='center', anchor_y='center').draw() pyglet.text.label(self.bottumtext, font_name='arial', font_size=16, x=self.window.get_size()[0]/2, y=20, anchor_x='center', anchor_y='center').draw() y in range(0, len(self.fields)): field in self.fields[y]: if (field.selected): glcolor3f(self.color[0], self.color[1], self.color[2]) # glcolor3f(1, 0, 1) else: glcolor3f(1, 1, 1) # draw center # self.drawcircle(field.x, field.y, 5, [1, 1, 1]) # # draw top side pyglet.graphics.draw(2, pyglet.gl.gl_lines, ('v2i', (field.x + field.size, field.y + field.size, field.x - field.size, field.y + field.size))) # draw down side pyglet.graphics.draw(2, pyglet.gl.gl_lines, ('v2i', (field.x + field.size, field.y - field.size, field.x - field.size, field.y - field.size))) # draw left side pyglet.graphics.draw(2, pyglet.gl.gl_lines, ('v2i', (field.x - field.size, field.y - field.size, field.x - field.size, field.y + field.size))) # draw right side pyglet.graphics.draw(2, pyglet.gl.gl_lines, ('v2i', (field.x + field.size, field.y - field.size, field.x + field.size, field.y + field.size)))
what following code produce:
(it's not limited frame buffer per se might produce better output)
#!/usr/bin/python import pyglet time import time, sleep class window(pyglet.window.window): def __init__(self, refreshrate): super(window, self).__init__(vsync = false) self.frames = 0 self.framerate = pyglet.text.label(text='unknown', font_name='verdana', font_size=8, x=10, y=10, color=(255,255,255,255)) self.last = time() self.alive = 1 self.refreshrate = refreshrate self.click = none self.drag = false def on_draw(self): self.render() def on_mouse_press(self, x, y, button, modifiers): self.click = x,y def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): if self.click: self.drag = true print 'drag offset:',(dx,dy) def on_mouse_release(self, x, y, button, modifiers): if not self.drag , self.click: print 'you clicked here', self.click, 'relese point:',(x,y) else: print 'you draged from', self.click, 'to:',(x,y) self.click = none self.drag = false def render(self): self.clear() if time() - self.last >= 1: self.framerate.text = str(self.frames) self.frames = 0 self.last = time() else: self.frames += 1 self.framerate.draw() self.flip() def on_close(self): self.alive = 0 def run(self): while self.alive: self.render() # ----> note: <---- # without self.dispatc_events() screen freeze # due fact don't call pyglet.app.run(), # because have control when , locks # application, since pyglet.app.run() locking call. event = self.dispatch_events() sleep(1.0/self.refreshrate) win = window(23) # set fps win.run()
you try force specific drawing methods might work open driver you're using, stuff like:
glenable(gl_texture_2d)
and
glclear(gl_color_buffer_bit) glloadidentity() glbegin(gl_triangles) glvertex2f(0, 0) glvertex2f(window.width, 0) glvertex2f(window.width, window.height) glend()
Comments
Post a Comment