title: Pygame/SDL Low Framerate at HD
body: <p>I know similar stuff like this has been asked before but I couldn't find an answer beyond "don't redraw the whole screen at once" which really isn't an option for a scrolling 2D shooter, where even if I didn't update the whole screen when not necessary, a player wouldn't notice framerates unless you moved anyway, which is when the whole screen would need to redraw...</p>
  
  <p>So as for how the game is rendered, the entire game is drawn onto a 480*270 surface (renderLayer), which is then scaled up to the screen size at the end of the render function, before the display is flipped.</p>
  
  <p>Running the game in a 480*270 window yields framerates in the hundreds, but as soon as the game is ran in 1080p, I'm lucky to get between 45 and 60fps. Keep in mind the only part that changes in the entire code is the scaling up at the end of each update frame then flipping the buffer onto the screen, so the rest of the code is irrelevant to this performance drop. </p>
  
  <p>The display is initialised like so:</p>
  
  <pre><code>os.environ['SDL_VIDEODRIVER'] = 'windib'
  pygame.init()
  display = pygame.display.set_mode((0,0),FULLSCREEN|DOUBLEBUF|HWSURFACE)
  </code></pre>
  
  <p>I used windib because it yielded very slightly higher framerates than the default driver.</p>
  
  <p>And the end of the rendering, after all the objects have been blit onto the renderLayer.</p>
  
  <pre><code>display.blit(pygame.transform.scale(renderLayer,display.get_size()),(0,0))
  pygame.display.flip()
  clock.tick()
  print(clock.get_fps())
  </code></pre>
  
  <p>Keep in mind I usually use clock.tick(60), as it's useful for keeping everything at the right speed, especially in multiplayer where syncronization is important, but for framerate testing I leave it as just clock.tick() so I can get an accurate representation of performance changes.</p>
  
  <p>So does anyone know if there's a way to increase framerates at higher resolutions or another method of scaling up to the display? I've heard about using openGL for the display, but blitting to these surfaces is  no longer possible from standard pygame surfaces, from what I can tell in experimentation.</p>
  
  <p>Sorry if the code posted is quite short, but with a 2000+ line of code game I didn't want to waste everyone's time with code that doesn't make a difference to framerates between low and high resolutions (display is not referenced or used at all throughout the rest of the functions in the game loop - everything uses the renderLayer for actual drawing of frame).</p>
  
  <p>Many thanks in advance to anyone who gave their time reading and/or answering my query, and I also apologise if this is too specific a question for this site. I wouldn't know where else to ask.</p>