Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
RTT bug — Gideros Forum

RTT bug

RickyngkRickyngk Member
edited July 2013 in General questions
I've found a bug while working with RTT
local rt1 = RenderTarget.new(1024, 768, true)
local texture1 = Texture.new("logo.png")
local bitmap1 = Bitmap.new(texture1)
bitmap1:setPosition(0, 0)
rt1:draw(bitmap1)
local b_rt1 = Bitmap.new(rt1)
stage:addChild(b_rt1)
 
local rt2 = RenderTarget.new(1024, 768, true)
local texture2 = Texture.new("icon.png")
local bitmap2 = Bitmap.new(texture2)
bitmap2:setPosition(bitmap1:getWidth(), 0)
rt2:draw(bitmap2)
local b_rt2 = Bitmap.new(rt2)
stage:addChild(b_rt2)
It looks ok, and result is att1

But, if I replace local bitmap2 = Bitmap.new(texture2) by local bitmap2 = Bitmap.new(texture1) (That mean I DO NOT USE texture2 anymore), icon image still be displayed and scaled. (att2)
local rt1 = RenderTarget.new(1024, 768, true)
local texture1 = Texture.new("logo.png")
local bitmap1 = Bitmap.new(texture1)
bitmap1:setPosition(0, 0)
rt1:draw(bitmap1)
local b_rt1 = Bitmap.new(rt1)
stage:addChild(b_rt1)
 
local rt2 = RenderTarget.new(1024, 768, true)
local texture2 = Texture.new("icon.png")
local bitmap2 = Bitmap.new(texture1)
bitmap2:setPosition(bitmap1:getWidth(), 0)
rt2:draw(bitmap2)
local b_rt2 = Bitmap.new(rt2)
stage:addChild(b_rt2)
After that, I remove local texture2 = Texture.new("icon.png"):
local rt1 = RenderTarget.new(1024, 768, true)
local texture1 = Texture.new("logo.png")
local bitmap1 = Bitmap.new(texture1)
bitmap1:setPosition(0, 0)
rt1:draw(bitmap1)
local b_rt1 = Bitmap.new(rt1)
stage:addChild(b_rt1)
 
local rt2 = RenderTarget.new(1024, 768, true)
--local texture2 = Texture.new("icon.png")
--local bitmap2 = Bitmap.new(texture2)
local bitmap2 = Bitmap.new(texture1)
bitmap2:setPosition(bitmap1:getWidth(), 0)
rt2:draw(bitmap2)
local b_rt2 = Bitmap.new(rt2)
stage:addChild(b_rt2)
Logo is displayed only one times. Nothing inside rt2 (att3)

It seems that bug will happen if we create/load a texture after calling RenderTarget:draw(). So, we should load & create texture before rendering. The following code works well:
local texture1 = Texture.new("logo.png")
local texture2 = Texture.new("icon.png")
 
local rt1 = RenderTarget.new(1024, 768, true)
local rt2 = RenderTarget.new(1024, 768, true)
 
local bitmap1 = Bitmap.new(texture1)
bitmap1:setPosition(0, 0)
rt1:draw(bitmap1)
local b_rt1 = Bitmap.new(rt1)
stage:addChild(b_rt1)
 
local bitmap2 = Bitmap.new(texture1)
bitmap2:setPosition(bitmap1:getWidth(), 0)
rt2:draw(bitmap2)
local b_rt2 = Bitmap.new(rt2)
stage:addChild(b_rt2)
However, It's impossible in real game ;)

Comments

Sign In or Register to comment.