Hi folks, My quest continues to learn pyglet, and then teach it to my high-school age son, who knows a little Python (and HTML and Javascript).
I have written a very simple, decorator-free Pyglet program. It combines features of the first two programs in the Pyglet programming guide. http://www.pyglet.org/doc/programming_guide/hello_world.html http://www.pyglet.org/doc/programming_guide/image_viewer.html Here is my code: ============================================================== import pyglet class MyWindow(pyglet.window.Window): def __init__(self): pyglet.window.Window.__init__(self) # super() doesn't work? self.label = pyglet.text.Label( 'Hello, world', font_name='Times New Roman', font_size=36, x = self.width//2, y = self.height//3, anchor_x='center', anchor_y='center') self.image = pyglet.resource.image('Earth 99x99.png') print(self.image.width, self.image.height) self.image_coord = ( (self.width - self.image.width)//2, 2*self.height//3 - self.image.height//2) def on_draw(self): self.clear() self.label.draw() self.image.blit(*self.image_coord) win = MyWindow() pyglet.app.run() ============================================================== My program works, but no matter what graphics file I use for win.image, I am running into an annoying problem. I eventually want to display irregular 2D images over an arbitrary (not just plain black) background. So, my images have an alpha channel. When I look at my source images in GIMP, they render exactly as I expect. However, when Pyglet renders the image, I get a smattering of unwanted dots in the transparent region, directly adjacent to the opaque parts of the image. It looks almost like old-fashioned dithering. I have this problem whether the source graphics file is a .GIF (where I might expect dithering) or a .PNG (where I do not expect dithering). Here is an image (with pixels suitably enlarged) which compares my source image to the Pyglet output: http://www.flickr.com/photos/15579975@N00/10448838095/ I give Pyglet the file shown in the left panel. The middle panel is what I WANT to see from Pyglet. The right panel is what I'm actually getting. Now, I understand that Pyglet is depending on the built-in OpenGL implementation on my computer (for 2D graphics, as well as for 3D?). Here is my configuration information: Ubuntu 13.04, AMD 64-bit (which presumably includes OpenGL) NVidia 460 GPU, Linux driver version 310.44 Python 3.3.1 Pyglet 1.2alpha1 Another program that I use on this computer employs Python and OpenGL, a 3D protein analysis package called PyMol. Its renderings look beautiful. Any advice is appreciated! -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/groups/opt_out.
