gfxStarfield=CreateImage(32,32,10)

Blitz3D Forums/Blitz3D Beginners Area/gfxStarfield=CreateImage(32,32,10)

GC-Martijn(Posted 2004) [#1]
gfxStarfield=CreateImage(32,32,10) 

; loop through each frame of the graphic we just made 
For t = 0 To 9 
; Set the drawing buffer to the graphic frame so we can write on it 
SetBuffer ImageBuffer(gfxStarfield,t) 
; put 50 stars in the frame at random locations 
For y = 1 To 50 
Plot Rnd(32),Rnd(32) 
Next 
Next 


this is a part of a sample code.

And my question is:
Why I can't close the
SetBuffer ImageBuffer(gfxStarfield,t)
End SetBuffer

I know that its not build for that , but how does blitz3d knows that he is done the the
SetBuffer ImageBuffer(gfxStarfield,t) ?

Or must I use it like this:
SetBuffer ImageBuffer(gfxStarfield,t)
;make the picture
SetBuffer BackBuffer() ;close it with this
;setbuffer too the default

Thanks


EOF(Posted 2004) [#2]
If you mean 'How do I return back to the previous buffer?' then you use the GraphicsBuffer() function:
gb=GraphicsBuffer()

gfxStarfield=CreateImage(32,32,10) 
; loop through each frame of the graphic we just made 
For t = 0 To 9 
 ; Set the drawing buffer to the graphic frame so we can write on it 
 SetBuffer ImageBuffer(gfxStarfield,t) 
 ; put 50 stars in the frame at random locations 
 For y = 1 To 50 
  Plot Rand(32),Rand(32) 
 Next 
Next

SetBuffer gb



GC-Martijn(Posted 2004) [#3]
Its not so hard ...
Maybe I need some sleep and then I'm going to coding again.

Thanks


Gauge(Posted 2004) [#4]
When you setbuffer to a graphics buffer all drawing commands: including cls,clscolor,rect, plot, etc are drawn to that buffer. This also includes text, and print (i think print). All other commands will be ignored or won't work right, I don't think. Try:

graphics3d 800,600,16,3
setbuffer backbuffer()
cube=createcube()
cam=createcamera()
positionentity cam,0,0,-15
renderworld
text 100,100,"Press Any key to see if it works"
flip

gfxStarfield=CreateImage(32,32,10) 

; loop through each frame of the graphic we just made 
For t = 0 To 9 
 ; Set the drawing buffer to the graphic frame so we can write on it 
 SetBuffer ImageBuffer(gfxStarfield,t) 
 ; put 50 stars in the frame at random locations 
 For y = 1 To 50 
  Plot Rand(32),Rand(32) 
 Next 
Next

rotateentity cube,45,0,0
text 100,150,"IT WORKS FOR TEXT"

waitkey()
setbuffer backbuffer()
renderworld
flip


If the text 100,150 shows up on the screen it works for text
If the cube is rotated, it works for meshes
though all mesh commands might not
if it didn't change or you see nothing, or get an error it doesn't. (i would test it, but i'm at my gf's house NO BLITZ OH NO!!!!")