Page 1 of 1
about drawing images
Posted: Wed Aug 10, 2011 4:33 pm
by NC22
I test LOVE game on two computers. One of them is netbook with mobile graphic card , second is usual PC. When I run game on netbook all images who have not standard size (26x26 25x25 etc) Love render as white cubes . On PC all renders fine. Have any ideas how to fix that? Is the problem of compatibility?
Re: about drawing images
Posted: Wed Aug 10, 2011 4:36 pm
by kikito
That looks like a case of
PO2_Syndrome
Re: about drawing images
Posted: Wed Aug 10, 2011 5:03 pm
by NC22
thx! Simple and helpful solution posted by Robin
Code: Select all
local nwimage = love.graphics.newImage
function love.graphics.newImage(source)
if type(source) == "string" then
source = love.image.newImageData(source)
end
local w, h = source:getWidth(), source:getHeight()
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return nwimage(padded)
end
return nwimage(source)
end
Re: about drawing images
Posted: Wed Aug 10, 2011 9:02 pm
by Robin
Not originally my code, but glad I could "help".
Also, some time in the future (probably sooner rather than later), LÖVE 0.8.0 will come out, and it has auto-padding for computers that need it, which means you don't have to worry about all that any more.
Re: about drawing images
Posted: Thu Aug 11, 2011 5:21 am
by ntpspe
Hmm I've never encountered this PO2 Syndrome, possibly because I always use numbers that are powers of two instinctively, seems to make more sense to me... that a bad thing?
Also, does this PO2S affect only LOVE/Lua or is it applicable to other things such as C+ e.c.t.? It's interesting to say the least, I can't understand why a graphics card can't display something just because it's not a power of 2 :L if it affects other things then hardware manufacturers should be ashamed... or are we talking win98 cards/drivers?
Re: about drawing images
Posted: Thu Aug 11, 2011 6:08 am
by Ensayia
PO2 syndrome is caused by graphics drivers. Nvidia cards usually don't have the problem but ATI cards do from what I hear.
Re: about drawing images
Posted: Thu Aug 11, 2011 7:27 am
by vrld
Sometimes these errors can be fixed by updating the graphics drivers. At least with Intel cards that is.
Re: about drawing images
Posted: Thu Aug 11, 2011 12:25 pm
by TechnoCat
vrld wrote:Sometimes these errors can be fixed by updating the graphics drivers. At least with Intel cards that is.
How do I update them on Ubuntu?
Re: about drawing images
Posted: Thu Aug 11, 2011 1:14 pm
by T-Bone
TechnoCat wrote:vrld wrote:Sometimes these errors can be fixed by updating the graphics drivers. At least with Intel cards that is.
How do I update them on Ubuntu?
In the dash, type and click on Hardware Drivers
Re: about drawing images
Posted: Thu Aug 11, 2011 3:14 pm
by ntpspe
There's no hardware drivers avaliable for my machine >.< Advent 4211 (rebranded MSI wind) I was looking for ways to just download the drivers from a website and use them with ubuntu, but meh... it works, that's all that matters.
From what PCWorld told me, my computer doesn't have a proper graphics card, just the default motherboard one for the monitor, and uses Intel express media accelerator... and they were confused that this netbook ran doom3