Please test this 1.20 graphics anomaly

BlitzMax Forums/BlitzMax Programming/Please test this 1.20 graphics anomaly

Grey Alien(Posted 2006) [#1]
[edit] This has been fixed now, no more tsting reqired. Thanks.

This test is for PCs.

When I run the code below, I see the scan line move down the rectangle resulting in a moving tear, and making the rectangle movement look jerky.

If I uncomment the EndGraphics() line and second Graphics() line, the rectangle with have a single stationary tear on it (at a random height).

Using OpenGL or not makes no difference.

Why is the first one unsynced and the second one synced? What possible difference is there in calling the same graphics command twice? This does my head in! Either some variables inside BlitzMax change or my video card has to be bullied into properly syncing by calling graphics twice, which is crazy.

It does *not* do this in BlitzMax 1.18, I have and old .exe I ran that's fine. Has someone altered the graphics modules recently? I noticed this because my Game Framework UFO demo, which used to work fine, has now started jerking when starting in windowed mode. But if I make it go full-screen, then back to windowed mode, it's fine!

Please report your findings. Thanks in advance.

Btw, I'm not expecting everyone to get the same findings due to the different ways video cards/drivers work.

Strict

'SetGraphicsDriver GLMax2DDriver() 
Local DesktopRefreshRate = GetDeviceCaps(GetDC(0),VREFRESH)
Local w = 1024, h = 768
Graphics (w,h,0,DesktopRefreshRate)
'Uncomment these two lines in to see the difference
'EndGraphics()
'Graphics (w,h,0,DesktopRefreshRate)

Local x = 0, y=0
While Not KeyDown(KEY_ESCAPE)
	Cls
	DrawRect (x,y,200,h)
	Flip
	x = x + 10
	If x > w Then x = 0
Wend


P.S. just found out the EndGraphics line is superflous because Graphics() calls it anyway for safety.


Robert Cummings(Posted 2006) [#2]
Actually when I uncomment, I get no tearing whatsoever and its amazingly stable.


Diablo(Posted 2006) [#3]
i get teating when i uncomment the lines, however it moves much slower down the screen. but if i leave those lines uncommented and use glmax2d the tearing goes away.

BUT if I recomments the lines and use glmax2ddriver, it gives tearing again.

EDIT : Dam my poor spelling*, I swear i typed tearing, honest ;)


Grey Alien(Posted 2006) [#4]
Thanks people.

Actually when I uncomment, I get no tearing whatsoever and its amazingly stable.
on mine I get a single tear at a random place (sometimes it's hidden by the title bar), what res are you running windows at? Higher than 1024x768? If so boost the w and h params, there should be a single tear somewhere ... Anyway the point is there is a difference right and there shouldn't be right?

I forgot to say, when I run my BMax1.20 demo it runs at 25% CPU usage and jerks, but my BMax1.18 demo runs at 50% CPU use and is fine. What gives BRL dudes?

Diablo: "teating" hey, well I can't help with that ;-) seriously though, you are seeing a change too then and an improvement with OpenGL. See how all cards are different, and this little experiment proves it?


Grey Alien(Posted 2006) [#5]
two possible 1.20 fixes that may have broken this:

+ (BRL.Graphics) Fixed soft synced Flip so it doesn't overflow after 4+ hours.

+ (BRL.Graphics) Added DefaultGraphicsFlags() Function


Grey Alien(Posted 2006) [#6]
Found it. It's a bug in graphics.bmx. I wish BRL commented their modules more, so hard to understand!

Anyway it's part of the Graphics() function. The _syncPeriod variable is used before it's intialised, moving the line up, then rebuilding the module fixes this anomaly. I don't know if moving it causes any other problems, BRL will need to check this:

	_syncRate=hertz
	If _syncRate _syncPeriod=1000/_syncRate Else _syncPeriod=0 'here!
	_syncFrac=1000-_syncPeriod*_syncRate
	_syncAccum=0
'	If _syncRate _syncPeriod=1000/_syncRate Else _syncPeriod=0 'not here
	_syncTime=MilliSecs()


I'll post this in the bugs forum now.


assari(Posted 2006) [#7]
I have tearing as well. Using timer events produces no tearing on my system
Strict

Local w = 1024, h = 768
Graphics (w,h,0,0)
Local timer:TTimer=CreateTimer(200)
Local x = 0, y=0
While Not KeyDown(KEY_ESCAPE)
	WaitEvent()
	If EventID()=EVENT_TIMERTICK
		Cls
		DrawRect (x,y,200,h)
		Flip
		x = x + 1
		If x > w Then x = 0
	EndIf
Wend
NVIDIA GeForce4 420 Go 32M|WinXP SP2|TabletPC


assari(Posted 2006) [#8]
Apologies. Changing x=x+10 instead of x=x+1 causes tearing even with the timer technique.


Grey Alien(Posted 2006) [#9]
yes tearing is more noticeable on faster moving sideways objects.


Robert Cummings(Posted 2006) [#10]
Grey... you really should be using the new style add, subtract and multiply by now!

reallyLongVar = reallyLongVar +1 'UGH!

reallyLongVar :+ 1 'mmmmm :)

:+ :* :- etc...


Grey Alien(Posted 2006) [#11]
Yeah I know, but I keep trying to do var++, then I remember it's not like that but can't remember the BMax syntax. It's just a dumb mental block and 20++ years of habit.