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: 
gokool
Visitor

Draw2D working differently in Roku2 XS and Roku 3

Hi,
The below code results are different on a Roku2XS and Roku 3 when the sleep() is commented out.
Roku2 -> I see only the poster screen.
Roku3 -> I see poster screen and above that a blue rectangle.

When the sleep is enabled I see the same result as in Roku3.
Why is this happening??

sub main()
facade = CreateObject("roPosterScreen")
facade.Show()
screen = CreateObject("roScreen")
screen.drawRect(0,0,700,800,&ha03000FF) ' red
'screen.finish()
screen = invalid

screen = CreateObject("roScreen")
sleep(2000)
screen.drawRect(0,0,700,1000,&h0022ddFF) ' blue
screen.finish()
loop()
facade.close()

end sub

function loop()
while true
?"looop"
sleep(1000)

end while
end function


Thanks.
0 Kudos
8 REPLIES 8
TheEndless
Channel Surfer

Re: Draw2D working differently in Roku2 XS and Roku 3

Since you're not using a double-buffered screen, you're most likely seeing an anomaly resulting from the back buffer not being cleared first. Per the documentation, you cannot intermix roScreen and other screen components:
"http wrote:
Once an roScreen is created, the display stack enters "Game Mode", and other screen components cannot be used. Other screen components cannot be intermixed with roScreens as the roScreen display stack is maintained independently from the main screen component display stack. When the final roScreen component is closed, other screen components can be used again.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuMarkn
Visitor

Re: Draw2D working differently in Roku2 XS and Roku 3

You're basically drawing to an roScreen, deliberately NOT calling Finish, then destroying the screen. This is going to produce undefined results. I don't know why you commented out the Finish call, but you need it to get consistent results. Also setting the screen to invalid immediately after drawing it will cause it to display then immediately disappear.

--Mark
0 Kudos
gokool
Visitor

Re: Draw2D working differently in Roku2 XS and Roku 3

"TheEndless" wrote:
Since you're not using a double-buffered screen, you're most likely seeing an anomaly resulting from the back buffer not being cleared first. Per the documentation, you cannot intermix roScreen and other screen components:
"http wrote:
Once an roScreen is created, the display stack enters "Game Mode", and other screen components cannot be used. Other screen components cannot be intermixed with roScreens as the roScreen display stack is maintained independently from the main screen component display stack. When the final roScreen component is closed, other screen components can be used again.



thanks for the reply.
I was following the same for my app. I would close the roscreen and launch a new component, and again create a roscreen. This seems to be working in Roku3 but in Roku2, the new component is not getting cleared completely(i.e i can still see the background) but port responses are from the recreated roscreen. When I put a sleep(200) between closing a standard component and recreating a roscreen, it worked in Roku2 also.
So, I wanted to know what was going wrong here and how can i make my app work consistently across all Roku versions.
Is there any way to find which item is on top of the stack or if there are differents stacks maintained, how to clear one programatically?

Thanks
0 Kudos
gokool
Visitor

Re: Draw2D working differently in Roku2 XS and Roku 3

"RokuMarkn" wrote:
You're basically drawing to an roScreen, deliberately NOT calling Finish, then destroying the screen. This is going to produce undefined results. I don't know why you commented out the Finish call, but you need it to get consistent results. Also setting the screen to invalid immediately after drawing it will cause it to display then immediately disappear.

--Mark



Thanks for the reply.
Actually, from what I noticed only the sleep() call was making the difference in Roku2 to make it work like Roku3.
How to ensure my app will work consistently across all the Roku versions?

Thanks
0 Kudos
TheEndless
Channel Surfer

Re: Draw2D working differently in Roku2 XS and Roku 3

"gokool" wrote:
"TheEndless" wrote:
Since you're not using a double-buffered screen, you're most likely seeing an anomaly resulting from the back buffer not being cleared first. Per the documentation, you cannot intermix roScreen and other screen components:
"http wrote:
Once an roScreen is created, the display stack enters "Game Mode", and other screen components cannot be used. Other screen components cannot be intermixed with roScreens as the roScreen display stack is maintained independently from the main screen component display stack. When the final roScreen component is closed, other screen components can be used again.



thanks for the reply.
I was following the same for my app. I would close the roscreen and launch a new component, and again create a roscreen. This seems to be working in Roku3 but in Roku2, the new component is not getting cleared completely(i.e i can still see the background) but port responses are from the recreated roscreen. When I put a sleep(200) between closing a standard component and recreating a roscreen, it worked in Roku2 also.
So, I wanted to know what was going wrong here and how can i make my app work consistently across all Roku versions.
Is there any way to find which item is on top of the stack or if there are differents stacks maintained, how to clear one programatically?

Thanks

You're never clearing the screen in your code. I'd try adding a screen.Clear(&H000000FF) after you create the screen to ensure the screen is clear before drawing to it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
gokool
Visitor

Re: Draw2D working differently in Roku2 XS and Roku 3

"TheEndless" wrote:
You're never clearing the screen in your code. I'd try adding a screen.Clear(&H000000FF) after you create the screen to ensure the screen is clear before drawing to it.

If that is the case, then it shouldnt work in Roku3 also correct? But it is working fine in Roku3 and not working on Roku2.
0 Kudos
TheEndless
Channel Surfer

Re: Draw2D working differently in Roku2 XS and Roku 3

"gokool" wrote:
"TheEndless" wrote:
You're never clearing the screen in your code. I'd try adding a screen.Clear(&H000000FF) after you create the screen to ensure the screen is clear before drawing to it.

If that is the case, then it shouldnt work in Roku3 also correct? But it is working fine in Roku3 and not working on Roku2.

You asked how to make it consistent. I believe that would make it consistent, and is also what I personally would consider a best practice (clearing the screen before you use it).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
gokool
Visitor

Re: Draw2D working differently in Roku2 XS and Roku 3

"TheEndless" wrote:
"gokool" wrote:
"TheEndless" wrote:
You're never clearing the screen in your code. I'd try adding a screen.Clear(&H000000FF) after you create the screen to ensure the screen is clear before drawing to it.

If that is the case, then it shouldnt work in Roku3 also correct? But it is working fine in Roku3 and not working on Roku2.

You asked how to make it consistent. I believe that would make it consistent, and is also what I personally would consider a best practice (clearing the screen before you use it).


Thanks for the reply, but I am clearing the screen.
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.