Any drawing of a image from file results in a whit box?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
theelitenoob
Prole
Posts: 7
Joined: Sun Dec 25, 2011 1:22 am
Location: Athens!
Contact:

Any drawing of a image from file results in a whit box?

Post by theelitenoob » Mon Dec 26, 2011 2:57 am

Help! I have no idea why, but no matter whenever i draw a .png image from a sprite-sheet or any other image, even standalone ones my game only ever shows a white box or rectangle, i followed all the docs and tuts but it doesn't help! Anyone know how to fix this?
hi, I'm The Elite Noob

User avatar
Jasoco
Inner party member
Posts: 3653
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Any drawing of a image from file results in a whit box?

Post by Jasoco » Mon Dec 26, 2011 3:03 am

Power of 2 Syndrome strikes again!

0.8.0 can't come soon enough to stop these threads from being posted over and over and over.

http://love2d.org/wiki/PO2_Syndrome

Make your image sizes a multiple of 2.

i.e. 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

Some graphics cards can't handle images with sizes that aren't PO2. Yours can't for instance.

User avatar
theelitenoob
Prole
Posts: 7
Joined: Sun Dec 25, 2011 1:22 am
Location: Athens!
Contact:

Re: Any drawing of a image from file results in a whit box?

Post by theelitenoob » Mon Dec 26, 2011 1:46 pm

oh, so each side of the image should be a multiple of 2 then?
hi, I'm The Elite Noob

User avatar
clickrush
Citizen
Posts: 83
Joined: Tue Dec 13, 2011 12:50 am

Re: Any drawing of a image from file results in a whit box?

Post by clickrush » Mon Dec 26, 2011 1:56 pm

theelitenoob wrote:oh, so each side of the image should be a multiple of 2 then?
each side should be a power of two: 2,4,8,16,32,64...

It does not have to be this problem though. It could also be because of

Code: Select all

love.graphics.setColor(255,255,255)
it also overwrites images.
I use:

Code: Select all

love.graphics.reset
in this case before I draw images. But I don't know if this is the way you should do it. It works though.
Sry about my english.

User avatar
thelinx
The Strongest
Posts: 848
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Any drawing of a image from file results in a whit box?

Post by thelinx » Mon Dec 26, 2011 2:25 pm

clickrush wrote:

Code: Select all

love.graphics.setColor(255,255,255)
it also overwrites images.
This is incorrect. If the colour is set to white (255, 255, 255) when drawing an image, no colour modulation is performed on that image.
It's only if the colour is set to like, red, or something, that the pictures you draw will appear red.

User avatar
theelitenoob
Prole
Posts: 7
Joined: Sun Dec 25, 2011 1:22 am
Location: Athens!
Contact:

Re: Any drawing of a image from file results in a whit box?

Post by theelitenoob » Mon Dec 26, 2011 2:31 pm

clickrush wrote:
theelitenoob wrote:oh, so each side of the image should be a multiple of 2 then?
each side should be a power of two: 2,4,8,16,32,64...
Ok, so for example can i have an image that is 16x32? or does it have to be 32x32?
hi, I'm The Elite Noob

User avatar
thelinx
The Strongest
Posts: 848
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Any drawing of a image from file results in a whit box?

Post by thelinx » Mon Dec 26, 2011 2:51 pm

16x32 works. The sides do not have to be equal.

User avatar
theelitenoob
Prole
Posts: 7
Joined: Sun Dec 25, 2011 1:22 am
Location: Athens!
Contact:

Re: Any drawing of a image from file results in a whit box?

Post by theelitenoob » Mon Dec 26, 2011 2:54 pm

OK, thanks for clearing it up for me! :)
hi, I'm The Elite Noob

User avatar
clickrush
Citizen
Posts: 83
Joined: Tue Dec 13, 2011 12:50 am

Re: Any drawing of a image from file results in a whit box?

Post by clickrush » Mon Dec 26, 2011 3:41 pm

thelinx wrote:
clickrush wrote:

Code: Select all

love.graphics.setColor(255,255,255)
it also overwrites images.
This is incorrect. If the colour is set to white (255, 255, 255) when drawing an image, no colour modulation is performed on that image.
It's only if the colour is set to like, red, or something, that the pictures you draw will appear red.
yeah I had pure black I think and it took me ages to figure out why the image is black then (duh!)

I find this interesting though. why does white only behave like this? This is cool because i can use setColor white instead of reset now :) (is it possibly for this exact reason? :? )
Sry about my english.

User avatar
slime
Solid Snayke
Posts: 2904
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Any drawing of a image from file results in a whit box?

Post by slime » Mon Dec 26, 2011 6:02 pm

clickrush wrote:I find this interesting though. why does white only behave like this? This is cool because i can use setColor white instead of reset now :) (is it possibly for this exact reason? :? )
In OpenGL, the RGBA values of colors are between 0 and 1, with white being 1,1,1,1. When you setColor, it multiplies the 0-1 rgba values of the image's pixels with the 0-1 rgba values of the color you set, so white (255, 255, 255) gets translated to 1,1,1,1, and then it does component-wise multiplication, so if the pixel is already white (1,1,1,1) then it will be (1*1, 1*1, 1*1, 1*1) which is still white. If the pixel is sort of orange or something (1,0.5,0,1) then the final result will still be the same (1*1, 0.5*1, 0*1, 1*1).

Post Reply

Who is online

Users browsing this forum: Cai.0 and 34 guests