changing graphics modes

BlitzMax Forums/BlitzMax Beginners Area/changing graphics modes

is there any way to change what graphic mode you are in while your program is running? i want to present users with a dialog box where they can change what resolution and weather they want windowed of full screen mode.

if it makes any difference, i'm using bMax1.10 on mac os x

cheers
charlie

To change graphics mode when the program is running I would assume it would be something like this...

Graphics 800,600,16,0

While Not KeyHit(KEY_ESCAPE)

	SetColor 255,255,255
	DrawText "Select graphics mode:",20,20
	DrawText "--------------------",20,40
	DrawText "1) Fullscreen mode",20,60
	DrawText "2) Windowed mode",20,80
	
	' change to fullscreen mode
	If KeyHit(KEY_1)
		EndGraphics
		FlushMem
		Graphics 800,600,16,0
	EndIf
	
	' change to windowed mode
	If KeyHit(KEY_2)
		EndGraphics
		FlushMem
		Graphics 800,600,0,0
	EndIf

	Flip
	FlushMem
	Cls
Wend
End


But if you change to windowed mode and then change back to fullscreen I get a unhandled memory exception error.

Can anybody tell me if this a bug or am I coding something wrong here?

yep, my program looks similar to that.

i get this error: "2005-06-10 13:09:02.274 boxtest[17583] invalid drawable"

when trying to change to anything, also im starting in windowed mode.

.
waited far too long to post

waited far too long to post

Is my code correct then? Is it a bug?

it would appear to be a problem with the graphics command in some manner yes.

SetGraphicsDriver(GLMax2DDriver())
Graphics 800,600,0,0

Global usingBGL = False

While Not KeyHit(KEY_ESCAPE)

	SetColor 255,255,255
	
	If usingBGL Then
		bglDrawText "Select graphics mode:",20,20
		bglDrawText "--------------------",20,40
		bglDrawText "1) Fullscreen mode",20,60
		bglDrawText "2) Windowed mode",20,80
		
	Else
		
		DrawText "Select graphics mode:",20,20
		DrawText "--------------------",20,40
		DrawText "1) Fullscreen mode",20,60
		DrawText "2) Windowed mode",20,80

	EndIf

	
	' change to fullscreen mode
	If KeyHit(KEY_1)
		EndGraphics
		FlushMem
		
		usingBGL =True
		'Graphics 800,600,32,0
		bglCreateContext(800,600,16,0, BGL_FULLSCREEN|BGL_BACKBUFFER)
		
	EndIf
	
	' change to windowed mode
	If KeyHit(KEY_2)
		'EndGraphics
		bglSwapBuffers()
		bglDeleteContext
		FlushMem
		usingBGL = False
		Graphics 800,600,0,0
	EndIf


	If usingBGL then
		bglSwapBuffers()
		FlushMem
	Else
		Flip
		FlushMem
		Cls
	EndIf
Wend
End



I was messing around with it and you can create a fullscreen GL context and switch back to window mode without issue (it does stop rendering the text when you switch to fullscreen for the second time, but that's *probably* a seperate issue).
There is no exception produced using the above.

...Wot e said...^^^^^^^

Although I didn't have any font problems.

cheers Perturbatio, hadn't realised there was a command called endgraphics

cheers
charlie

Oh wait, after reading it properly...Not what he said.

The first code sample works perfectly if you set the gl driver first. So probably a bug with the DX7 implementation.
SetGraphicsDriver GLMax2DDriver()

Graphics 800,600,16,0

While Not KeyHit(KEY_ESCAPE)

	SetColor 255,255,255
	DrawText "Select graphics mode:",20,20
	DrawText "--------------------",20,40
	DrawText "1) Fullscreen mode",20,60
	DrawText "2) Windowed mode",20,80
	
	' change to fullscreen mode
	If KeyHit(KEY_1)
		EndGraphics
		FlushMem
		Graphics 800,600,16,0
	EndIf
	
	' change to windowed mode
	If KeyHit(KEY_2)
		EndGraphics
		FlushMem
		Graphics 800,600,0,0
	EndIf

	Flip
	FlushMem
	Cls
Wend
End


only the second example works for me

however, on the second interation of the mode change, you cannot see the text in fullscreen mode.

I can keep clicking on full frame mode (1) and gives new full frame, and it can go to window mode where and if I keep clicking window mode(2) it creates a new window every time but from window mode if I click full frame it exits with out an esc.