Page 1 of 1

0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 8:35 am
by vortizee
What am I missing?
main.lua:26 is

Code: Select all

require ‘lua/loader’
which is at the top of main.lua, and line 220 of loader.lua simply loads an image:

Code: Select all

local LGNI	= love.graphics.newImage
.
.
.
controls	= LGNI( 'resources/images/controls.png' )
Runs peachy in Löve 0.9.2 on OS X Mavericks but fails on OS X High Sierra as an executable app. Dropping the game folder over Löve 11.2 spits the error below unlike over 0.9.2.
Error

lua/loader.lua:220: love.graphics cannot function without a window!

Traceback
[C]: in function 'LGNI'
lua/loader.lua:220: in main chunk
[C]: in function 'require'
main.lua:26: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function ‘xpcall’
I have just started the port to 11.2 — color definitions, stencil, and mouse changes yet to be done. conf.lua is

Code: Select all

function love.conf(t)

  t.identity				= "ATCH"
  t.window.title			= "ATCH"
  t.window.width			= 1280
  t.window.height			= 800
  t.modules.joystick			= false
  t.modules.physics			= false
  t.window.highdpi			= true
  t.window				= nil
  t.modules.thread			= false
  
end

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 9:46 am
by zorg
A quick look at Config_Files will tell you that you're missing at least two things; t.modules.window = true and t.modules.graphics = true.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 12:23 pm
by vortizee
Thank you, same error though. I’m trying to find out what other things might bite like this from the changelogs.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 1:14 pm
by zorg
In that case, it might be that because of some inexplicable design decision on löve's part, you can no longer use love.graphics functions without creating an actual graphical window (even if some functions did work without it previously); i'm not sure on this one, though i do remember something like this faintly.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 2:44 pm
by slime
It never worked to use love.graphics without a window, since the window has always created an OpenGL context (partly since an SDL OpenGL context requires a window to be created in the first place - because on various platforms an OpenGL context and a renderable backbuffer are tied together, and the latter requires a window).

Before love 0.10 or so, it would just randomly crash or corrupt your memory in that case. Now it causes a Lua error instead (when some functions are called, at least.)

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 2:45 pm
by pgimeno
From 0.10.1 release notes:

"Fixed love.graphics object creation functions (e.g. love.graphics.newImage) to error instead of crash, if called before a window has been created."

Indeed in 0.10.0 it crashes. According to what slime has said above, I wonder why in 0.9.1 and 0.9.2 I get no crash. In 0.9.0 I get one.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 4:24 pm
by vortizee
I’m very rusty at the löve functions, and I worked everything out by trial and error. A window always launched at the start in 0.9.2, and I considered a config file the first time after noticing it started at some default dimension ( 800 x 600? ) before I could resize it with love.window.setMode. If in 11.2 the window is not automatically created, who does so and how? I can see a love.window.close at the top of the list, but not a love.window.open or anything intuitively similar.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sat Jan 12, 2019 4:34 pm
by slime
The window is automatically created by default in love 11. Your love.conf has the line "t.window = nil" in it, which stops that from happening. If you remove that line it should be automatically created.

You can also call love.window.setMode to (re)create the window in main.lua (before calling any love.graphics function).

There are also various t.window fields documented in the love.conf wiki page to set the size of the window, etc. when it's created the first time after love.conf is loaded, so you don't need to call setMode to set the initial size.

Re: 0.9.2 to 11.2 love.graphics cannot function without a window

Posted: Sun Jan 13, 2019 2:19 am
by vortizee
There you go, I guess I put that in 0.9.2 to stop the visible resize and forgot all about it. Okay, I’m in the update business, thanks!