TLfres
So I'm trying to learn the ropes on changing between resolutions and fullscreen/windowed-mode. I've been trying to use TLfres as according to this: https://love2d.org/wiki/TLfres
The first problem I encounted with version 1.0.4 is the following error:
Code: Select all
TLfres.lua:36: attempt to perform arithmetic on global 'e' (a nil value)
Code: Select all
function TLfres.letterbox(w,h, c)
w,h,c = w or 4, h or 3, c or {0,0,0, 255}
color(c)
local tall,de = TLfres.e/w*h, TLfres.e*2
if TLfres.centered then
rect("fill", -TLfres.e,-TLfres.e, de,TLfres.e-tall)
rect("fill", -TLfres.e,TLfres.e, de,tall-TLfres.e)
else
local o = (ws-hs) / ws * (TLfres.e-1)
rect("fill", 0,-o, de,TLfres.e-tall)
rect("fill", 0,de-o, de,tall-TLfres.e)
end
end
Anyhow, I followed the wiki and applied TLfres into my code to test it. Before even changing resolution, my game already looks messed up! I attached an image to show what I mean. The game's original resolution is at 1280x768.
I make sure to call TLfres.setScreen in love.load(), but is this the correct place to call it?
Code: Select all
TLfres.setScreen({w=1280,h=768,full=false,vsync=false,aa=0},1280)
Code: Select all
function love.draw()
TLfres.transform()
--draw backgrounds first, then other stuff
background_draw()
if gamestate == "menu" then
button_draw()
elseif gamestate == "optionmenu" then
optionbutton_draw()
end
--draw the frames per second
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS()), 10, 30)
TLfres.letterbox(12,9)
end
love.graphics.setMove()
I also tried using love.graphics.setMode() instead of the TLfres file. With the setMode(), my game looks fine in windowed-mode. However, when going fullscreen to a resolution of 1920x1080 (my native resolution), a black bar appears on the right and my button's mousepress checks are off to the left of the actual button images. I try to follow what felix24 says here: viewtopic.php?t=8991&p=55448
As such in options.lua I try the following to change from windowed-mode to fullscreen:
Code: Select all
function go_fullscreen()
--sets the game into fullscreen
--love.graphics.toggleFullscreen()
love.graphics.setMode( 1920, 1080, true, false, 0)
scaleAmount = love.graphics.getHeight()/768
currentHeight = love.graphics.getHeight()
if scaleAmount > 1 then --scale up
int,fract = math.modf(scaleAmount)
movey = currentHeight * fract
elseif scaleAmount < 1 then --scale down
movey = currentHeight * (1-scaleAmount)
end
end
function go_windowed()
--sets the game into windowed mode
--love.graphics.toggleFullscreen()
love.graphics.setMode( 1280, 768, false, false, 0)
scaleAmount = love.graphics.getHeight()/768
currentHeight = love.graphics.getHeight()
if scaleAmount > 1 then --scale up
int,fract = math.modf(scaleAmount)
movey = currentHeight * fract
elseif scaleAmount < 1 then --scale down
movey = currentHeight * (1-scaleAmount)
end
end
Any help or guidance on the matter is greatly appreciated by me