[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame 1.8 - problem with framerate



hi,

yeah, I'm pretty sure this is the case... usually blitting is the slow
part - and with most older computers, directx is the fast path.
There's also been a couple of other reports of 1.8 being slower on
their computers...

I've committed something for lib/__init__.py  ...  that uses directx
for older windows versions.  It's untested so far, I'll boot up my
windows machines and see if it works there.  I can only test on xp,
and vista at the moment.


These should run on older versions of windows.

----
import pygame, os
assert(os.environ.get('SDL_VIDEODRIVER', '') == 'directx')



------  this one should respect the driver set by the user.
import os
os.environ['SDL_VIDEODRIVER'] = 'windib'
import pygame
assert(os.environ.get('SDL_VIDEODRIVER', '') == 'windib')


cu,


On Sat, Jun 7, 2008 at 11:19 AM, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> Let's wait until Pedro Vieira confirms he is using Windows and that setting
> SDL_VIDEODRIVER solves his problem. If so then yes we could patch
> __init__.py to set SDL_VIDEODRIVER if it is not already set. Personally, I
> see a 6X increase in framerate enabling directx for the test case below.
>
> Lenard
>
>
> René Dudfield wrote:
>>
>> hi,
>>
>> this is probably because your computer has faster directx 2d driver
>> than windib driver.
>>
>> We had to follow SDLs change of default driver, because the directx
>> driver is broken on some platforms.
>>
>> However you can set the old directx driver.
>> os.environ["SDL_VIDEODRIVER"] = "directx"
>>
>> I would recommend wrapping it in some OS detection - so your game
>> would still work on the platforms where the directx driver is broken.
>>
>> Lenard: Maybe we can make this behaviour default in pygame 1.8.1... ?
>> What do you think?
>> We could use the platform module to detect if it's win9x, win2k etc,
>> then select the directx driver if so.
>>
>> If you reckon, it's a good idea, I'll try and make a patch for the OS
>> detection.
>>
>>
>>
>>
>> On Sat, Jun 7, 2008 at 4:33 AM, Pedro Vieira <pesvieira@xxxxxxxxx> wrote:
>>
>>>
>>> Hi.
>>>
>>> I updated the version of pygame, 1.7.1 to 1.8, and I had problem with
>>> that.
>>> My game started to become very slow, only by exchanging version. I was
>>> looking to see what was happening and saw that the fps was very low. I
>>> created a simple code to test and I saw that for the same code, ran on
>>> both
>>> versions, there is a big difference in FPS. What may be happening?
>>>
>>> Thank you.
>>>
>>>
>>> The code that I used for test is below:
>>>
>>> import pygame
>>>
>>> class Game:
>>>       screen = None
>>>       screen_size = None
>>>       run = True
>>>
>>>       def __init__( self, size, fullscreen):
>>>               pygame.init()
>>>               flags = pygame.DOUBLEBUF
>>>               if fullscreen:
>>>                       flags = (pygame.FULLSCREEN | pygame.DOUBLEBUF |
>>> pygame.HWSURFACE)
>>>               self.screen = pygame.display.set_mode( size, flags )
>>>
>>>       def handle_events( self ):
>>>               for event in pygame.event.get():
>>>                       if ((event.type == pygame.KEYDOWN)or(event.type ==
>>> pygame.KEYUP)):
>>>                               if (event.key == pygame.K_ESCAPE):
>>>                                       self.run = False
>>>
>>>       def loop( self ):
>>>               clock = pygame.time.Clock()
>>>               while (self.run):
>>>                       clock.tick()
>>>                       print clock.get_fps()
>>>                       self.screen.fill((255,255,255))
>>>                       self.handle_events()
>>>                       pygame.display.flip()
>>>
>>>
>>> game = Game((1024,768), 1)
>>> game.loop()
>>>
>
>