Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to scale a window's contents so that every pixel displays at a multiple of it's normal size. Basically I want to achieve larger pixels without scaling each and every individual sprite. This question is very similar to this one, however that only scales a single sprite. How should I go about this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Ended up figuring out the answer myself through trial and error, solution follows.

You need to import openGL to get access to the scaling function:

from pyglet.gl import *

Next, toss in the following code after your game's window has been initialized:

#These arguments are x, y and z respectively. This scales your window.
glScalef(2.0, 2.0, 2.0)

At this point your resolution will double, but your window will stay the same size. You can correct this easily by doubling your window's width and height. Furthermore, your textures will appear blurry, so we need to fix that. We need to set parameters for the textures in your on_draw() function:

def on_draw(self):
        self.clear() #clears the screen
        #The following two lines will change how textures are scaled.
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
        self.label.draw() #blits the label to the screen

You should now have pixels displaying at double their original size.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.