about drawing images

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
NC22
Prole
Posts: 9
Joined: Sat Jul 16, 2011 12:36 am

about drawing images

Post 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?
Attachments
rest.jpg
rest.jpg (44.36 KiB) Viewed 3288 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: about drawing images

Post by kikito »

That looks like a case of PO2_Syndrome
When I write def I mean function.
NC22
Prole
Posts: 9
Joined: Sat Jul 16, 2011 12:36 am

Re: about drawing images

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: about drawing images

Post 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.
Help us help you: attach a .love.
User avatar
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

Re: about drawing images

Post 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? :P
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: about drawing images

Post 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.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: about drawing images

Post by vrld »

Sometimes these errors can be fixed by updating the graphics drivers. At least with Intel cards that is.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: about drawing images

Post 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?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: about drawing images

Post 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 :neko:
User avatar
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

Re: about drawing images

Post 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 :P
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 40 guests