Black image.

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
Mendokuse
Prole
Posts: 4
Joined: Sat Mar 26, 2011 3:53 am

Black image.

Post 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)
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Black image.

Post 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.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
sharpobject
Prole
Posts: 44
Joined: Fri Mar 18, 2011 2:32 pm
Location: California

Re: Black image.

Post 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.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Black image.

Post 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?
Mendokuse
Prole
Posts: 4
Joined: Sat Mar 26, 2011 3:53 am

Re: Black image.

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests