At the request of commenters...
Warning to Pyglet professionals: There may be a nice Pyglet way to do this, and this isn't it. It's a nice OpenGL way. You have been warned!
You can do this in OpenGL by first binding the texture, then calling glTexParameteri or similar varients. You can do this in Pyglet by importing OpenGL:
from pyglet.gl import *
You can then enable GL_TEXTURE_2D to set the target. This is not always needed, but I'm keeping this complete for some other bindings.
glEnable(GL_TEXTURE_2D)
In Pyglet, it seems like you don't have to bind the texture either. Sometimes you have to load in your image, get the texture id, then use glBindTexture(GL_TEXTURE_2D, texture.id). My assumption that these are already the state set for you in Pyglet.
The next step is to call glTexParameteri. Thanks to Jimmy on correcting me on this: the correct call is:
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
A quick break down: the first is just to set the target so OpenGL knows what you're talking about, then the second parameter is the type of filter you would like to set. MAG_FILTER is correct because it controls the magnifications of textures. The final parameter is GL_NEAREST, which controls how the texture is scaled. GL_NEAREST is basically a fast scale that gives pixel-styled textures. GL_LINEAR is normal and will instead smoothly blur your texture.
This version of OpenGL I'm talking about (about < OpenGL 3.2 officially) uses immediate mode, which sets the state. Now that the state is set, you can scale your texture. I can see no better than to show the code that Renold himself posted as working code.
image = resource.image('tileset.png') texture = image.get_texture() gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) texture.width = 16 # resize from 8x8 to 16x16 texture.height = 16 texture.blit(100, 30) # draw
from pyglet.gl import *and then make a call to talisman.org/opengl-1.1/Reference/glTexParameter.html withGL_NEAREST. \$\endgroup\$glEnable(GL_TEXTURE_2D). Then let's say you had a call toa = image.load('blah.jpg'). Assigntex = a.texturethenglBindTexture(GL_TEXTURE_2D, texture.id)and finally a call topyglet.gl.glTexParameteri(pyglet.gl.GL_TEXTURE_2D, pyglet.gl.GL_TEXTURE_MIN_FILTER, pyglet.gl.GL_NEAREST). I'm not too familiar with the namespace for OpenGL in python, so the I left the full call qualified. Since we imported OpenGL, I believe you can remove at least the pyglet in the front, and maybe gl too. \$\endgroup\$glTexParameteri. OpenGL 1/2/~3 which I presume Pyglet is based on have these immediate mode commands. That is, you execute a command to change the state, then everything after it will change. I'd begin by moving the calls underneath the gl calls. \$\endgroup\$