Hello everyone,
I'm having some trouble rendering a canvas in the correct colors. It works fine the first time (when the canvas is generated in love.load()), that version is rendered in a random alternating green and blue as expected. Pressing 'R' once will regenerate the canvas using the same code that's called in love.load(), pressing 'R' again will swap the old canvas with the one generated in the previous step. When the new canvas is rendered it's either green on black or blue on black.
The larger square that's rendered after somehow becomes blue too. I'm sure I'm doing something dumb, it's been a while since I messed around with Love and probably missing something very obvious.
- edit
Added the ZIP file, didn't realise the attachment upload is separate from the post submit
Love version: 0.9.2
The functions involved:
modules/tilemapGenerator.lua
tilemapGenerator:generateWater(bFillAll)
Generates a new random map
modules/tilemapRenderer.lua
tilemapRenderer:drawMap(map)
Renders the map table to a canvas
main.lua
love.load()
Generates the map for the first time (this one renders OK)
love.update(dt)
The first time 'R' is pressed, a new map is generated, the second time 'R' is pressed, the canvas for the new map is rendered
load.draw()
Draws the canvas and the 'player tile'
love.keypressed()
Increments 'iMapRefresh' which is used in love.update() to refresh the map.
Canvas color problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- BadLuckBurt
- Prole
- Posts: 6
- Joined: Mon Oct 07, 2013 2:05 pm
- Location: Netherlands
Canvas color problem
- Attachments
-
- dunia.zip
- Project files
- (6.74 KiB) Downloaded 180 times
Re: Canvas color problem
Are you setting the color back to white before drawing the canvas onto the main screen (love.graphics.setColor(255,255,255))?
- BadLuckBurt
- Prole
- Posts: 6
- Joined: Mon Oct 07, 2013 2:05 pm
- Location: Netherlands
Re: Canvas color problem
No, I was not but just added that line and it works fine nowS0lll0s wrote:Are you setting the color back to white before drawing the canvas onto the main screen (love.graphics.setColor(255,255,255))?
Thank you very much!
Re: Canvas color problem
As an explanation: when drawing Canvas or Images, the color and image texel get mixed (see the default shader in love.graphics.newImage's documentation) by multiplying the colors component-wise.BadLuckBurt wrote:No, I was not but just added that line and it works fine nowS0lll0s wrote:Are you setting the color back to white before drawing the canvas onto the main screen (love.graphics.setColor(255,255,255))?
Thank you very much!
- BadLuckBurt
- Prole
- Posts: 6
- Joined: Mon Oct 07, 2013 2:05 pm
- Location: Netherlands
Re: Canvas color problem
Thanks for explaining. When I ran into the problem I did recall posts on this forum from people having the same issue (yes, I lurked ) so I figured I'd ask.
I changed the code a bit last night and now it can generate an image with random colors and an adjustable tile size
I changed the code a bit last night and now it can generate an image with random colors and an adjustable tile size
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests