Page 1 of 1

Black image.

Posted: Sat Mar 26, 2011 3:58 am
by Mendokuse
Hi

Code: Select all

function love.load()
	image = love.graphics.newImage("image1.png")
	sound1 = love.audio.newSource("sound1.mp3")
	local f = love.graphics.newFont(14)
	love.graphics.setFont(f)
	love.graphics.setColor(0,0,0,255)
	love.graphics.setBackgroundColor(255,255,255)
end

Code: Select all

function love.draw()
	love.graphics.print("Hello World", 400, 600)
	love.graphics.draw(image)
end
Renders a black image for me. The text is also black.

If I remove

Code: Select all

love.graphics.setColor(0,0,0,255)
The whole screen is white (white text and image on white background)

Can someone tell me what I'm doing wrong?

EDIT: Huh, I read the PO2 syndrome and if I resize it to 256x256 it displays. I didn't think this would happen, my graphics card isn't too old (8800GTS)

Re: Black image.

Posted: Sat Mar 26, 2011 6:21 am
by Taehl
Everything's black because you use love.graphics.setColor(0,0,0,255), which sets the color to black. Color isn't reset between frames.

Re: Black image.

Posted: Sat Mar 26, 2011 6:27 am
by sharpobject
Hi, try it like this:

Code: Select all

function love.load()
   image = love.graphics.newImage("image1.png")
   sound1 = love.audio.newSource("sound1.mp3")
   local f = love.graphics.newFont(14)
   love.graphics.setFont(f)
   love.graphics.setBackgroundColor(255,255,255)
end

function love.draw()
   love.graphics.setColor(0,0,0,255)
   love.graphics.print("Hello World", 600, 400)
   love.graphics.setColor(255,255,255,255)
   love.graphics.draw(image)
end
Drawing the image after setting the color to black causes you to draw a black image. Drawing the text at (400,600) causes it to be just under the bottom of the window.

Re: Black image.

Posted: Sat Mar 26, 2011 9:12 am
by thelinx
Mendokuse wrote: EDIT: Huh, I read the PO2 syndrome and if I resize it to 256x256 it displays. I didn't think this would happen, my graphics card isn't too old (8800GTS)
It isn't really the graphics card's fault, it's because of shitty drivers. Are you sure your drivers are up to date?

Re: Black image.

Posted: Sat Mar 26, 2011 12:12 pm
by Mendokuse
thelinx wrote:
Mendokuse wrote: EDIT: Huh, I read the PO2 syndrome and if I resize it to 256x256 it displays. I didn't think this would happen, my graphics card isn't too old (8800GTS)
It isn't really the graphics card's fault, it's because of shitty drivers. Are you sure your drivers are up to date?
I was pretty sure they were.

Reinstalled now and everything's fine.

Thanks.