CopyBuffer()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
KuschelTeddy82
New User
New User
Posts: 9
Joined: Thu Jul 10, 2003 3:13 pm
Location: Germany

CopyBuffer()

Post 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.
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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)

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
KuschelTeddy82
New User
New User
Posts: 9
Joined: Thu Jul 10, 2003 3:13 pm
Location: Germany

Post 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.
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

oh, ok.. I'll take your word for it...
I guess I really should try the advice I give... :lol:

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
filperj
User
User
Posts: 77
Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)

Post by filperj »

I am not sure, but it seems flipbuffers() works as KuschelTeddy82 says in fullscreen, and works as a "copybuffer()" in windowedscreen...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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)

:)
filperj
User
User
Posts: 77
Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)

Post 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 ?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Your first code demonstrates that FlipBuffers() doesn't copy anything, as said. The second shows a FlipBuffers() bug for WindowedScreen. :o
filperj
User
User
Posts: 77
Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)

Post 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().
KuschelTeddy82
New User
New User
Posts: 9
Joined: Thu Jul 10, 2003 3:13 pm
Location: Germany

Post 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?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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
KuschelTeddy82
New User
New User
Posts: 9
Joined: Thu Jul 10, 2003 3:13 pm
Location: Germany

Post 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:
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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:
Post Reply