Graphics Windows are non-centred on Mac

Archives Forums/BlitzMax Bug Reports/Graphics Windows are non-centred on Mac

Grey Alien(Posted 2007) [#1]
hi, if you run this:

Strict
'Graphics 800,600,32 'full-screen
'EndGraphics
Graphics 800,600,0 'windowed

While Not KeyHit(key_escape)
Cls
Flip
Wend

You'll see that the graphics window is centred horizontally and place near the top of the desktop. Fine. I'm wondering if the is Mac OSX doing the centreing and not BMax because on Windows PCs the Graphics window is NOT centred.

BUT if you uncomment the Graphics 800,600,32 which starts the app in full-screen mode first and also uncomment End Graphics, you'll notice that the final graphics window is drawn in the bottom left of the desktop instead of being centred, weird.

The mini-code above is supposed to simulate having a game that starts in full-screen then the user switches to windowed mode. They will expect the windowed mode to appear centred and not in a funny location.

I don't want to use MaxGUI for this so is there a fix/enhancement that can be applied to the code which creates a graphics window to centre it? Even a flag for centreing would be very useful as on PCs I have to "manually" centre it after it's created with an API call. Perhaps there's a MacOSX equivalent?

Many thanks in advance for your help with this.


marksibly(Posted 2007) [#2]
Can't reproduce.

Here, the windowed mode window always appears 'up a bit' from center, which is what the Mac does when you call 'center' on a window.


Grey Alien(Posted 2007) [#3]
Thanks for testing. Mark, you did uncomment those two lines did you? That's when the window is shown non-centred.

Can anyone else reproduce this on OSX 10.4?


DavidDC(Posted 2007) [#4]
On Intel Leopard, if I attempt the full screen version above (ie uncomment graphics & end graphics and comment the windowed graphics call) I get an unhandled exception: attempt to field or method of null object.

If I then comment out the end-graphics line, then no exception is raised and the fullscreen placement seems correct.

If I uncomment all lines then windowed version works ok. Window is slightly high vertically but centred horizontally.


Grey Alien(Posted 2007) [#5]
Hi David. Ah, you need to uncomment graphics (full screen) and end graphics and LEAVE the windowed graphics call in like this:

Strict
Graphics 800,600,32 'full-screen
EndGraphics
Graphics 800,600,0 'windowed

While Not KeyHit(key_escape)
Cls
Flip
Wend

This is to simulate a user starting a game in full-screen mode and later on changing to windowed mode on an options page. (Which you can do in my framework and it exhibits the same behaviour).

The reason you got an unhandled exception is after EndGraphics there is NO current graphics object and then Cls (and Flip) will fail of course :-)


DavidDC(Posted 2007) [#6]
Ah I see. Guess who's never used max in fullscreen? : )

Anyway, with all lines uncommented in Leopard the window is centred, slightly high.

-David


Grey Alien(Posted 2007) [#7]
How odd, as in 10.4 (on my Macbook Pro) it is NOT centred.


Yan(Posted 2007) [#8]
There isn't some windows management setting that you've enabled, is there?

I was having similar problems with centred windows in Linux, until I realised I'd enabled intelligent window alignment in the desktop manager.


Grey Alien(Posted 2007) [#9]
I haven't changed any of the Mac settings as I'm such a Mac noob. Basically a Blitz app that STARTS in windowed mode is centred near the top, but one that starts full screen then CHANGES to windowed mode is not centred...


JazzieB(Posted 2007) [#10]
I'll have to check to be sure, but I'm fairly certain that my games (when started in full-screen) end up in the top-left corner and not at the bottom! Games started windowed are just high of centre.


marksibly(Posted 2007) [#11]
Hi,

Ok, I can get it to happen on 10.4 but not on 10.5.

Sticking a 'PollSystem' after EndGraphics appears to fix it - Looks like the OS thinks it's still in 800x600 mode when centering the new window.


Grey Alien(Posted 2007) [#12]
Great thanks Mark, will test this workaround ASAP! I trust that PollSystem has no ill effects on 10.5.

[Edit]Yep it worked in 10.4, thanks.


BlackSp1der(Posted 2007) [#13]
here's my fix. XD
Graphics 800,600,0
EndGraphics
Graphics 800,600,32
.
.
.
EndGraphics
Graphics 800,600,0 'centered


Grey Alien(Posted 2007) [#14]
haha :-) But it will make a messy window appear for a fraction of second right at the start of a full-screen game.


Grisu(Posted 2007) [#15]
Same goes for the windows version.


QuickSilva(Posted 2008) [#16]
It would be a nice addition to be able to create a centered window. Will this feature be added in a future version?

Jason.