When blitting textureatlas images to screen with non-integer
coordinates (really necessary for visually appealling and smooth
scrolling/movement) there are sampling artifacts from adjacent
textures in the atlas.
There should perhaps be an option to have the atlas addition algorithm
leave a 1 pixel, zeroed alpha channel border around each sub-texture?
The following code shows this:
nb.
ball.png = small png with alpha
other.png = png with pixels covering whole area (ie. no alpha at
edges)
from pyglet import image
from pyglet import window
from pyglet.gl import *
# Set these to the size of your background image
win = window.Window(width=768, height=768)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
# Set these paths to a couple of graphics
atlas = pyglet.image.atlas.TextureAtlas (width=1024, height=1024)
ball = image.load('ball.png')
ball_atlas = atlas.add (ball)
other = image.load('other.png')
other_atlas = atlas.add (other)
background = image.load('space.jpg')
ball_coords = [0,0]
ball_velocity = [0.334545,0.25345]
while not win.has_exit:
win.dispatch_events()
ball_coords[0] += ball_velocity[0]
ball_coords[1] += ball_velocity[1]
if ball_coords[0] > win.width - ball.width or ball_coords[0] < 0:
ball_velocity[0] = -ball_velocity[0]
if ball_coords[1] > win.height - ball.height or ball_coords[1] <
0:
ball_velocity[1] = -ball_velocity[1]
win.clear()
background.blit(0, 0)
ball.blit(*ball_coords)
ball_atlas.blit (ball_coords[0]+45, ball_coords[1])
win.flip()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---