Issue 198 in los-cocos: [patch] TMX maps — tiles edges misrendering

26 views
Skip to first unread message

codesite...@google.com

unread,
Aug 10, 2013, 10:27:20 AM8/10/13
to cocos-...@googlegroups.com
Status: New
Owner: ----

New issue 198 by 2slow2ha...@gmail.com: [patch] TMX maps — tiles edges
misrendering
http://code.google.com/p/los-cocos/issues/detail?id=198

tiles.load_tiles() uses GL_CLAMP_TO_EDGE for proper edges rendering but
tiles.load_tmx() doesn't. I've modified a bit TileSet.from_atlas() to fix
it, see attachment.


Or you can use monkey-patch aswell

from pyglet import gl
from cocos import tiles

class TileSet_fixed_edges(tiles.TileSet):

@classmethod
def from_atlas(cls, name, firstgid, file, tile_width, tile_height):
image = pyglet.image.load(file)
rows = image.height / tile_height
columns = image.width / tile_width
image_grid = pyglet.image.ImageGrid(image, rows, columns)
atlas = pyglet.image.TextureGrid(image_grid)
id = firstgid
ts = cls(name, {})
ts.firstgid = firstgid
for j in range(rows-1, -1, -1):
for i in range(columns):
tile_image = image.get_region(atlas[j, i].x, atlas[j, i].y,
atlas[j, i].width, atlas[j, i].height)

gl.glBindTexture(tile_image.texture.target, id)
gl.glTexParameteri(tile_image.texture.target,
gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(tile_image.texture.target,
gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)

ts[id] = tiles.Tile(id, {}, tile_image)
id += 1
return ts

tiles.TileSet = TileSet_fixed_edges


Before/after: http://www.youtube.com/watch?v=CmtCvNGLikA

Attachments:
tiles.patch 1.1 KB

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

codesite...@google.com

unread,
Aug 10, 2013, 6:05:36 PM8/10/13
to cocos-...@googlegroups.com
Updates:
Status: TrunkFixed
Labels: Type-Defect Component-Tiles

Comment #1 on issue 198 by ccan...@gmail.com: [patch] TMX maps — tiles
edges misrendering
http://code.google.com/p/los-cocos/issues/detail?id=198

Thanks very much for patch and analysis.
Committed at r1239

If you want to give a name / nickname to acknowledge the patch in the
changelog, leave it here.
Reply all
Reply to author
Forward
0 new messages