Fullscreen bug

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.
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Fullscreen bug

Post by megalukes »

Hi there. I'm developing a small arcade game that uses the 512x448 resolution. In window mode it runs normally, but when I turn on the fullscreen mode, the window size changes to 640x480, messing up with positions and center alignment.

Window mode:
Image

Fullscreen mode:
Image

I found out this happens both on Windows and on Mac OSX. Is this supposed to happen? Thank you in advance!
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Fullscreen bug

Post by kikito »

A lot of monitors (and/or graphic cards, I am not sure where's the culprint) can't swich to a "random" screen resolution in fullscreen; instead, they have a "list of valid combinations of width & height".

In LÖVE, you can get that list by using [wiki]love.window.getFullscreenModes[/wiki].

In your case, what seems to happen is that LÖVE is giving you either the closest mode matching what you requested, or just the smallest mode.

If you want to stick to the 512x448 resolution, you will have to go around this when in full screen. You can either add "black borders" around your game, or draw to a canvas and "stretch it" on the screen.
When I write def I mean function.
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: Fullscreen bug

Post by megalukes »

Ah, I see. I will try to draw some black borders and center the screen to make up the difference then. Thank you so much for the help.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Fullscreen bug

Post by Jasoco »

It's definitely more preferred these days to not change the resolution if you can. Especially to low ones from the early days of computing.

I recommend the Canvas method, or a simple use of push, scale and pop if you can, and then use "Desktop" fullscreen mode. Code the game to just scale to whatever size the window is using simple math (scale factor = window dimension / game resolution dimension) so we can control the window size ourselves with the Maximize, Zoom or Lion Fullscreen buttons in the titlebar or the window edges. It also lets us change to other applications when we can. Something streamers complain about with a lot of "impolite" games because a few won't let you change to a browser when needed and it makes streaming more difficult, sometimes requiring them to play windowed.

It requires literally little to no effort on your part if done right. And is highly recommended especially if you're making a game that uses pixel art graphics.

Something to note is if you use the method above, (And make sure to set all image filters to "nearest" for goodness sakes) you'll get crisp clean large pixels on your screen, whereas if you actually try to set the monitor resolution, you're gonna end up with blurriness due to the display blending the low resolution to fill up the large screen area.

I'd even go so far as to refuse to play a game if I can't set its resolution to my display's resolution. I don't want no blurry pixels or inability to change windows when needed.

If you want advice, I can try and answer and provide samples.
G-Mang
Prole
Posts: 9
Joined: Sun Jun 01, 2014 12:21 am

Re: Fullscreen bug

Post by G-Mang »

Jasoco wrote:It's definitely more preferred these days to not change the resolution if you can. Especially to low ones from the early days of computing.

...

If you want advice, I can try and answer and provide samples.
As a noobie, I definitely want to learn more about this. :0 Any good samples or tutorials to learn from?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Fullscreen bug

Post by Jasoco »

Okay. First a question. How are you drawing your game right now?

It might be as simple as using the love.push/scale/pop() commands. But some information will be handy. Do you have a sample .love maybe?

Are you using graphics that are already doubled up? Is 512x448 the resolution you are currently drawing at?

For a start, try this:

Set the window's "resizable" flag to true. Either by putting it in the conf.lua file or when you setMode. If you don't call setMode at launch, put these flags in your conf.lua file:

Code: Select all

t.window.resizable = true
t.window.fullscreentype = "desktop"
What this will do is A) set the window to be freely resizable and B) I believe the "desktop" mode enables the Lion Fullscreen button in the top right corner to let a Löve game on OS X go into Fullscreen on its own space.

Place this code in your love.draw() function before the drawing stuff:

Code: Select all

local s = love.window.getHeight() / 448 --Where 448 is the height you are drawing your game content at; Change this if/when needed
love.push()
love.scale(s)
And this at the end of the draw function:

Code: Select all

love.pop()
And report what you get. If done correctly, you should A) be able to resize the window freely or maximize it and B) the drawing stuff should scale with the window height. (It won't be centered yet though. This is just a starting point.)

Maybe take a screenshot of your window maximized.

If you're willing to use the Canvas method mentioned above, there is a different approach we can use.
G-Mang
Prole
Posts: 9
Joined: Sun Jun 01, 2014 12:21 am

Re: Fullscreen bug

Post by G-Mang »

I dunno about OP, but none of those love.functions (push, scale, pop) seem to do anything for me. Get errors like this:

Code: Select all

Error: main.lua:32: attempt to call field 'push' (a nil value)
stack traceback:
	main.lua:32: in function 'draw'
	[string "boot.lua"]:438: in function <[string "boot.lua"]:399>
	[C]: in function 'xpcall'
It's worth noting that I've never used any of those and don't know what they do. :P
Attachments
TempGame01.love
(9.13 KiB) Downloaded 191 times
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Fullscreen bug

Post by Jasoco »

I'm an idiot. It's love.graphics.push/scale/pop. Change those and it should work.
G-Mang
Prole
Posts: 9
Joined: Sun Jun 01, 2014 12:21 am

Re: Fullscreen bug

Post by G-Mang »

Oh ya much better. :rofl: TY!
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Fullscreen bug

Post by T-Bone »

If you're interested in the canvas method, it would look something like this (untested)

Code: Select all

function love.load()
	awesomecanvas = love.graphics.newCanvas(512, 448)
	awesomecanvas:setFilter("nearest", "nearest")
        -- and the rest of your love.load of course
end

function love.draw2() -- this is your current love.draw function, you just have to rename it to something else
	...
end

function love.draw()
	awesomecanvas:renderTo(love.draw2)
	local w = love.window.getWidth()
	local h = love.window.getHeight()
	local s = math.floor(h/448)
	love.graphics.draw(awesomecanvas, w*0.5 - s*512, h*0.5 - s*448, 0, s, s)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests