Page 1 of 1

CopyBuffer()

Posted: Fri Jan 16, 2004 2:22 pm
by KuschelTeddy82
If you don't want to "Flip" the buffers wit FlipBuffers(), so that the backbuffer gets exchanged with the frontbuffer, you could create a command like CopyBuffer() which "copy" the backbuffer to the frontbuffer, so that the backbuffer keeps unchanged for the next drawing sequence. Sometimes it may be useful.

Posted: Fri Jan 16, 2004 2:30 pm
by LarsG
Isn't that what FlipBuffers() does?!?
It's the ClearScreen() that actually erases the backbuffer...
Try dong a FlipBuffers() and don't ClearScreen() after it, and see what happens...
Or am I way off here?!? (haven't actually tried it myself)

Posted: Fri Jan 16, 2004 2:39 pm
by KuschelTeddy82
No, i tried it already. Example: Draw one Line of Text, then do FlipBuffer(). Now draw a second Line of text and FlipBuffer() again. Now you see only the second line. After the next FlipBuffer() you see just the first Line. And so on... In a code from me, I made an loading-Info-Procedure, which shows you, what actually happens in form of an expanding list. What I have to do is: DrawText("test") : FlipBuffer() : DrawText("test") : FlipBuffer(), so that for the next Line the Text is in the Backbuffer too.

Posted: Fri Jan 16, 2004 2:43 pm
by LarsG
oh, ok.. I'll take your word for it...
I guess I really should try the advice I give... :lol:

Posted: Sun Jan 18, 2004 5:49 pm
by filperj
I am not sure, but it seems flipbuffers() works as KuschelTeddy82 says in fullscreen, and works as a "copybuffer()" in windowedscreen...

Posted: Sun Jan 18, 2004 6:06 pm
by Psychophanta
FlipBuffers() funtion doesn't copy anything, it just flips the screen buffers: the one which was rendered will be displayed, and the one which was displayed will be prepared to be rendered; that's all.

What KuschelTeddy82 requests, could be done using GrabSprite() (to capture all the screen buffer info) and DisplaySprite() (to display all it again)

:)

Posted: Sun Jan 18, 2004 6:24 pm
by filperj
I repeat:
t seems flipbuffers() works as KuschelTeddy82 says in fullscreen, and works as a "copybuffer()" in windowedscreen...
and i insist:

Code: Select all


InitSprite()
OpenScreen(400,300,16,"coucou")

StartDrawing(ScreenOutput())
 Locate(200,140)
 DrawText("coucou")
StopDrawing()

InitKeyboard()
Repeat
 ExamineKeyboard()
 If KeyboardReleased(#pb_key_space)
  FlipBuffers()
 EndIf
Until KeyboardReleased(#pb_key_escape)

Code: Select all

InitSprite()
hwnd=OpenWindow(0,0,0,400,300,#pb_window_screencentered,"coucou")
OpenWindowedScreen(hwnd,0,0,400,300,0,0,0)






InitSprite()
hwnd=OpenWindow(0,0,0,400,300,#pb_window_screencentered,"coucou")
OpenWindowedScreen(hwnd,0,0,400,300,0,0,0)





StartDrawing(ScreenOutput())
Locate(200,140)
DrawText("coucou")
StopDrawing()

InitKeyboard()
Repeat
ExamineKeyboard()
If KeyboardReleased(#pb_key_space)
  cnt+1
  StartDrawing(ScreenOutput())
   Locate(0,0):DrawText(Str(cnt))
  StopDrawing()
  FlipBuffers()
EndIf
WindowEvent()
Until KeyboardReleased(#pb_key_escape)

but maybe it doesn't have the same effect on every machine/system ?

Posted: Sun Jan 18, 2004 6:55 pm
by Psychophanta
Your first code demonstrates that FlipBuffers() doesn't copy anything, as said. The second shows a FlipBuffers() bug for WindowedScreen. :o

Posted: Mon Jan 19, 2004 6:21 am
by filperj
Your first code demonstrates that FlipBuffers() doesn't copy anything, as said. The second shows a FlipBuffers() bug for WindowedScreen.
OK, I will repost in bug section.
*edit* Ah, you did :D *edit*

What KuschelTeddy82 requests, could be done using GrabSprite() (to capture all the screen buffer info) and DisplaySprite() (to display all it again)
Another way may be to render on a screensized sprite, using "usebuffer()",and to display that buffer-sprite just before flipbuffers().
But that doesn't work with displaysprite3D().

Posted: Sat Feb 07, 2004 2:53 pm
by KuschelTeddy82
Uhm... GrabSprite then DisplaySprite to "Copy" is not really good! It would be a damn loose of Speed! All the workaround isn't the way it should be in a fast language like pb. But you see, FlipBuffers() does unusefull flipping of the buffers. With a additional CopyBuffers() you are not forced to render everything in every cycle again, just adjust changes and copy again. In some cases this is a useful way, or do anybody know, for what you could use the 2nd last image :?:

Or Modify the FlipBuffers() to: FlipBuffers([mode, [clipX1, clipY1, clipX2, clipY2]]). So, when you use just FlipBuffer() it acts like we know it. But as mode you can optionally select for example 0 (Standard - Flip), 1 (Copy) and then, if you use copy as mode, you can select a clipping region, which part of the screen should be copied in the frontbuffer.

So, what you think about it?

Posted: Sat Feb 07, 2004 10:29 pm
by Psychophanta
KuschelTeddy82;
I suggest to you to try "spriteEx" library, from Moebius. You can download it from www.purearea.net for example.
I was trying with it, and there are a useful command to copy a screen rectangle from a coordenate to another; that command takes about 4/5 time units than execute just a GrabSprite() PB command.
That lib has lots of improvements that i guess you will enjoy. :D

In my opinion, it would be needed for PB to add some argument to FlipBuffers() in order to erase or not to erase the content of buffers.

Besides, I requested Fred about to implement single and triple buffer, and perhaps quadriple buffer, and he said he will add it to PB. With single buffer, in execution time, what is drawn is shown in real time (no flipping buffers). You can do this now with SpriteEX lib

Posted: Sun Feb 08, 2004 12:58 am
by KuschelTeddy82
I know the SpriteEx-Library already and have it too, but I miss the Sprite3D-Commands there, which I need very often. Jeah, an erase - or not erase option is really needed, and the thing with tribble-buffering :D sounds really nice!!! :D

Uhm.... I know single, double and triple buffer, and I know for what they are, but for what could anyone need quadriple buffer ??? Is one a fixed buffer, on which you can draw graphics which would not change during a game and the other three act like tribble buffering?
Thanks for reporting this things to fred :roll:

Posted: Sun Feb 08, 2004 10:58 am
by Psychophanta
Mmmmh! should be good if S. Moebius upgrade his SpriteEx lib to 3D sprites... :roll:
for what could anyone need quadriple buffer ??? Is one a fixed buffer, on which you can draw graphics which would not change during a game and the other three act like tribble buffering?
Well, when i wrote my request: viewtopic.php?t=8037 , i saw there the very nice Fred's explanation about how triple buffer works, and watching it i realized that quad-buffer should work for those slower PC systems when there is needed lots of calculations before to vblank time is finished. But i don't know if Fred will add quad-buffer... :roll: :arrow: