D3D9 and SetViewPort

BlitzMax Forums/BlitzMax Programming/D3D9 and SetViewPort

xcessive(Posted 2011) [#1]
On my machine the SetViewPort() function when using D3D9 drivers creates a blank screen. It works fine using D3d7 or openGL drivers. Even more strangely, this only happens in full screen. When in windowed graphics mode D3D9 works fine. Is there some issue or quirk I am not aware of?

Heres the code I am using:

superstrict
SetGraphicsDriver 'insert drive to test here

Graphics 800,600,32
test()
EndGraphics
Graphics 640,480,0
test()

Function test()
	Cls
	SetViewport 100,100,100,100
	DrawOval 0,0,300,300
	Flip
	While Not KeyHit(KEY_ESCAPE)
	Wend
End Function



xlsior(Posted 2011) [#2]
Supposedly viewports aren't compatible with 100% of the video adapters out there...


Grey Alien(Posted 2011) [#3]
But it was old ones I had trouble with, several years back (no black screen or anything, simply that the viewport didn't work so everything I drew in it wasn't clipped by it).

This is worrying if it's happening with DX9 on modern machines as I recently released a game that used SetViewPort after it called SetVirtualResolution.

Last edited 2011


xcessive(Posted 2011) [#4]
Well if its any help too you grey alien, I run a rarely used card.

Toxic 5970 4gb version. Cost an arm and both legs.


Zeke(Posted 2011) [#5]
i think there is still some "bugs" in d3d9 driver..:

this works:
SuperStrict
SetGraphicsDriver GLMax2DDriver()
SetGraphicsDriver D3D7Max2DDriver()
SetGraphicsDriver D3D9Max2DDriver()'insert drive to test here

Graphics 800,600,32
test()
EndGraphics
Graphics 640,480,0
test()

Function test()
	Cls
	Flip 'Add this
	SetViewport 100,100,100,100
	DrawOval 0,0,300,300
	Flip
	While Not KeyHit(KEY_ESCAPE)
		Delay 5
	Wend
End Function


Last edited 2011

Last edited 2011


Grey Alien(Posted 2011) [#6]
@Zeke Are you saying you have to flip before setting the viewport to get it work at all?


Zeke(Posted 2011) [#7]
yeah.. of course if you put whole Cls,SetViewport,Drawoval and Flip inside While/Wend loop then it works fine(without flip after CLS). but that test is only "clearscreen,setviewport,drawoval,flip" and then wait for escape keypress.. not loop. so maybe there is something wrong with flip, or graphics initialization or something else. weird bug.

[EDIT] also if you use flip after SetViewPort. this works fine too. but before CLS. not working.

Last edited 2011