Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tim_a_lacey
Visitor

Multiple roScreen Handling (with double buffering)

Hey Roku Dev Community,

I'm developing a channel with multiple roScreen's to create custom screens with animation provided by sprites. The issue I'm facing is safely passing off between roScreens. I've made attempts that have either resulted in
    stack overflow and crashing

    inconsistent screen output, randomly returning a blank screen

    a complete disaster when attempting to pass off between a double buffered roScreen and another


I know this is easily achieved with template screens by waiting for
msg.isScreenClosed()
indicating the screen has safely closed, then exiting a while true loop, but a similar feature is missing for roScreen.

I have successfully handled passing between single buffered roScreens
Function Main() as void

screen = CreateObject("roScreen", false) ' single buffered roScreen
screen.Clear(&h662D9100 + 255) 'Roku Purple
screen.SetAlphaEnable(True)

port = CreateObject("roMessagePort")
screen.SetMessagePort(port) 'send events to port

catBackground = CreateObject("roBitmap", "pkg:/images/cat-1280x720.jpg")
if type(catBackground) = "Invalid"
print "type(catBackground) = Invalid"
end if

' update screen
screen.DrawObject(0, 0, catBackground)
screen.Finish()
'screen.Clear(&h0000FF00 + 255) ' clear screen for new frame, colourBlue on screen will indicate error
print "displaying cat"

' user input
while true
message = wait(0, port) ' get a message, if available
if type(message) = "roUniversalControlEvent" then
buttonAction = message.GetInt()
'print buttonAction
if (buttonAction = 0) then
' back button - close screen
print "------ Closed ------"
return

else if (buttonAction = 10) then
' Info/Options button (*)
print "* Button Pressed - leaving cat"
Lion()
print "Returned to cat"
screen.DrawObject(0, 0, catBackground)
screen.Finish()
endif
endif
end while
End Function

Function Lion() as void
lionBackground = CreateObject("roBitmap", "pkg:/images/lion-1280x720.jpg")
if type(lionBackground) = "Invalid"
print "type(lionBackground) = Invalid"
end if

screen = CreateObject("roScreen", false)
screen.Clear(&h662D9100 + 255) 'Roku Purple
screen.SetAlphaEnable(True)

port = CreateObject("roMessagePort")
screen.SetMessagePort(port) 'send events to port

' update screen
screen.DrawObject(0, 0, lionBackground)
screen.Finish()
'screen.Clear(&hFF000000 + 255) ' clear screen for new frame, colourRed on screen will indicate error
print "displaying lion"

' user input
while true

message = wait(0, port) ' get a message, if available
if type(message) = "roUniversalControlEvent" then
buttonAction = message.GetInt()
'print buttonAction
if (buttonAction = 0) then
' back button - close screen
print "------ Closed ------"
return

else if (buttonAction = 10) then
' Info/Options button (*)
print "* Button Pressed - leaving lion, returning to main()"
' print "screen = Invalid"
' screen = Invalid
exit while

endif
endif
end while

End Function



However when implementing with double buffered roScreens, it adds an extra layer of complexity.

I'm looking for a way to efficiently handle the transition between multiple double buffered roScreens. Any help is greatly appreciated.
0 Kudos
2 REPLIES 2
squirreltown
Roku Guru

Re: Multiple roScreen Handling (with double buffering)

Not aware of any good reason to have more than one roScreen. Just assign whatever you are drawing currently to it.
Kinetics Screensavers
0 Kudos
Komag
Roku Guru

Re: Multiple roScreen Handling (with double buffering)

perhaps more advanced use of bitmaps and regions could come into play, and be sent to the single screen and controlled more easily
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.