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

detecting the change in desktop resolution - how?

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:

1) SDL_ACTIVEEVENT
2) SDL_VIDEOEXPOSE 3) SDL_VIDEORESIZE

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
focus.

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,
-Erik

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi !

On windows, and PyWin, this script give the H/V current resolution :

import win32com.client
oWMI = win32com.client.Dispatch("WbemScripting.SWbemLocat or")
owbem = oWMI.ConnectServer(".","root\cimv2")
collec = owbem.ExecQuery("Select * from Win32_PrinterConfiguration")
print "Horizontal Resolution: ", collec[0].HorizontalResolution
print "Vertical Resolution: ", collec[0].VerticalResolution


@-salutations
--
Michel Claveau

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.