0.9.2 to 11.2 love.graphics cannot function without a window

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.
Post Reply
User avatar
vortizee
Prole
Posts: 34
Joined: Sat Feb 14, 2015 6:23 am

0.9.2 to 11.2 love.graphics cannot function without a window

Post 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
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
vortizee
Prole
Posts: 34
Joined: Sat Feb 14, 2015 6:23 am

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

Post by vortizee »

Thank you, same error though. I’m trying to find out what other things might bite like this from the changelogs.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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.)
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

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

Post 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.
User avatar
vortizee
Prole
Posts: 34
Joined: Sat Feb 14, 2015 6:23 am

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

Post 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.
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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.
User avatar
vortizee
Prole
Posts: 34
Joined: Sat Feb 14, 2015 6:23 am

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

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests