Word of warning I'm rather new at this.
So what I want to do is just create a simple menu that includes a way to change your windows resolution by presenting a list of them to choose from but I don't quite understand how to use "love.graphics.getModes" and whatever other methods I need incorporate to achieve this. I've looked what I believe is a good example that uses "love.graphics.getModes" but it involved using kikito's middleclass library, and I haven't quite learned how to use or understand how peoples libraries work (oop? not there yet). I'd like to figure it out this way, if that can be explained, but am also curious if there are alternative ways to do this.
I'm rather new to programming and lua so I just can't understand it on my own and need some loving help.
love.graphics.getModes
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Spec0pAssassin
- Prole
- Posts: 8
- Joined: Sun Jul 01, 2012 6:47 pm
- Location: My head, USA
love.graphics.getModes
-Spec0pAssassin
Wait. What?
Wait. What?
Re: love.graphics.getModes
You can use love.graphics.checkMode to do this.
Haven't tested this, but it should work.
Code: Select all
ratios = {800 / 600, 1440 / 900, 1960 / 1080}
supported = {fullscreen = {}}
for scale = 1, 6 do
for k, ratio in ipairs(ratios) do
local x = 320 * scale
local y = x * ratio
local key = tostring(x .. "x" .. y)
local res = {width = x, height = y}
if love.graphics.checkMode(x, y) then
supported[key] = res
end
if love.graphics.checkMode(x, y, true) then
supported.fullscreen[key] = res
end
end
end
--check for rogue resolution
local key = "1680x1050"
local res = {width = 1680, height = 1050}
if love.graphics.checkMode(1680, 1050) then
supported[key] = res
end
if love.graphics.checkMode(1680, 1050, true) then
supported.fullscreen[key] = res
end
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
- Spec0pAssassin
- Prole
- Posts: 8
- Joined: Sun Jul 01, 2012 6:47 pm
- Location: My head, USA
Re: love.graphics.getModes
If it's not to much trouble do you think you can comment that out for me?(like explain whats doing what) Some of what your code is doing is a little beyond me so implementing it into something testable will take sometime on my end. What's the difference between checkModes and getModes?
-Spec0pAssassin
Wait. What?
Wait. What?
Re: love.graphics.getModes
I linked to love.graphics.checkMode wiki page.
The script is pretty straightforward. It generates resolutions according to three popular aspect ratios and performs two test for each resolution: windowed and fullscreen. If supported, the resolution is added to a table. How the results are stored doesn't really matter, but I stored them here in the following fashion, using some simple tables:
Let our resolution be 800 x 600 -
supported["800x600"] = {width = 800, height = 600}
supported.fullscreen["800x600"] = {width = 800, height = 600}
This data format allows you to easily access the table to display the available options to the player and also to switch the resolution.
The script is pretty straightforward. It generates resolutions according to three popular aspect ratios and performs two test for each resolution: windowed and fullscreen. If supported, the resolution is added to a table. How the results are stored doesn't really matter, but I stored them here in the following fashion, using some simple tables:
Let our resolution be 800 x 600 -
supported["800x600"] = {width = 800, height = 600}
supported.fullscreen["800x600"] = {width = 800, height = 600}
This data format allows you to easily access the table to display the available options to the player and also to switch the resolution.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
- slime
- Solid Snayke
- Posts: 3160
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: love.graphics.getModes
How is that better than using love.graphics.getModes to get a list of all supported fullscreen resolutions? (all windowed mode width/height combinations will probably work as long as they aren't bigger than the desktop resolution).Lafolie wrote:I linked to love.graphics.checkMode wiki page.
The script is pretty straightforward. It generates resolutions according to three popular aspect ratios and performs two test for each resolution: windowed and fullscreen. If supported, the resolution is added to a table. How the results are stored doesn't really matter, but I stored them here in the following fashion, using some simple tables:
Let our resolution be 800 x 600 -
supported["800x600"] = {width = 800, height = 600}
supported.fullscreen["800x600"] = {width = 800, height = 600}
This data format allows you to easily access the table to display the available options to the player and also to switch the resolution.
- Spec0pAssassin
- Prole
- Posts: 8
- Joined: Sun Jul 01, 2012 6:47 pm
- Location: My head, USA
Re: love.graphics.getModes
So however I decide to create said table of resolutions, I assume printing them to the window would require converting the items within the table into strings? I feel like there's an alternative to that aswell, what would that be if there is one? Or am I thinking of doing that wrong?
Last edited by Spec0pAssassin on Thu Mar 21, 2013 9:32 am, edited 1 time in total.
-Spec0pAssassin
Wait. What?
Wait. What?
Re: love.graphics.getModes
I did not know that function existed! Please ignore everything I said, once again.slime wrote: How is that better than using love.graphics.getModes to get a list of all supported fullscreen resolutions? (all windowed mode width/height combinations will probably work as long as they aren't bigger than the desktop resolution).
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest