DXERROR err = WRONGMODE

BlitzMax Forums/BlitzMax Programming/DXERROR err = WRONGMODE

Grey Alien(Posted 2007) [#1]
Anyone ever had this in V1.26? I'm getting this when I run my game in full-screen mode then I call some code to minimise it (works fine) then I click the game on the task bar and it goes full-screen again but the screen is black and I have to end task on it. That error appears in the output window when I'm running in Debug mode.

I'll see if I can make some small test code.

btw, Alt+Tab works, so does pressing the windows key.

Oh and it works if I use OpenGL.


tonyg(Posted 2007) [#2]
I got a lot of DXERROR messages in 1.26 *but* I had also updated to the latest 9.0c. When I wen back to April it settled down again.


Grey Alien(Posted 2007) [#3]
I probably haven't updated my DX in a while. hmm.

I can't duplicate it now running the same code! I was writing some test code and that seemed fine, went back to test the original crashing code and it's fine! I can't explain that. [EDIT] OK red herring, I left it in OpenGL mode which works. Yeah it's definitely DX which fails.


Dreamora(Posted 2007) [#4]
any other DX app running at the same time?


tonyg(Posted 2007) [#5]
... from Dreamora's prompt, I sometimes get DX errors when running Bmax programs alongside Football Manager 2007 (which is very often).


Grey Alien(Posted 2007) [#6]
OK red herring on the cannot duplicate bit, I left it in OpenGL mode which works. Yeah it's definitely DX which fails. No other DX apps running at all. My machine is at bare minimum.


Grey Alien(Posted 2007) [#7]
Got some code to duplicate the problem, you need a title.jpg and a paused.png to replicate it yourself:

Strict

Extern "win32"
	Function GetActiveWindow%()
End Extern

Graphics 800,600,32

Const SW_MINIMIZE = 6 'used with ShowWindow
Global WindowHandle = GetActiveWindow() 'need this to set icon, even in full screen mode.
Global image:TImage = LoadImage("Title.jpg")
Global paused:TImage = LoadImage("paused.png")

'DrawImage(Paused,200,200) 'uncomment this and crash will not occur

While Not KeyHit(Key_ESCAPE)
	Cls
	SetBlend SOLIDBLEND
	DrawImage image,0,0
	DrawText "Press Escape to Exit",10,10
	DrawText "Press M to Minimise",10,30
	SetBlend ALPHABLEND
	If AppSuspended() Then
		DrawImage(Paused,200,200)
	EndIf
	Flip
	
	If KeyHit(Key_M) Then
		ccMinimiseWindow(WindowHandle)
	EndIf
Wend

' -----------------------------------------------------------------------------
' ccMinimiseWindow: Windows API call to minimise a window
' -----------------------------------------------------------------------------
Function ccMinimiseWindow(hWnd%)
	?Win32
		ShowWindow(hWnd, SW_MINIMIZE)					
	?
EndFunction


I've figured out what's happening. When the game is suspended the code tries to draw Paused on the screen. Because Paused has NOT been sent to VRAM yet, the first time it tries to draw DX generates an error because the game is not longer full-screen it's minimised. If you uncomment the 'DrawImage(Paused,200,200) near the top, this sends Paused to VRAM and then later when the game tries to draw Paused when the game is minimised it works fine.

Basically DX (or BMax's implementation of DX) doesn't like it if you sent a graphic to VRAM when the game is minimised in this fashion. But it handles it if the game is alt+tabbed or Windows key is pressed. Some other Windows apps sometimes force a game to minimise when they have completed some task, I've seen this, and maybe they'll crash out the video driver in such a case.

Of the 800+ people that beta tested my latest game some of them did get some weird behaviour after the game had been running for a while, something about a severe driver error (windows error dialog). Wonder if it was caused by this?

Sure I could fix it my end by ensuring that no NEW graphics are drawn when the game is suspended but as this works in OpenGL it would be nice if it worked in DX.

Shall I post it in the bug forum?