Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
2016-06 RenderTarget bug on older devices — Gideros Forum

2016-06 RenderTarget bug on older devices

totebototebo Member
edited July 2016 in General questions
On older devices RenderTarget fails to copy any pixels if the area is very narrow, in my case for an energy bar. This code shows the issue.
local shape = Shape.new()
shape:setFillStyle(Shape.SOLID, 0xff0000, 1)
shape:beginPath()
shape:moveTo(0,0)
shape:lineTo(100, 0)
shape:lineTo(100, 100)
shape:lineTo(0, 100)
shape:lineTo(0, 0)
shape:endPath()
stage:addChild(shape)
 
local width = 100 
local height = 5 -- Using a value of 10 works on all devices
local rt = RenderTarget.new( width, height )
local bitmap = Bitmap.new( rt )
rt:draw( shape )
bitmap:setX( 125 )
stage:addChild( bitmap )
On these devices no pixels are copied:

- iPad 2
- iPod Touch 5th generation
- iPhone 5

On these it works fine (all pixels are copied):

- Local Gideros Player
- Nexus 6
- iPad Mini Retina


A workaround could be to keep adding pixels to the height until something shows up, but this makes the energy bar (in my case) too tall. Is this a known issue?

I've also added an issue on Github here: https://github.com/gideros/gideros/issues/241
My Gideros games: www.totebo.com

Comments

  • hgy29hgy29 Maintainer
    edited July 2016 Accepted Answer
    Looks like a device dependant FBO restriction to me, but there are workaround. First I can think of is enlarge your rendertarget but clip the Bitmap that uses it. Second thought is do you need a rendertarget at all ?
  • totebototebo Member
    edited July 2016
    Okay, clipping the bitmap can work. I'll give it a go.

    In this case I do need RenderTarget, or... actually, maybe I could just clip the bitmap? Will come back after some tests.
    My Gideros games: www.totebo.com
  • totebototebo Member
    Doh! setClip() to the rescue. The code is so much cleaner. Thanks for the nudge @hgy29!

    Likes: antix, john26

    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    Does rendertarget to the power of two not work? Then clip it? Or is that what you have done?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • totebototebo Member
    Yeah, I use setClip now and that works. I had to add 1px to around the clip for some reason, because the exact coordinates cropped it a little. But it works, whereas RenderTarget didn't.
    My Gideros games: www.totebo.com
  • SinisterSoftSinisterSoft Maintainer
    I think rendertarget works as in 0 to width-1 and 0 to height-1 rather than 1 to width and 1 to height when plotting coords.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
Sign In or Register to comment.