Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ishish1
Level 7

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
2 Replies
necrotek
Level 11

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)
    bm.Finish()
    ba = bm.GetPng(0, 0, w, h)
    ba.WriteFile("tmp:/test.png")
 End Function
0 Kudos
Komag
Level 10

Re: Using ifDraw2D with SceneGraph

This is code snippet gold, thank you!

0 Kudos