switching from windowed to fullscreen problems...

BlitzMax Forums/BlitzMax Beginners Area/switching from windowed to fullscreen problems...

DREAM(Posted 2007) [#1]
hi i was just wondering if anyone knows why when i un rem the below code, and when i try the fullscreen option, my code starts playing up with carious unhandled exceptions depending on what parts of the code i have loaded.

Graphics 1024,768,wind,75
SetBlend(alphaBlend )
SetMaskColor 0,0,0
AutoMidHandle 1

'	wind=1
'	
'	Repeat
'		Cls
'		DrawText "Pick window or fullscreen.",10,10
'		DrawText "[W] indowed",10,40	
'		DrawText "[F] ullscreen",10,70
'		If KeyHit(key_w) Then wind=0
'		If KeyHit(key_f) Then wind=32
'		Flip
'	Until wind<>1
'	
'	If wind<>0
'		Graphics 1024,768,wind,75
'		SetBlend(alphaBlend )
'		SetMaskColor 0,0,0
'		AutoMidHandle 1
'	EndIf


now the game works when in '0' or windowed mode fine and '32' fullscreen to just on its own with no remmed bit, but when i try to add the option, something happens when the app recalls the graphics command...


do i have to close the old graphics(original) command somehow.......i'm stuck....


Grey Alien(Posted 2007) [#2]
You don't have to close the original Graphics window because it calls EndGraphics automatically. I can't see anything wrong. Maybe someone else can.


tonyg(Posted 2007) [#3]
Didn't older version of BlitzMax need the images to be reloaded?
Anyway, does this work OK...
Graphics 800 , 600
Local image:timage = LoadImage("max.png")
While Not KeyHit(KEY_ESCAPE)
	Cls
	DrawImage image , MouseX() , MouseY()
	Flip 1
	If MouseHit(1) Graphics 800 , 600 , 32
	If MouseHit(2) Graphics 800 , 600
Wend



GfK(Posted 2007) [#4]
You might get a more useful error message if you turn Debug on.

Couple of pointers about your code tho (I'm not suggesting they're responsible for the problem though!).

1. Drop the 'Hz' flag from your Graphics declaration. You don't really need it.
2. Get into the habit of using True/False instead of 1/0. It makes your code easier to read.


Grey Alien(Posted 2007) [#5]
He could use True for AutoMidHandle but the wind flag is sometimes 32, so it doesn't make sense to use true/false - well not to me anyway. Really wind should be called depth and shouldn't be used as a Repeat loop control variable by testing for when it's not 1. A new variable would be clearer.

The Hz flag has it's uses. In full-screen mode you could make it non-60Hz (the default) but I wouldn't from fear of incompatibility. Also if Flip 1 fails to vSync for some reason or you use Flip -1, the Hz parameter is used by Bmax to do the timing of the flips. Furthermore in windowed mode you can sync Hz with the desktop Hz for use with Flip 1, but you'll get a single (possibly moving) tear on the window at a random height. Actually I now agree with GfK, don't use it :-)

Anyway, yeah turn on debug mode and you'll get more meaningful errors.


MGE(Posted 2008) [#6]
So, what is the proper procedure for going from windowed to full screen and back again?

In my code I'm simply calling this each time the window variable is changed:

EndGraphics()
GCCollect()
ShowMouse()
If SetupGraphicsScreen() = False
Notify "Could not create graphics screen. Exiting..."
End
EndIf
HideMouse()

And it works fine. But I'm wondering if we need to do anything about our image resources or check for any flags?