[Solved] Resolution NES (256x240)

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
var77
Prole
Posts: 30
Joined: Wed May 02, 2018 1:57 pm

[Solved] Resolution NES (256x240)

Post by var77 » Sat Jan 12, 2019 11:37 am

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 7 times
So if anyone got an idea ;)
Last edited by var77 on Sat Jan 12, 2019 3:02 pm, edited 1 time in total.

User avatar
ivan
Party member
Posts: 1410
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post by ivan » Sat Jan 12, 2019 12:05 pm

Instead of scaling you could render everything to a 256x240 canvas. That would give you the nice pixelated aesthetic you are looking for.

var77
Prole
Posts: 30
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post by var77 » Sat Jan 12, 2019 12:36 pm

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 :)

User avatar
ivan
Party member
Posts: 1410
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post by ivan » Sat Jan 12, 2019 12:39 pm

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

var77
Prole
Posts: 30
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post by var77 » Sat Jan 12, 2019 12:49 pm

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 9 times

User avatar
ivan
Party member
Posts: 1410
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post by ivan » Sat Jan 12, 2019 2:15 pm

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)

var77
Prole
Posts: 30
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post by var77 » Sat Jan 12, 2019 2:40 pm

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 10 times

User avatar
pgimeno
Party member
Posts: 1531
Joined: Sun Oct 18, 2015 2:58 pm

Re: Resolution NES (256x240)

Post by pgimeno » Sat Jan 12, 2019 2:53 pm

Try canvas:setFilter("linear", "nearest") at initialization.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories - portland (mobile orientation)
The MS-Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

var77
Prole
Posts: 30
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post by var77 » Sat Jan 12, 2019 3:00 pm

That's it pal you save my day thanks both of you.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests