By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,653 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,653 IT Pros & Developers. It's quick & easy.

Detecting the change of screen resolution with SDL or PyGame

P: n/a
Hello All,

I am trying to clean up some polish bugs with the Shanghai game I am
working on and I am currently stuck on trying to get the right event
for detecting when the user has changed the desktop resolution.

I have tried trapping the following events:


These are the events that are passed through to pygame as
pygame.ACTIVEEVENT and so on...

#3 - SDL_VIDEORESIZE This is what I looked at first and I was wrong,
this is only for the WINDOW being resized... not the desktop resoltion

#2 - SDL_VIDEOEXPOSE After watching the events in a debugger when I
change the desktop resolution I find out that this IS the event that is
generated from changing the desktop resolution. Okay no problem right?
Time to call:

self.screen = self.pygame.display.set_mode( size )

and draw() again right?

Well sure, now my game repaints properly when the desktop resolution
changes. So What is the problem? Well now EVERY TIME another window
draws on top of my game's window a SDL_VIDEOEXPOSE event is triggered.
There does not appear to be any flags associated with this event. So I
am having trouble distinguishing from an overlapping window and
changing the desktop resolution.

So I tried this:

1) call pygame.display.Info() at the startup of my game and save off
this structure
2) call it again after getting a SDL_VIDEOEXPOSE event and comparing to
see if it has changed at all.

The problem with this is that apparantly the VidInfo structure DOES NOT
change when changing desktop resolution...

So then I tried using SDL_ACTIVEEVENT and simply leaving the display
black and unpainted after the user changes the resolution until the
user rolls the mouse over the game window and bringing it back to

This works. However, it gets annoying watching the screen repaint
everytime the window gains focus....

Do you guys have any leads for me to try? This HAS to be a problem
solved many times before...

Thank you,

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.