Flip screen woes

Blitz3D Forums/Blitz3D Beginners Area/Flip screen woes

Roe(Posted 2005) [#1]
Hello,

I've got a problem with my screen update. I had a few sprites moving around in a windowed 1024, 768 environment and everything was going well. In the code, I clear the screen, tell the code to draw the sprites in their respective places in the backbuffer and then I flip the screen; so far, so what, but when I took my code into work to test it on another machine, the frame rate looked really low and laggy. However my framerate display shows it's running at a consistent 75 frames per seocnd; the same as back home.

Now we use two monitors in work; back home I have recently installed a second monitor and guess what? The lag has started to appear here too.

Something wierd is going on with the screen refresh, it seems to be out of sync with my game. Could it be related to the dual monitor setup? Even if I turn the monitor off it still lags. If it is a monitor problem, how can I sync up the refresh to the game so that it runs fine?

I'm quite new to coding, but if I take out the 'Flip' function from my code, shouldn't this stop anything appearing in the window? Because when I take it out, the game still shows the sprites on the screen, but they flash on badly and tear down the screen as if they were being drawn straight onto the screen and not the backbuffer; is that right? I've set it up so that the back buffer is the buffer used, but it looks like something is overriding when the buffer gets drawn to the screen,

Sorry for the mumbling, I'll try and explain better if you need me to. Any ideas?

Cheers


big10p(Posted 2005) [#2]
We really need to see some code.

How are you using Flip? Are you locking it to the monitor refresh rate (i.e. Flip True)? Try using 'VWait : Flip False' instead.

Just guessing here. Like I say, we need the codez. :)


Roe(Posted 2005) [#3]
This is my main loop

Include "globals.bb"
Include "leveldata.bb"
Include "Movement.bb"
Include "graphics.bb"
Include "debug.bb"
Include "render.bb"
Include "framespeed.bb"

;---------------------------------------------------------------------
;---------------------------MAIN LOOP---------------------------------
;---------------------------------------------------------------------

While Not KeyHit(1)

framespeed() ;checks the frames per second (only for debug display, it doesn't limit or lock it)

keycheck() ;this is for playermovement

render() ; draws everything to the screen

updateplayerongrid() ;updates the array

Wend

End

;--------------------------------------------------------------------



This is the render loop:

Cls ; clear the screen

DrawImage (ibckgrnd, centerx+gridsize, centery+gridsize); draws the background

debug() ; adds any debug text displays

For b = 1 To 15 ; main render loop for drawing all the sprites
For a = 1 To 15

x = centerx+a*gridsize-(gridsize)
y = centery+b*gridsize-(gridsize)

;Text centerx+a*gridsize, centery+b*gridsize, ""+grid(a,b,1)
If grid(a,b,1) = 1 Then DrawImage (iblock, x, y)
If grid(a,b,1) = 2 Then DrawImage (dblock, (a*gridsize)+centerx-gridsize, (b*gridsize)+centery-gridsize)
Next

Next

DrawImage (iplayer, player1\X, player1\Y) ; and lastly the player!



Flip ; update the screen



The debug functionis just drawing some text:

Function debug()

Text 20, 50, grid((player1\gridx - 1), (player1\gridy-1),1)+" "+grid((player1\gridx), (player1\gridy-1),1)+" "+grid((player1\gridx + 1), (player1\gridy-1),1) ;debug
Text 20, 65, grid((player1\gridx - 1), (player1\gridy),1)+" "+grid((player1\gridx), (player1\gridy),1)+" "+grid((player1\gridx + 1), (player1\gridy),1);debug
Text 20, 80, grid((player1\gridx - 1), (player1\gridy+1),1)+" "+grid((player1\gridx), (player1\gridy+1),1)+" "+grid((player1\gridx + 1), (player1\gridy+1),1) ;debug

Text 0, 5, player1\gridxvalue+ " gridxvalue "+(player1\gridxvalue - spriteoffset)+" spriteoffset "+player1\x+ " "+fps+" fps "

End function


Roe(Posted 2005) [#4]
I've tried the same code in BlitzPlus and it works fine. It's only a problem in Blitz3D. Furthermore, the Flip command does indeed prohibit the drawing of anything to the screen when it's commented out but in Blitz3D the screen still get's refreshed.

Any ideas?


big10p(Posted 2005) [#5]
That is weird. Indeed, nothing should be displayed until Flip is executed. From what you've said, I think it must be something to do with your dual screen setup - maybe a setting in your driver? I've never used a dual screen setup so can't really say. If you can't get it sorted, post in the bug report forum.


Roe(Posted 2005) [#6]
Thanks Big, I think I will submit a bug report. I tried running the game in fullscreen mode and it runs smoothly then, but the top of the screen flickers a little bit. Definately not right :(

Cheers


jfk EO-11110(Posted 2005) [#7]
Sounds to me like you forgot to set the buffer:

Graphics3d 1024,768,32,2
setbuffer backbuffer() ; <<<<<<<


Hotcakes(Posted 2005) [#8]
If you are seeing stuff as soon as it is drawn, then it is drawing to the frontbuffer. What jfk said should help, but in the case of double buffering not being supported for some reason, you... may just have to work around it. I know windowed mode doesn't support double buffering, but I still thought it didn't show the buffer until you used Flip... but... that could just be because the drawing commands are so damn fast...


Roe(Posted 2005) [#9]
No, the Backbuffer is being set, I have it setup at the start.

As I said, this only became an issue when I installed nView Dual Monitor Support.


Damien Sturdy(Posted 2005) [#10]
You should see what happens when you try to use 3d glasss ;)