Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Render to Texture bug (maybe only some devices?) — Gideros Forum

Render to Texture bug (maybe only some devices?)

SinisterSoftSinisterSoft Maintainer
edited July 2013 in Bugs and issues
I did a quick render to texture test. It works fine in the emulator and fine on my Samsung S3 - but on the Ouya it's a black screen.

Here is the code, can people test and report if it's black or it it has colours blocks falling.
<pre>
require "box2d"
 
application:setScaleMode("stretch")
 
application:setFps(60)
application:setBackgroundColor(0x000000)
 
b2.setScale(20) -- pixels per metre
 
sprites={}
 
world=b2.World.new(0,9.8) -- x gravity, y gravity
bottom=world:createBody({})
ground=b2.EdgeShape.new(-200,320,520,320)  -- x1,y1,x2,y2
bottom:createFixture({shape=ground,density=0})
 
function box(x,y,w,h,c,t)
	if t==nil then
		t=1
	end
 
	local body=world:createBody{type=b2.DYNAMIC_BODY,
								position={x=x,y=y}}
 
	local shape=b2.PolygonShape.new()
	shape:setAsBox(w/2,h/2) -- w/2,h/2,centre x,centre y,angle
	body:createFixture{shape=shape,
						density=1,
						restitution=0.1,
						friction=0.3}
 
	local sprite = Shape.new()
	size=w+h
	size=size/2
	sprite:setFillStyle(Shape.SOLID,c,t/size*2)
 
 
 
	for loop=1,size do
		div=(1/loop)*size
 
		sprite:moveTo(0/div,-h/div)
		sprite:lineTo((w/1.50)/div,(-h/1.12)/div)
		sprite:lineTo((w/1.25)/div,(-h/1.25)/div)
		sprite:lineTo((w/1.12)/div,(-h/1.50)/div)
		sprite:lineTo(w/div,0/div)
 
		sprite:lineTo((w/1.12)/div,(h/1.50)/div)
		sprite:lineTo((w/1.25)/div,(h/1.25)/div)
		sprite:lineTo((w/1.50)/div,(h/1.12)/div)
 
		sprite:lineTo(0/div,h/div)
 
		sprite:lineTo((-w/1.50)/div,(h/1.12)/div)
		sprite:lineTo((-w/1.25)/div,(h/1.25)/div)
		sprite:lineTo((-w/1.12)/div,(h/1.50)/div)
 
		sprite:lineTo(-w/div,0/div)
		sprite:lineTo((-w/1.12)/div,(-h/1.50)/div)
		sprite:lineTo((-w/1.25)/div,(-h/1.25)/div)
		sprite:lineTo((-w/1.50)/div,(-h/1.12)/div)
		sprite:endPath()
	end
 
	sprite:setFillStyle(Shape.SOLID,c,t)
	sprite:beginPath()
	sprite:moveTo(-w/2,-h/2)
	sprite:lineTo(w/2,-h/2)
	sprite:lineTo(w/2,h/2)
	sprite:lineTo(-w/2,h/2)
	sprite:endPath()
 
	w=sprite:getWidth()
	h=sprite:getHeight()
	sprite:setPosition(w/2,h/2)
	print(w)
	print(h)
	print(" ")
	dest=RenderTarget.new(w,h)
	dest:draw(sprite)
	sprite=Bitmap.new(dest)
	sprite:setAnchorPoint(0.5,0.5)
 
	stage:addChild(sprite)
	sprites[body]=sprite
	return sprite
end
 
count=0
 
function onEnterFrame(event)
	local pi=math.pi
	local pi180=180/pi
 
	world:step(1/60,8,3) -- time stepped, volocity count, position count
 
	count=count+1
	if count%100==0 then
		box(math.random(0,480),-400,math.random(20,100),math.random(20,100),math.random(0,0xffffff))
	end
 
	for body,sprite in pairs(sprites) do
		sprite:setPosition(body:getPosition())
		sprite:setRotation(body:getAngle()*pi180)
	end
 
end
 
stage:addEventListener(Event.ENTER_FRAME,onEnterFrame)

Likes: dealsnap

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
+1 -1 (+1 / -0 )Share on Facebook

Comments

Sign In or Register to comment.