Page 1 of 1

[Solved] Resolution NES (256x240)

Posted: Sat Jan 12, 2019 11:37 am
by var77
Hi everyone,

I'm back here with a little issue about resolution. Actually i try to get the same resolution as the NES for some test.
Unfortunatly it didn't get the expected result in full screen mode. I try several things and wonder if any one got a tips for it ?

I try changing widht and height in conf.lua but no change in fullscreen (still 1920x1080).

I try this function:

Code: Select all

-- love.update
function scale_size()
width,height = love.graphics.getDimensions
window_width,window_height = love.graphics.getDimensions()
window_scale_y = window_height/256
window_scale_x = window_scale_y
window_translate_x = (window_width - (window_scale_x*240))/2
scr.h = window_scale_y
scr.w = window_scale_x
end

--love.draw()
love.graphics.translate(window_translate_x,0)
love.graphics.scale(window_scale_x,window_scale_y)
But the result is smooth not like with a sprite filter ("setFilter("nearest", "nearest", 0)")
and the "cross" mouse move far away from the screen.

All files if it help:
c.zip
(262.82 KiB) Downloaded 47 times
So if anyone got an idea ;)

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 12:05 pm
by ivan
Instead of scaling you could render everything to a 256x240 canvas. That would give you the nice pixelated aesthetic you are looking for.

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 12:36 pm
by var77
Thanks for the fast answer ivan unfortunatly i'm not very familiar with the canvas. I try a lil with love wiki but didn't give me good result with fullscren. So if you have some tips on it i'll appreciate :)

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 12:39 pm
by ivan

Code: Select all

canvas = love.graphics.newCanvas(256, 240)

function love.draw()
  love.graphics.setCanvas(canvas)
  -- draw everything to the canvas
  ...
  love.graphics.setCanvas()
  -- draw the canvas itself
  love.graphics.draw(canvas, 0, 0)
end

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 12:49 pm
by var77
thanks again i try your code it work in some sort but with lil improve (i guess i understand
why some part of the screen are hide but not why it didn't handle the full screen).
I let you see the result that make some strange things with the cross mouse.

files:
c.zip
(262.85 KiB) Downloaded 167 times

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 2:15 pm
by ivan
Almost there. You need to clear the canvas each frame:

Code: Select all

  love.graphics.setCanvas(canvas)
  love.graphics.clear()
In full screen mode, you have to use some sort of scaling to fill the screen:

Code: Select all

  -- draw the canvas itself
  local w, h = love.graphics.getDimensions()
  local cw, ch = canvas:getDimensions()
  love.graphics.draw(canvas, 0, 0, 0, w/cw, h/ch)

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 2:40 pm
by var77
This is close to what i was looking for. I just wondering why it's still smooth the pixel but
i guess it's my graphic card nvidia that force the job ?
c.zip
(262.89 KiB) Downloaded 183 times

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 2:53 pm
by pgimeno
Try canvas:setFilter("linear", "nearest") at initialization.

Re: Resolution NES (256x240)

Posted: Sat Jan 12, 2019 3:00 pm
by var77
That's it pal you save my day thanks both of you.