## TLfres - resolution freedom

Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLfres - resolution freedom

Got some documentation up for it: TLfres
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

### Re: TLfres - resolution freedom

You done a nice work on this Taehl. It's like a very well polished evolved version of my basic function. Unfortunately I didn't found this when I needed.

BTW a feature I had to add to my version (that one I posted was a bit downgraded version) and you can also find interesting also add is include an option to add some extra margin offset pixel value to a fullscreen image.

Why we can need this? Because we could need later to do things like rotate that image. But rotating a full background image will "fail" showing "gaps". Yes, we could put a larger value than the window size but the problem is when we don't know the screen size or game have options to various resolutions. (I hope I made clear my idea/feature).

Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLfres - resolution freedom

Honestly, I have no idea what you're talking about. Sorry. Maybe you could post a code demo to show me what you mean?
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

### Re: TLfres - resolution freedom

Taehl wrote:Honestly, I have no idea what you're talking about. Sorry. Maybe you could post a code demo to show me what you mean?
resize.png

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: TLfres - resolution freedom

I think the minimum size (the height, in the usual case) should be the maximum size (the width, usually), times the square root of two.

Thus:

Code: Select all

local ratio = screenWidth / screenHeight
backgroundHeight = screenWidth * math.sqrt(2)
backgroundWidth = backgroundHeight * ratio

Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLfres - resolution freedom

... So you're asking me to make the scaling arbitrarily inaccurate in case someone makes their game badly? Seriously, this is something the game should be handling. TLfres ensures that whatever is coded looks equivalent in any resolution - including user errors.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

### Re: TLfres - resolution freedom

Robin wrote:I think the minimum size (the height, in the usual case) should be the maximum size (the width, usually), times the square root of two.
Nice math thinking Robin. Actually the auto option only came to my mind when I was having my time doing (wasting probably) the explanation image to Taehl so I haven't till now tried to find a formula to that. Also I suck on math.

BTW Robin, and if Taehl don't mind, and since I did little test is my "manual" offset math formula correct?

Code: Select all

function draw_extended_img (myImg,myMode,extraSpace,x,y,r,sx,sy,ox,oy)

local img_w = myImg:getWidth()
local img_h = myImg:getHeight()

if	myMode == "width" or myMode == "fullscreen" or
myMode == "w" or myMode == "fs"
then
x = x - extraSpace
img_sx = ( window.size_w + 2*extraSpace ) / img_w
else
img_sx = 1
end

if	myMode == "height" or myMode == "fullscreen" or
myMode == "h" or myMode == "fs"
then
y = y - extraSpace
img_sy = (window.size_h + 2*extraSpace ) / img_h
else
img_sy = 1
end

love.graphics.push()
love.graphics.scale(img_sx,img_sy)
love.graphics.draw(myImg,x,y,r,sx,sy,ox,oy)
love.graphics.pop()

end
Taehl wrote:... So you're asking me to make the scaling arbitrarily inaccurate in case someone makes their game badly? Seriously, this is something the game should be handling. TLfres ensures that whatever is coded looks equivalent in any resolution - including user errors.
I'm really not asking nothing Taehl. If you read correctly I simple suggested because I noticed when doing my library how handy was doing an option like this one. Also I'm not really "waiting" for your code, I had a solution that at least worked well for my project. I just was trying to be helpful demonstrating a situation that I faced that show me how that extending images to fullscreen like this didn't account post-rotation situations.

Story of my unwanted "request". After I was extending the header in my title screen with my function, I quickly notice that when applying rotation to any extended object would fail, so to get the result in the big screenshot I had to develop that option. Sorry I "asked" for something. It's your library, you do what you want of course. And I had mine already thank you.
intro2.png
intro1.png

pk
Citizen
Posts: 67
Joined: Wed Dec 14, 2011 2:13 am
Location: Texas, United States
Contact:

### Re: TLfres - resolution freedom

poop-screetshot.png (51.39 KiB) Viewed 2203 times

Code: Select all

-- Our imaginary game runs at 720p.
-- Display it at SVGA resolution with letterboxing.

require "TLfres"

image = love.graphics.newImage("poop.png")
TLfres.setScreen(nil, 1280)
end

function love.draw()
TLfres.transform()
love.graphics.draw(image, 0, 0)
color = {21,60,84}
TLfres.letterbox(16,9,color)
end

poop.love
I'm obviously not doing it right, but I can't figure out the cause.
ALL CREATURE WILL DIE AND ALL THE THINGS WILL BE BROKEN. THAT'S THE LAW OF SAMURAI.

nkorth
Prole
Posts: 15
Joined: Sun Sep 18, 2011 8:54 pm
Contact:

### Re: TLfres - resolution freedom

TLfres does not appear to work at all when the actual screen's aspect is wider than that of the virtual screen. Is it assuming that all games should be widescreen, or am I missing something?

(My game's virtual screen is 320x240; right now I'm just displaying it at 2x in a window but I'd like to allow res-independent fullscreen.)

tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

### Re: TLfres - resolution freedom

For some reason 1.04 doesn't work at all for me.

I get:

Code: Select all

Error: libs/TLfres.lua:36: attempt to perform arithmetic on global 'e' (a nil value)
stack traceback:
libs/TLfres.lua:36: in function 'letterbox'
main.lua:97: in function 'draw'
[string "boot.lua"]:410: in function <[string "boot.lua"]:373>
[C]: in function 'xpcall'
[Finished in 3.4s]

I use this at the end of my load:

Code: Select all

   TLfres.setScreen(nil, 1088, false, true)

and this in draw:

Code: Select all

    TLfres.transform()
TLfres.letterbox(16, 9)

EDIT: Also, when it works, some of the stuff I draw are going nowhere and all my click events (UI, character click movement, etc) aren't working anymore. Any idea with this?

Anyone has an idea? Thanks!

### Who is online

Users browsing this forum: No registered users and 6 guests