How can I resize pixel art in Pyglet without making it blurry?

Posted by Renold on Game Development See other posts from Game Development or by Renold
Published on 2011-11-27T21:09:28Z Indexed on 2011/11/28 10:48 UTC
Read the original article Hit count: 715

Filed under:
|
|

I have a tileset of 8x8 pixel images, and I want to resize them in my game so they'd be double that (16x16 pixels, e.g. turning each pixel into a 2x2 block.) What I'm trying to achieve is a Minecraft-like effect, where you have small pixel images scale to larger blockier pixels.

In Pyglet, the sprite's scale property blurs the pixels. Is there some other way?

Update:

So I changed my code, but I'm still having the same issue (nothing changed.) Of course, the GL commands are kind of mysterious to me:

gl.glEnable(gl.GL_TEXTURE_2D)                                                                                                                                                                               
image = resource.image('tileset.png')                                                                                                                                                               
texture = image.get_texture()   
gl.glBindTexture(gl.GL_TEXTURE_2D, texture.id)                                                                                                                                                      
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)                                                                                                                               
texture.width = 16 # resize from 8x8 to 16x16                                                                                                                                                                  
texture.height = 16                                                                                                                                                                                                                                                                                                                       
image.blit(100, 30) # draw                                                                                                                                                                        

Is there something else I should try?

© Game Development or respective owner

Related posts about python

Related posts about image