On Mon, Aug 18, 2014 at 6:07 AM, Ronald Pandolfi <[email protected]> wrote:
> If I load a tile map with cocos2d, how can I give it the 'retro' look of > nearest interpolation? With pyglet I would set glTexParameteri, but I don't > know how to apply that to a cocos tile layer. Any tips? Thanks > -- > Theres no direct support for pixelated tilemaps in cocos, but maybe it can be done with some work. As a quick and dirty prof of concept, I patched pyglet from repo as seen in the attachment pixelated_pyglet.diff , and modified the stock cocos/test/test_tiles.py as in the attached test_tiles_pixelated.py. To run, put in the cocos/test directory so resources are found, and then press z to zoom into a pixelated view. For extra pixelated view, you can use a road-tiles.png not antialiased, like the attached. This gives the pixelated view, but the car sprite in motion looks awful. This is due to stock Sprites having int vertex coordinates. While this defect can be corrected in code, (Sprite._update_position) I would probably resize the art and let alone the stock pyglet + cocos. -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" 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/cocos-discuss. For more options, visit https://groups.google.com/d/optout.
diff -r 7f99b5234f7b pyglet/sprite.py
--- a/pyglet/sprite.py Wed Jul 16 17:45:21 2014 +0100
+++ b/pyglet/sprite.py Tue Aug 19 00:52:10 2014 -0300
@@ -142,6 +142,8 @@
def set_state(self):
glEnable(self.texture.target)
glBindTexture(self.texture.target, self.texture.id)
+ gl.glTexParameteri(self.texture.target, gl.GL_TEXTURE_MAG_FILTER,
gl.GL_NEAREST)
+ gl.glTexParameteri(self.texture.target, gl.GL_TEXTURE_MIN_FILTER,
gl.GL_NEAREST)
glPushAttrib(GL_COLOR_BUFFER_BIT)
glEnable(GL_BLEND)
test_tiles_pixelated.py
Description: Binary data
