CreateGraphics() weirdness

BlitzMax Forums/BlitzMax Programming/CreateGraphics() weirdness

Russell(Posted 2009) [#1]
In the following code, the second :TGraphics object will always be Null:
Local win:TGraphics = CreateGraphics(1280,720,0,60,0)
Local full:TGraphics = CreateGraphics(1280,720,32,60,0) 'The second one will always be Null!

If win
	SetGraphics(win)
	Cls
	DrawText("windowed mode",0,0)
	Flip
	Delay(3000)
	CloseGraphics(win)
EndIf
If full
	SetGraphics(full)
	Cls
	DrawText("fullscreen mode",0,0)
	Flip
	Delay(3000)
EndIf

In the code above, win will work fine but full will fail. If you reverse the order of the first two lines then full will work and win will fail. Perhaps I'm not quite understanding what CreateGraphics does, but my understanding was that it didn't actually establish any graphics modes until you use it with SetGraphics().
And, yes, these modes are both available on my computer (they both work individually just fine).

Any ideas?

Russell
[EDIT: BTW, I had to use Delay(3000) because even when the gfx mode is established (the one that's not Null) the keyboard polling doesn't seem to work...]
[EDIT2: I'm using BMX 1.33 pentium 4 2.6GHz 1.5GB GForce 8400GS 512MB]


marksibly(Posted 2009) [#2]
Hi,

Fullscreen graphics are 'exclusive' - there can only be one and you can't create a windowed graphics if a fullscreen graphics already exists (and vice versa).

We tried getting this to work so that the display mode switch occured when you did the SetGraphics, but couldn't get it happening due to driver weirdness and other factors.


Russell(Posted 2009) [#3]
Ah, that's too bad. It would be nice to have various modes pre-prepared that you could switch between with SetGraphics(). So this begs the question, what is the intended purpose of CreateGraphics()/SetGraphics() then?

I know I've done this before, though I think I just used EndGraphics and issued another Graphics() with the new resolution.

Anyway, thanks for the reply, Mark.

Russell


Russell(Posted 2009) [#4]
You know, I was sitting here thinking how not actually setting the graphics mode until SetGraphics() is encountered could be a problem and I can't think of one! I mean, the TGraphics object is just storing information about a potential future graphics mode. How could this cause problems? (I know that TGraphics also has other functionality, but they wouldn't be called in this case, would they?)

Just curious..

Keep up the good work!

Russell


plash(Posted 2009) [#5]
We tried getting this to work so that the display mode switch occured when you did the SetGraphics, but couldn't get it happening due to driver weirdness and other factors.
I bet it wouldn't be too hard to do with just OpenGL if you ditch the DirectX drivers ;)