News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

differences between screenmodes?

Started by andrik, February 09, 2007, 09:59:11 AM

Previous topic - Next topic

andrik

HI,

Are there any differences between the different screenmodes? Let me explain my question:
I created a game which starts with the following code:
if getdesktopwidth() = 1024
   openscreen 1024,768,16,2
else
   OpenScreen 1024,768,16,1
   Titlescreen "Stap op!"
endif

Now I developed the game on a 1440x900 screen, so I played in a windowed mode. I just now tested it in a fullscreen mode, by changing the code above, and suddenly some background images won't appear anymore and text is written over other pieces of text which normally would.nt happen. So my guess is something goes wrong with my update_Gameboard routine, which basically CLS 0 the screen and draws some pictures and boxes and then syncs.

So am I doing something wrong?

best regards,
Andrik

kevin

#1
 You're no doubt aware that screen is double buffered.    However, buffering works differently between the two modes (windows + Full screen)  


Window Mode

 - All gfx are drawn to the back buffer.

 - When we sync, this copies the Back buffer to the window so we can see it.

 - All drawing occurs on the same buffer



Full Screen.

 - All gfx are drawn to the back buffer.

 - When we sync, the Back buffer is swapped with the front.  

 - All drawing will be interleaved between the two buffers.  Since Front & Back are separate copies of the screen.
 
** There is an exception to this rule, as some video cards do not support hardware flipping. Those machine work the same as window modes when in full screen mode.  


Try this example in window/full screen modes

PlayBASIC Code: [Select]
setfps 10

print "Hello"
Sync

Print "World"

Do

; flip buffers
Sync
loop








in Windowed mode everybody will see

Hello
World

in full screen mode most people will see the the two buffers being flipped. one buffer with Hello and the other with World.   While the others will see Hello, World as their card doesn't suport hardware flipping.  



This has been covered before


andrik

THanks for the link to the older post, it's clear now. So as I see it, it's best first of all to minimize the use of sync commands all over your code, and probably try to do it once after you've updated all you want to update.

greetz,
Andrik

kevin


You shouldn't be sync'ing more than once per update.


andrik

Well,

I thought I understood, but apparently I don't.
Could you look at this code?
   cls 0
   setcursor 300,300
   Print "Hi, " +naam$+ "! The deck is being shuffled..."
   sync
   wait 1000

   ; toon de tafelachtergrond.
   ;cls rgb(0,0,0)
   update_gameboard()
   sync
   wait 1000
  ; print "some other stuff..."
  sync
Now, update_gameboard does not contain a sync statement, I do that after update_Gameboard()
When I later on sync again, after showing "some other stuff..", the text "Hi ...The deck is being shuffled..."  appears again. I thought that buffer would be empty.

What am I doing wrong here?

Ian Price

#5
Again, there's too many Sync commands (you don't need one after the "update_gameboard()") and you are not clearing the screen with a CLS RGB(R,G,B), which is why you are still seeing the first message.

What you could do is -


naam$="Ian"

Text 300,300,"Hi"+naam$+"! The deck is being shuffled..."

Sync

Cls 0

Wait 1000

update_gameboard()

Text 300,320,"The screen is now clean (Except for THIS text!)"

Sync

Cls 0

WaitKey
 
end
 
Function update_gameboard()
Text 10,10,"UPDATE GAMEBOARD FUNCTION IS... FUNCTIONING"
EndFunction


Do your work first, then Sync and CLS. Repeat. Notice there is one CLS for each Sync. You can use CLS at the beginning or end of a loop, but I prefer to use it immediately after a Sync command. You notice that the second Sync still allow the gameboard to be updated, as the function runs fine. You're then only updating the screen once it's done what it needs to do.


I came. I saw. I played some Nintendo.

andrik

Ahh..I get it this time 'round. Good tip, the sync, CLS 0 combination. Many Thanks!
Hope you guys don't mind all my stupid questions, but I'm still learning (and liking it a lot!)

Draco9898

#7
Yes, the screen content will not change (erase parts from different cycles) unless you do this:

Do
Cls 0
` Game logic here

Sync
Loop

Or for a camera, this:

Createcamera 1
Do
CaptureTOscene: ClsScene
`Put your game logic here!

DrawCamera 1
Sync
Loop
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin