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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using ifDraw2D with SceneGraph

I would like to draw some more complex objects on my Roku channel. I have been using SceneGraph for everything but would like to utilize ifDraw2D functions in order to draw shapes, etc. What is the best way to do so? When I create my channel I use

screen = CreateObject("roSGScreen")

Do I just save a reference to this when I need to draw to the screen? I assume this means that I can't draw from component code and there is no way for the drawn pixels to be "contained" by a SceneGraph node correct?

0 Kudos
Roku Guru

Re: Using ifDraw2D with SceneGraph


Start a task in scengraph , set up a roBitmap and draw what you need.  use getPng(..) and save the result to device filesystem.  use that path for a poster image in scenegraph.


Function SaveTestPng()
    w = 200 : h = 100
    bm = CreateObject("roBitmap", {width: w, height: h, AlphaEnable: true})
    bm.DrawRect(10, 10, w-20, h-20, &hFF0000FF)
    ba = bm.GetPng(0, 0, w, h)
 End Function
Roku Guru

Re: Using ifDraw2D with SceneGraph

This is code snippet gold, thank you!

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.