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 .
subrime
Citizen
Posts: 76 Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia
Post
by subrime » Sat Nov 28, 2009 9:01 am
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)
bartbes
Sex machine
Posts: 4946 Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:
Post
by bartbes » Sat Nov 28, 2009 9:44 am
The image's size is wrong. Older video cards/drivers have problems with images not being power-of-two sizes.
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Sat Nov 28, 2009 9:58 am
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:
Update drivers(?)
Change the image size yourself
Wait until a image:padForCrappyDrivers() is implemented
subrime
Citizen
Posts: 76 Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia
Post
by subrime » Sat Nov 28, 2009 11:10 am
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
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Sat Nov 28, 2009 11:31 am
subrime wrote: Aha... well, does this count as implemented?
That depends... does it work?
bartbes
Sex machine
Posts: 4946 Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:
Post
by bartbes » Sat Nov 28, 2009 11:35 am
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))
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Sat Nov 28, 2009 12:50 pm
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.
Of course, it won't matter that much, since you would never execute this code inside the game loop anyway.
subrime
Citizen
Posts: 76 Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia
Post
by subrime » Sat Nov 28, 2009 5:29 pm
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.
bartbes
Sex machine
Posts: 4946 Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:
Post
by bartbes » Sat Nov 28, 2009 9:14 pm
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.
Users browsing this forum: Bing [Bot] and 5 guests