Images dont Load

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
Umbrageous
Prole
Posts: 8
Joined: Sat Apr 10, 2010 5:45 pm

Images dont Load

Post 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?
never
Prole
Posts: 10
Joined: Sun Apr 11, 2010 4:20 am

Re: Images dont Load

Post by never »

You should post your code :) I'm new to love but Ive spent a lot of time with the draw function.
Umbrageous
Prole
Posts: 8
Joined: Sat Apr 10, 2010 5:45 pm

Re: Images dont Load

Post 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
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Images dont Load

Post 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.
Umbrageous
Prole
Posts: 8
Joined: Sat Apr 10, 2010 5:45 pm

Re: Images dont Load

Post by Umbrageous »

Hmm, Seems almost unnesecary lol. So would it just be best to use all images that are a power of two?
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Images dont Load

Post by bmelts »

Yes.
Umbrageous
Prole
Posts: 8
Joined: Sat Apr 10, 2010 5:45 pm

Re: Images dont Load

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

Re: Images dont Load

Post by Robin »

You can also put this file:
padding.lua
(519 Bytes) Downloaded 221 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.
Help us help you: attach a .love.
Umbrageous
Prole
Posts: 8
Joined: Sat Apr 10, 2010 5:45 pm

Re: Images dont Load

Post by Umbrageous »

Wow! Thanks for the all the help, everything works fine now.
Post Reply

Who is online

Users browsing this forum: Tabaqui and 27 guests