Page 1 of 1

Images dont Load

Posted: Mon Apr 12, 2010 1:10 am
by Umbrageous
Images dont Load, when I Draw them, all i get is a white block in the dimensions of the original object, am i doing something wrong or is it a hardware failure?

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:15 am
by never
You should post your code :) I'm new to love but Ive spent a lot of time with the draw function.

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:16 am
by Umbrageous
I just used the Hamster Tutorial, but replaced it with the love logo

Code: Select all

function love.load()
lovelogo = love.graphics.newImage("love-logo.JPG")
x = 40
y = 50
speed = 100
end
function love.update(dt)
   if love.keyboard.isDown("right") then
      x = x + (speed * dt)
   elseif love.keyboard.isDown("left") then
      x = x - (speed * dt)
   end

   if love.keyboard.isDown("down") then
      y = y + (speed * dt)
   elseif love.keyboard.isDown("up") then
      y = y - (speed * dt)
   end
end

function love.draw()
love.graphics.draw(lovelogo, x, y)
end

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:19 am
by bmelts
It's a hardware thing. Some graphics cards don't support non-power-of-2 images - that is, images with dimensions that are not powers of 2. The LÖVE logo falls under this category.

The easiest way to deal with this is just to use images with power of 2 dimensions. However, for images that aren't the right size, you can use the padding function found on the wiki to avoid the issue.

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:46 am
by Umbrageous
Hmm, Seems almost unnesecary lol. So would it just be best to use all images that are a power of two?

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:50 am
by bmelts
Yes.

Re: Images dont Load

Posted: Mon Apr 12, 2010 1:52 am
by Umbrageous
Okay, but just for the sake of knowing can you take the bit of code i used, and show me how to correctly implement the padding function?

Re: Images dont Load

Posted: Mon Apr 12, 2010 2:44 pm
by Robin
You can also put this file:
padding.lua
(519 Bytes) Downloaded 295 times
in the same folder as your main.lua, and start your main.lua with:

Code: Select all

require 'padding'
Then you need to make no further changes to make it work.

Re: Images dont Load

Posted: Mon Apr 12, 2010 11:42 pm
by Umbrageous
Wow! Thanks for the all the help, everything works fine now.