Page 1 of 2
Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 2:57 am
by theelitenoob
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?
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 3:03 am
by Jasoco
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.
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 1:46 pm
by theelitenoob
oh, so each side of the image should be a multiple of 2 then?
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 1:56 pm
by clickrush
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:
in this case before I draw images. But I don't know if this is the way you should do it. It works though.
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 2:25 pm
by thelinx
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.
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 2:31 pm
by theelitenoob
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?
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 2:51 pm
by thelinx
16x32 works. The sides do not have to be equal.
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 2:54 pm
by theelitenoob
OK, thanks for clearing it up for me!
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 3:41 pm
by clickrush
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?
)
Re: Any drawing of a image from file results in a whit box?
Posted: Mon Dec 26, 2011 6:02 pm
by slime
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).