coolbits
12 years agoVisitor
Strange behavior - update screen even without swapbuffer
Hi,
I've been working with roScreen along with roCompositor and roSprite objects. I've found a strange behavior with the roCompositors.
It is known that we have to use screen.SwapBuffers() in order to update the changes in the sprites inside a compositor. Here is what I did.
1. Created a screen (myScreen) , a compositor(myCompositor) and two sprites (mySprite1, mySprite2) in the compositor
2. Called the myScreen.SwapBuffer() to display the sprites in the screen
3. removed mySprite1 from the myCompositor ; mySprite1.Remove() and set the variable to invalid mySprite1 = invalid
4. Clear screen; myScreen.Clear(&h00000000)
5. Call the Draw function in compositor; myCompositor.Draw()
The strange behavior is that, when I do the step5, the myCompositor draws the remaining sprite (mySprite2) to the screen (without calling the myScreen.swapbuffers()).
At the bottom line, what I want to do is to spare some memory. That's why I am removing the sprites.
I also noticed that, the removed sprites DO NOT remove until I call the myCompositor.Draw() function as well.
Here is the actual code I've used
Thanks for any ideas on this.
Cheers,
Chandana
I've been working with roScreen along with roCompositor and roSprite objects. I've found a strange behavior with the roCompositors.
It is known that we have to use screen.SwapBuffers() in order to update the changes in the sprites inside a compositor. Here is what I did.
1. Created a screen (myScreen) , a compositor(myCompositor) and two sprites (mySprite1, mySprite2) in the compositor
2. Called the myScreen.SwapBuffer() to display the sprites in the screen
3. removed mySprite1 from the myCompositor ; mySprite1.Remove() and set the variable to invalid mySprite1 = invalid
4. Clear screen; myScreen.Clear(&h00000000)
5. Call the Draw function in compositor; myCompositor.Draw()
The strange behavior is that, when I do the step5, the myCompositor draws the remaining sprite (mySprite2) to the screen (without calling the myScreen.swapbuffers()).
At the bottom line, what I want to do is to spare some memory. That's why I am removing the sprites.
I also noticed that, the removed sprites DO NOT remove until I call the myCompositor.Draw() function as well.
Here is the actual code I've used
Function main()
' r2d2_bitmaps
screen = CreateObject("roScreen")
compositor1 = CreateObject("roCompositor")
compositor1.SetDrawTo(screen,&h00000000)
sp1 = compositor1.NewSprite(10,10,CreateObject("roRegion",CreateObject("roBitmap","pkg:/locale/default/images/image1.png"),100,100,300,300),10)
sp12 = compositor1.NewSprite(100, 100,CreateObject("roRegion",CreateObject("roBitmap","pkg:/locale/default/images/backbox.png"),0,0,228,195),10)
compositor2 = CreateObject("roCompositor")
compositor2.SetDrawTo(screen,&h00000000)
sp2 = compositor2.NewSprite(500,500,CreateObject("roRegion",CreateObject("roBitmap","pkg:/locale/default/images/image2.jpg"),100,100,300,300),10)
compositor1.Draw()
compositor2.Draw()
screen.SwapBuffers()
sleep(20000)
print "Now removing the sprites sp2 and sp12"
sp2.Remove()
sp12.Remove()
sp2 = invalid
sp12 = invalid
screen.SwapBuffers()
print "Check whether sprites are removed from the memory"
screen.Clear(&h00000000)
screen.SwapBuffers()
sleep(10000)
print "Now drawging"
compositor1.Draw()
compositor2.Draw()
print "Check now!"
sleep(10000)
End Function
Thanks for any ideas on this.
Cheers,
Chandana