Forum Discussion

Romans_I_XVI's avatar
Romans_I_XVI
Roku Guru
11 years ago

Does DrawRotatedObject() have poor performance?

So I am using this wacky code to randomly select from 1 of 4 bitmaps and 1 of 4 rotation angles thus giving me 16 different looking images displayed randomly which creates a nice electricity effect for my shield. This works great on my Roku 3 but I was just testing on my Roku 1 today and well the performance is horrible.


if this.shield_on
if this.shield_animation_timer.TotalMilliseconds() > 50
this.rnd_shield_old = this.rnd_shield
this.rnd_shield_rotation_old = this.rnd_shield_rotation
this.shield_animation_timer.Mark()
set_shield_animation:
this.rnd_shield = cint(rnd(4)-1)
this.rnd_shield_rotation = 90 * cint(rnd(4)-1)
this.x_offset = 0
this.y_offset = 0
if this.rnd_shield_rotation = 90
this.y_offset = 150
else if this.rnd_shield_rotation = 180
this.y_offset = 150
this.x_offset = 150
else if this.rnd_shield_rotation = 270
this.x_offset = 150
end if
if this.rnd_shield_rotation = this.rnd_shield_rotation_old and this.rnd_shield = this.rnd_shield_old
goto set_shield_animation
end if
end if
this.screen.DrawRotatedObject(this.spr_ship_x-33-10+this.x_offset, this.ship_y-21-10+this.y_offset, this.rnd_shield_rotation, this.bm_shield[this.rnd_shield], m.ship_color[m.active_ship].shield.hex)
end if


So the question is, is there a performance difference between these various forms of drawing to the screen:

  • Drawing sprites that are in the compositor using compositor.DrawAll()

  • Using screen.DrawObject()

  • Using screen.DrawScaledObject()

  • Using screen.DrawRotatedObject()


I guess it makes sense that if the game needs to handle rotating the image first it would take time, I just didn't think it would have this much of a performance hit.

Also note that I am colorifying (IDK the term but gimp calls it this) the shield using the optional hex color argument. Not sure if that could affect it as well.

I know that I could swap out DrawScaledObject() and DrawObject() temporarily to see what it does ( and I probably will ) but I just thought I'd see if anyone else has thoughts on this topic.

Cheers

18 Replies

  • Great, another Roku "family" to test against, why remove OpenGL? Surely that's an oversight on the table! 😞
  • "NewManLiving" wrote:
    What about the TV that is not listed as having open gl

    You've got a TV right? Does it rotate arbitrary? without openGL? or are you saying the list is wrong?
  • Let me clarify that. I think TheEndless has one perhaps he can test it. I like the arbitrary rotation. Don't like having to emulate it with region frames
  • "TheEndless" wrote:
    With that said.. looks like there's the potential I was wrong about the new Roku 2 and Roku 3. According to this chart, they don't have OpenGL, so maybe someone does need to test that out... (assuming OpenGL support is the requirement for arbitrary rotation).

    Eh. I wouldn't put stock in the 4/29 update of the table. First, there are couple of mistakes in the newly added columns for 2015 Roku2 and 2015 Roku3 (wrong model model#, indicating "yes" for Voice Capable Remote for Search on 2015-Roku2). Second, the person who did that edit has history of imprecise language (i.e. omissions/incorrect) in the docs.
  • "squirreltown" wrote:
    Call me crazy but perhaps someone with "Roku Engineering" after their name could give a definitive list of does dat do and does dat don't, including the most recent boxes -and while they're at it, how about available 2D graphic memory for the new boxes.



    *Crickets*


    ( I have an awesome Hollywood Edge "outdoors" SFX loop. Too bad you can't paste sounds in here. Just imagine you're listening to it.)
  • "RokuMarkn" wrote:
    The "gaming_hardware" capability refers to the ability to connect to a motion-enabled remote. In other words, the unit supports a WiFi Direct or Bluetooth remote. It doesn't change depending on what type of remote is actually being used. As far as I know, there isn't currently any easy way to detect whether OpenGL is implemented. If you really wanted to reliably detect whether nonorthogonal rotations are supported, I suppose you could rotate a small bitmap by 45 degrees and use GetByteArray to check whether it worked, although that's pretty ugly.

    Thank you for the clarification on "gaming_hardware"!
    Separately, I thought of checking on #2400 and it indeed returns False for gaming_hardware - which makes sense, i think it doesn't have the BT chip - but has OpenGLES.

    Testing for rotation through ifDraw2D.GetByteArray() is ingenious, if somewhat evil. I suppose testing for performance can be done in analogous way, i.e. benchmark how long does it take to do a few hundred DrawRotatedObject() on the particular player and then branch out depending on result.
  • "NewManLiving" wrote:
    Let me clarify that. I think TheEndless has one perhaps he can test it. I like the arbitrary rotation. Don't like having to emulate it with region frames

    The TV only rotates in 90 degree increments.