0.6.0: red ball is a white square...

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
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

0.6.0: red ball is a white square...

Post by subrime »

Am I doing something wrong?

From the docs so far, I would imaging the following would put an image on the screen...

Code: Select all

ball=love.graphics.newImage('redball.png')
function love.draw()
  love.graphics.draw(ball,200,200)
end
but all it does is put a white square there instead of my lovely red ball...

Is my code wrong or is it a problem with Love?

(version 0.6.0, 20091123-20387c3a3d7c built from source on debian stable)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by bartbes »

The image's size is wrong. Older video cards/drivers have problems with images not being power-of-two sizes.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by Robin »

bartbes wrote:The image's size is wrong. Older video cards/drivers have problems with images not being power-of-two sizes.
IIRC you have three options:
  1. Update drivers(?)
  2. Change the image size yourself
  3. Wait until a image:padForCrappyDrivers() is implemented
Help us help you: attach a .love.
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: 0.6.0: red ball is a white square...

Post by subrime »

Aha... well, does this count as implemented?

Code: Select all

function fixed_newImageData(file)
  local i=love.image.newImageData(file)
  local x,y,nx,ny=i:getWidth(),i:getHeight(),1,1
  while nx<x do nx=nx*2 end
  while ny<y do ny=ny*2 end
  local f=love.image.newImageData(nx,ny)
  f:paste(i,0,0,0,0,x,y)
  return f
end
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by Robin »

subrime wrote:Aha... well, does this count as implemented?
That depends... does it work?
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by bartbes »

This seems like a good solution, though I wonder if this might be more efficient:

Code: Select all

nx = math.ceil(math.log(x)/math.log(2))
ny = math.ceil(math.log(y)/math.log(2))
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by Robin »

bartbes wrote:This seems like a good solution, though I wonder if this might be more efficient:

Code: Select all

nx = math.ceil(math.log(x)/math.log(2))
ny = math.ceil(math.log(y)/math.log(2))
Ah, but then, what about this:

Code: Select all

local mc, ml = math.ceil, math.log
local ml2inv = 1/ml(2)
nx = mc(ml(x)*ml2inv)
ny = mc(ml(y)*ml2inv)
... or maybe that makes it worse. :roll:

Of course, it won't matter that much, since you would never execute this code inside the game loop anyway.
Help us help you: attach a .love.
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: 0.6.0: red ball is a white square...

Post by subrime »

yes it works, though I would suggest that if you are concerned about speed it could be implemented in c with the rest of love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: 0.6.0: red ball is a white square...

Post by bartbes »

I'll discuss it with rude.

EDIT: btw i just realized I forgot to actually do the math.pow in my snippet, so that won't function.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest