Roku Developer Program

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

RAF custom buffer layer won't rotate.

I'm trying to implement a custom buffer screen for my RAF implementation. I'm placing an image of a spinner on the screen and using the "setAdBufferRenderCallback" method to update the TargetRotation of my spinner. When printing out the value i can see it update as expected but the spinner doesn't actually rotate. Even setting the default TargetRotation value doesn't seem to do anything? This same logic was implemented using roImageCanvas in our non-SceneGraph app and it worked fine. Any ideas why it now wouldn't work?

Here is my code

function setupBufferScreen(adIface)
    displaySize = CreateObject("roDeviceInfo").getDisplaySize()
    cW = displaySize.w
    cH = displaySize.h
    bg = getSpinnerBG(cW, cH)
    spinner = getSpinnerLayer(cW, cH)
    adIface.setAdBufferScreenLayer(0, bg)
    adIface.setAdBufferScreenLayer(1, spinner)
    adIface.setAdBufferRenderCallback(bufferScreenCallback, {}, 0)
end function

function bufferScreenCallback(state as Dynamic, eventType as String, ctx as Dynamic)
    if eventType = "Progress"
        ctx.canvasLayers[1].TargetRotation = ctx.progress
        ? "TARGET ROTATION: "; ctx.canvasLayers[1].TargetRotation
    end if
end function

function getSpinnerBG(cW, cH)
    spinnerBGSize = 125
    spinnerBGLayout = {
        x        : Int((cW / 2) - (spinnerBGSize / 2))
        y        : Int((cH / 2) - (spinnerBGSize / 2))
        w        : spinnerBGSize
        h        : spinnerBGSize
    }

    return {
        Color: "#101010"
        CompositionMode: "Source"
        TargetRect: spinnerBGLayout
    }
end function

function getSpinnerLayer(cW, cH)
    spinnerSize = 100
    spinnerX = Int((cW / 2) - (spinnerSize / 2))
    spinnerY = Int((cH / 2) - (spinnerSize / 2))
    spinnerTargetRect = {
        x: spinnerX,
        y: spinnerY,
        w: spinnerSize,
        h: spinnerSize
    }
    return {
        url: "pkg://images/spinner.png",
        TargetRect: spinnerTargetRect,
        TargetTranslation: { x: spinnerX, y: spinnerY },
        TargetRotation: 90,
        CompositionMode: "Source"
    }
end function


Here is the output in the console:

rafrndr-renderTypeChanged() - client-inserted
added child: Rectangle id: 1 subtype: Rectangle
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  0
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  6
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  13
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  19
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  26
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  6
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  13
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  19
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  26
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  99
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  99
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  100
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
0 Kudos
4 Replies
Roku Employee
Roku Employee

Re: RAF custom buffer layer won't rotate.

Does this work when you do it outside RAF API?
Some models do not support object rotation. Try
? createObject("roDeviceInfo").GetGraphicsPlatform() 

if "opengl" - can rotate, if "directfb" - can't.
0 Kudos
kelweb87
Level 7

Re: RAF custom buffer layer won't rotate.

"RokuNB" wrote:
Does this work when you do it outside RAF API?
Some models do not support object rotation. Try
? createObject("roDeviceInfo").GetGraphicsPlatform() 

if "opengl" - can rotate, if "directfb" - can't.

I've double checked and it's returning "opengl" but still no rotation.
0 Kudos
Veeta
Level 7

Re: RAF custom buffer layer won't rotate.

Have you tried calling adIface.setAdBufferScreenLayer() after you change the TargetRotation?  

I notice in the roImageCanvas documentation that: "The screen is redrawn when SetLayer()is called."  Most likely you are changing the inputs but aren't triggering any rendering.
0 Kudos
kelweb87
Level 7

Re: RAF custom buffer layer won't rotate.

"Veeta" wrote:
Have you tried calling adIface.setAdBufferScreenLayer() after you change the TargetRotation?  

I notice in the roImageCanvas documentation that: "The screen is redrawn when SetLayer()is called."  Most likely you are changing the inputs but aren't triggering any rendering.

I've not but I've added a 3rd layer which displays the progress amount in text and that is updating as expected so it's definitely re-rendering. Also, any default value applied to TargetRotation has no affect, it seems as though it's not possible at all.
0 Kudos