Blitz3d in a Window - Jittery?

Blitz3D Forums/Blitz3D Programming/Blitz3d in a Window - Jittery?

Gabriel(Posted 2005) [#1]
This one's bugged me for as long as I can remember, but since I don't normally write windowed-only games, it wasn't too important. But now I am, so it is. Blitz games in a window at twitchy and jittery, where their fullscreen cousins are not. This seems mainly to happen when I'm connected to the net, and happens worse if I'm downloading a file. I don't have a clue why that would make a difference ( aside from it being a software modem and needing a little cpu time, but not much ) but I'm absolutely certain it IS making a difference.

In fullscreen I can get rid of an occasional jitter by adding a little delay in the main loop, but windowed mode jitters much more frequently in the first instance and a little delay does not seem to help.

Lots of you have written windowed-only games, so how can you deal with it? Or can you?


Difference(Posted 2005) [#2]
Please try my code and read my description from this topic to see if it's related:
http://www.blitzbasic.com/Community/posts.php?topic=33850

If it is, it's one of my big whishes to get it fixed. :)


Gabriel(Posted 2005) [#3]
Well it's not exactly the same problem, because my game doesn't have any mouse input apart from the native Windows mouse cursor, but it does indeed seem to be related. It shows up for me most often when I have some smooth but slow moving objects ( eg: the text lines in a credits scroller ) and they jitter badly.

The LockBuffer(BackBuffer()):Unlock(BackBuffer()) fix does seem to help, so thanks for pointing me to that.

Now that I've looked at your code, I recall a game I wrote a year or two ago, which ran only in windowed mode. It was a puzzle game, but it used FPS-style mouselook, and it lagged like crazy. Again, the situation did occur in fullscreen mode, but to a much lesser degree.

As I say, the buffer trick seems to help, but it does seem that a proper fix should be implemented, particularly something to stop execution speed affecting mouse input.


HappyCat(Posted 2005) [#4]
I had the mouse lagging problem in windowed mode on my laptop but I found that upgrading my graphics drivers fixed it so I never considered it to be a problem with Blitz itself.

Who knows though? :-)


danjo(Posted 2005) [#5]
i recently tried something. i have a 3d game, and use graphics3d etc, works ok in both full and windowed. i tried something at the start to start it in non3d mode, with just graphics 640,480,0,2 - and the scrolling stuff went very jerky, but in fullscreen it didnt..


jfk EO-11110(Posted 2005) [#6]
The reason why is a dx fullscreen app has a much higher task priority than a windowed app. A windowed app has less priority than any system task. The fullscreen App has an extremly high prirotiy, so high that it may crash the system when you don't let windows "breath" from time to time with a Delay, waitkey, flip true or something like that that allows the OS to utilize Blitzes Idle Time.

A very long time somebody posted a solution that would allow to set the Processes Priority. It should be possible using the Windows Api with a decls call. Although even then you may not get the same priority as a fullscreen App.


Difference(Posted 2005) [#7]
I'm 99% sure the mouse lag issue is not a prirotiy thing.

I think it's the way the messagepump in Blitz is coded.

Rendering/flipping takes precedence over getting all messages from Windows.
Blitz does not empty the message queue, even though it can't keep up reading messages because it's too buzy rendering.

IMO Blitz should throw away messages when it can't keep up.


Gabriel(Posted 2005) [#8]
I agree with Peter. From my experience with the 2 year old game, messages were definitely being ignored in favour of rendering.

If priority is the issue here, then it should be fixed within Blitz. We should not need to code it ourselves. Blitz knows when it's being run in windowed mode, and it should adjust the priority accordingly.

Plenty of other languages and tools run DX in a window and don't have this problem. Quest3d and 3d Gamestudio, for example, both run DX in a window and are as smooth as they are in fullscreen. I can't see a legitimate reason for Blitz not to do the same.


jfk EO-11110(Posted 2005) [#9]
I was talking about tasks like TCP Data transfer etc. When you're in Fullscreen Mode, your firewall and Antivirus high Priority Processes are forced to do their work in the idle time. In windowed mode it may be not possible to force them to "wait". are you sure the other apps you named don't have the same problems in windowed mode when you use the modem?

You also need to make sure that your framerate is compatible with the framerate the desktop uses. Probably you should use vwait:flip 0 instead of Flip True.


Gabriel(Posted 2005) [#10]
Yes, I'm quite sure that games made with 3d Gamestudio and Quest3d don't jitter at all when the same background tasks are running.

VWait:Flip 0 is not compatible with some laptop videocards, so I don't use it.


jfk EO-11110(Posted 2005) [#11]
I had some troubles when MD2 Models where in use, but I think this isn't your problem.

BTW: I think it's best to check the users Vsync Settings, something like this:

syncmode=1
vwait
t1=millisecs()
vwait
t2=millisecs()
if (t2-t1)<5 then ; seems like vwait is comletely ignored
 syncmode=2
endif
...
; and then in the game loop:

if syncmode=1 then
 vwait:flip 0
else
 flip
endif