[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
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

[Solved] Resolution NES (256x240)

Post 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 37 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: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post 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.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post 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 :)
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post 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
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post 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 157 times
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Resolution NES (256x240)

Post 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)
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post 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 168 times
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Resolution NES (256x240)

Post by pgimeno »

Try canvas:setFilter("linear", "nearest") at initialization.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Resolution NES (256x240)

Post by var77 »

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 78 guests