Virtual resolution - what can cause this??

BlitzMax Forums/BlitzMax Programming/Virtual resolution - what can cause this??

GfK(Posted 2010) [#1]
I'm having a problem that I can't reproduce in any example code so I've got to be doing something wrong... but what??

I have a 640x480 window, with the virtual resolution set to 800x600.

Everything should be automatically scaled down to fit the screen (just like in the test code I came up with!). But I'm getting this. Everything IS the right scale, but I have this black area!:



The black void at the right/bottom edge is not meant to be there. You can see from the debug info top-left that the graphics res and virtual res are as expected. There is nothing drawn in my code (by me) after the mouse pointer, yet you can see its clearly behind the black area, on the right.

I'm not using any viewport clipping anywhere, yet I have this oddity.

I'm setting the graphics mode, then the virtual resolution afterwards.

This works perfectly in my test code (below), and it also works fine in my game, provided that the graphics res is at least the size of the virtual res.
Here's the test code that *doesn't* reproduce the problem, yet it doesn't appear to be any different to what I have in the game.
Strict
SetGraphicsDriver D3D9Max2DDriver()
Graphics 800,600
SetVirtualResolution(800,600)

Local img:TImage = LoadAnimImage("mousepointer.png",64,64,0,1)

While Not KeyDown(key_escape)
	Cls
	DrawImage img,VirtualMouseX(),VirtualMouseY()
	Flip
	If KeyHit(key_space)
		Graphics 640,480
		SetVirtualResolution(800,600)
	EndIf

Wend


Any ideas what could cause this?


matibee(Posted 2010) [#2]
Try adding a "DrawRect(0,0,640,480)" to your sample right after your Cls. Is that the same? And isn't that expected behaviour?


TaskMaster(Posted 2010) [#3]
Gfk,

I remember having a similar issue when I was first testing ifsoGUI with the new VirtualResolution stuff. I don't remember exactly what the cause and solution was, but I think it had something to do with needing to cal SetViewPort after the new graphics command and before the SetVirualResolution (when changing the resolution while the program was already running). Now, I do not remember which Resolution I had to set the viewport to, real for virtual, but try them both and see if one way or the other solves your problem. My guess is that you need to set it to the VirtualResolution though.

In other words, your example would look like this:

Strict
SetGraphicsDriver D3D9Max2DDriver()
Graphics 800,600
SetVirtualResolution(800,600)

Local img:TImage = LoadAnimImage("mousepointer.png",64,64,0,1)

While Not KeyDown(key_escape)
	Cls
	DrawImage img,VirtualMouseX(),VirtualMouseY()
	Flip
	If KeyHit(key_space)
		Graphics 640,480
		SetViewPort(800,600)
		SetVirtualResolution(800,600)
	EndIf

Wend


Like I said, that may be backwards ands the SetViewPort may need to be:

SetViewPort(640, 480)

Anyway, I hope this helps.


GfK(Posted 2010) [#4]
Thanks - I've been following the program logic for about an hour now and I have strong suspicions that its something to do with TimelineFX...

[edit] Sticking a SetViewport(0,0,800,600) in every loop fixed it... think I'll have to ask PeteRigz to take a look...


_Skully(Posted 2010) [#5]
So if you disable TimeLineFX does it work correctly? I'd be surprised if its in TimeLineFX since it's being used quite a bit... OK, perhaps not with the virtual commands but I'm pretty sure PeteRigz tested it... unless my memory is faulty... which it is sometimes ;)


GfK(Posted 2010) [#6]
Yep. No TimelineFX, no problem.

Try his 'vaders' demo and make this change at line 425:
		Graphics 640,480
		SetVirtualResolution(800,600)


The problem only happens when the physical resolution is smaller than the virtual resolution. Off to post on his forum now.


GfK(Posted 2010) [#7]
Well, Pete reckons its a dodgy reference in my code to GraphicsWidth() when it should reference VirtualGraphicsWidth(). By sheer coincidence, his demo code has the exact same problem as my code does.

I shall take a peek tomorrow but I'm sure he's right. :)


ziggy(Posted 2010) [#8]
This happens exactly the same in the game I'm developing now!


maverick69(Posted 2011) [#9]
dont know if it works here, but I had a similar problem and calling SetViewport AFTER SetVirtualResolution helped.
SetVirtualResolution(800,600)
SetViewport(GraphicsWidht(), GraphicsHeight())