Main Menu

rendertoscreen

Started by andrik, January 05, 2007, 02:52:41 PM

Previous topic - Next topic

andrik

Hi,

Could someone tell me what happens when I don't use rendertoscreen? I only use sync to show my text and images on screen and haven't had any problems with it, so what exactly is the use of rendertoscreen?
I know it draws to the backbuffer, and sync brings the back- to the frontbuffer, but appearantly this also works without rendertoscreen.

best regards,
Andrik

Ian Price

PB is automatically set to RenderToScreen (the physical screen that we all see).

You will only ever have to use the command if you use a RenderToImage XX command first, which instructs PB to send all future drawing routines etc. to the image specified (with this you can copy images onto other images etc. quickly and easily). After using the command, you must use RenderToScreen to ensure that PB continues drawing to the physical screen.

A good example would be this -

; Open up a 640x480 fullscreen screen
openscreen 640,480,32,2

; Creates a new image in memory
createimage 1,100,100

; Sets drawing to the new image
rendertoimage 1

; Clears the image (not the screen) to pink
cls rgb(255,0,255)

; Draws dots only on the image
for n=0 to 100
dot rnd(100),rnd(100)
next

; Resets PB to draw to the physical screen
rendertoscreen

text 10,10,"PRESS A KEY"

sync
cls 0

waitkey

while not esckey()

text 10,10,"PRESS ESC TO EXIT"
drawimage 1,100,100,1

sync

cls 0

endwhile


I came. I saw. I played some Nintendo.

kevin

 Also, Image 0 is the screen

RenderToIMage 0    is the same as RenderToScreen

Big C.

Quote from: kevin on January 05, 2007, 07:13:42 PM
Also, Image 0 is the screen

RenderToIMage 0    is the same as RenderToScreen

I think, that is an interesting and helpful notice. Maybe this notice should be recorded on the corresponding help page under facts  ;)

Big C.

kevin

#4
 Done.

QuoteI think, that is an interesting and helpful notice. Maybe this notice should be recorded on the corresponding help page under facts  

Since when do programmers read the help files ?  :)


Read PlayBASIC Manual - PLayBASIC Documentation

Ian Price

I came. I saw. I played some Nintendo.