getting trouble on Flip 0

Blitz3D Forums/Blitz3D Programming/getting trouble on Flip 0

bytecode77(Posted 2006) [#1]
hello!

i am currently working on a game, and there is a problem:
when i am using flip true, everything seems to be ok.
but when i'm using flip false, the keyboard reacts half a second AFTER i pushed a button! the mouse has got same problem!
but i cant imagine why -.-

would be thankful for help!

EDIT: a friend just told me that this bug apperas in my gui, too!

edit2: this code has got this bug, too:

Graphics 1024, 768, 32, 2
SetBuffer BackBuffer()

While Not KeyHit(1)
	Rect MouseX(), MouseY(), 10, 10
	Flip 0
	Cls
Wend
End



bytecode77(Posted 2006) [#2]
oh, now i know the bug: it is because the window mode! on fullscreen it is working fine.
well, i am very upset about this because i have got a very sh*tty monitor, which takes a >few< secons to build up the fullscreen! any idea to solve the bug?


b32(Posted 2006) [#3]
The program uses too much CPU time, Windows can't draw the window. Add "delay 1"



bytecode77(Posted 2006) [#4]
no it doesnt work, but i will use fullscreen! thx!


b32(Posted 2006) [#5]
Have you tried different delays ? It could depend on your p.c.'s speed.


bytecode77(Posted 2006) [#6]
when i put in a timer with 333 the bug appears half a minute later, on 334, it appears right now


jfk EO-11110(Posted 2006) [#7]
333 is the frequency, so you say you want a timer event every 1000/334 millisecs. That's every second, or every third millisecond, depending on if you say 333 or 334.
Probably you shouldn't use such high frequencies with CreateTimer.

(Only guessing:)

You problem seems to be something in windows. Unlike the fullscreen mode, where flip truly FLIPs the buffer adresses, in windowed mode it will only tell windows to refresh the rectangle of your apps window, taking the pixels from a buffer that is logically teached as backbuffer. Infact they won't be flipped.

If this doesn't work, there seems to be a problem in the desktop refresh tasks of the system. Maybe the priority is too high, so there is a delay for the user input.

BTW there is this command that allows to use an alternative input device (aarg, can't remember the exact synthax right now), something like UseDirectDevice (anyone?).


Dreamora(Posted 2006) [#8]
Reason this happens: With flip false, your GPU renders the scene ahead. Sounds theoretical like a cool idea. Sadly this means that it is 10-15 frames ahead on high end cards which means a lot on a TFT with 60hz (10-15 * 16ms) ... Every input you do in that time is "lagging" that time ahead.

The only way to fix that is the same fixes as the mouse lag fixes.


A different way, which I would suggest (although I'm most likely the only one using such obscure technics ... at least it seem so) is using timed rendering:


Ask the user for desired FPS and only draw the screen that many times. At best with maximum on the highest hertz the users screen support at that resolution.

Doing that is simple by a small "if timedifference >= 1000 / desiredframes".

This also will free quite a lot computing time for the real game (ai etc) which otherwise would be wasted by rendering stuff thats never seen.
This should give you quite a lot rendering time etc for nice effects as well.
Generaly doing everything time based beside input is a good idea ... especially effect updates and rendering which are time consuming and don't need to be "millisecond accurate". (never do it with input ... while it might look like a nice idea, you wouldn't be able to use keydown / mousedown anymore which is a bad thing in most cases)


bytecode77(Posted 2006) [#9]
ok, now i have put the timer down to 60 FPS and it is working...
THX A LOT!!! :)