mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Merge branch 'love2d:12.0-development' into 12.0-development
This commit is contained in:
@@ -141,6 +141,21 @@ enum DoneAction
|
|||||||
DONE_RESTART,
|
DONE_RESTART,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void print_usage()
|
||||||
|
{
|
||||||
|
// when editing this message, change it at boot.lua too
|
||||||
|
printf("LÖVE is an *awesome* framework you can use to make 2D games in Lua\n"
|
||||||
|
"https://love2d.org\n"
|
||||||
|
"\n"
|
||||||
|
"usage:\n"
|
||||||
|
" love --version prints LÖVE version and quits\n"
|
||||||
|
" love --help prints this message and quits\n"
|
||||||
|
" love path/to/gamedir runs the game from the given directory which contains a main.lua file\n"
|
||||||
|
" love path/to/packagedgame.love runs the packaged game from the provided .love file\n"
|
||||||
|
" love path/to/file.lua runs the game from the given .lua file\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &restartvalue)
|
static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &restartvalue)
|
||||||
{
|
{
|
||||||
// Oh, you just want the version? Okay!
|
// Oh, you just want the version? Okay!
|
||||||
@@ -155,6 +170,13 @@ static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &res
|
|||||||
return DONE_QUIT;
|
return DONE_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc > 1 && strcmp(argv[1], "--help") == 0)
|
||||||
|
{
|
||||||
|
print_usage();
|
||||||
|
retval = 0;
|
||||||
|
return DONE_QUIT;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the virtual machine.
|
// Create the virtual machine.
|
||||||
lua_State *L = luaL_newstate();
|
lua_State *L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|||||||
@@ -305,10 +305,11 @@ File *luax_getfile(lua_State *L, int idx)
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileData *luax_getfiledata(lua_State *L, int idx, bool ioerror)
|
FileData *luax_getfiledata(lua_State *L, int idx, bool ioerror, int &nresults)
|
||||||
{
|
{
|
||||||
FileData *data = nullptr;
|
FileData *data = nullptr;
|
||||||
File *file = nullptr;
|
File *file = nullptr;
|
||||||
|
nresults = 0;
|
||||||
|
|
||||||
if (lua_isstring(L, idx) || luax_istype(L, idx, File::type))
|
if (lua_isstring(L, idx) || luax_istype(L, idx, File::type))
|
||||||
{
|
{
|
||||||
@@ -322,7 +323,7 @@ FileData *luax_getfiledata(lua_State *L, int idx, bool ioerror)
|
|||||||
|
|
||||||
if (!data && !file)
|
if (!data && !file)
|
||||||
{
|
{
|
||||||
luaL_argerror(L, idx, "filename, File, or FileData expected");
|
nresults = luaL_argerror(L, idx, "filename, File, or FileData expected");
|
||||||
return nullptr; // Never reached.
|
return nullptr; // Never reached.
|
||||||
}
|
}
|
||||||
else if (file && !data)
|
else if (file && !data)
|
||||||
@@ -335,10 +336,10 @@ FileData *luax_getfiledata(lua_State *L, int idx, bool ioerror)
|
|||||||
{
|
{
|
||||||
file->release();
|
file->release();
|
||||||
if (ioerror)
|
if (ioerror)
|
||||||
luax_ioError(L, "%s", e.what());
|
nresults = luax_ioError(L, "%s", e.what());
|
||||||
else
|
else
|
||||||
luaL_error(L, "%s", e.what());
|
nresults = luaL_error(L, "%s", e.what());
|
||||||
return nullptr; // Never reached.
|
return nullptr; // Never reached if ioerror is false.
|
||||||
}
|
}
|
||||||
|
|
||||||
file->release();
|
file->release();
|
||||||
@@ -349,7 +350,8 @@ FileData *luax_getfiledata(lua_State *L, int idx, bool ioerror)
|
|||||||
|
|
||||||
FileData *luax_getfiledata(lua_State *L, int idx)
|
FileData *luax_getfiledata(lua_State *L, int idx)
|
||||||
{
|
{
|
||||||
return luax_getfiledata(L, idx, false);
|
int nresults = 0;
|
||||||
|
return luax_getfiledata(L, idx, false, nresults);
|
||||||
}
|
}
|
||||||
|
|
||||||
Data *luax_getdata(lua_State *L, int idx)
|
Data *luax_getdata(lua_State *L, int idx)
|
||||||
@@ -404,7 +406,10 @@ int w_newFileData(lua_State *L)
|
|||||||
// Single argument: treat as filepath or File.
|
// Single argument: treat as filepath or File.
|
||||||
if (lua_gettop(L) == 1)
|
if (lua_gettop(L) == 1)
|
||||||
{
|
{
|
||||||
FileData *data = luax_getfiledata(L, 1, true);
|
int nresults = 0;
|
||||||
|
FileData *data = luax_getfiledata(L, 1, true, nresults);
|
||||||
|
if (data == nullptr)
|
||||||
|
return nresults;
|
||||||
luax_pushtype(L, data);
|
luax_pushtype(L, data);
|
||||||
data->release();
|
data->release();
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
#import <QuartzCore/CAMetalLayer.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
|
#ifdef LOVE_MACOS
|
||||||
|
// Needed for the GPU dynamic switching hack below.
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
namespace graphics
|
namespace graphics
|
||||||
@@ -291,6 +296,33 @@ Graphics::Graphics()
|
|||||||
throw love::Exception("LOVE's Metal graphics backend requires macOS 10.15+ or iOS 13+.");
|
throw love::Exception("LOVE's Metal graphics backend requires macOS 10.15+ or iOS 13+.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_MACOS
|
||||||
|
// On multi-GPU macOS systems with a low and high power GPU (e.g. a 2016
|
||||||
|
// Macbook Pro), the OS doesn't activate the high power GPU for final
|
||||||
|
// monitor blitting even when MTLCreateSystemDefaultDevice is called, on
|
||||||
|
// newer macOS versions. https://developer.apple.com/forums/thread/675411
|
||||||
|
// But it does when an OpenGL context is created, so this big hack forces it
|
||||||
|
// when we want it to happen.
|
||||||
|
if (!device.isLowPower && MTLCopyAllDevices().count > 1)
|
||||||
|
{
|
||||||
|
NSOpenGLPixelFormatAttribute attributes[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||||
|
NSOpenGLPFAColorSize, 24,
|
||||||
|
NSOpenGLPFAAlphaSize, 8,
|
||||||
|
NSOpenGLPFADepthSize, 24,
|
||||||
|
NSOpenGLPFAStencilSize, 8,
|
||||||
|
NSOpenGLPFASampleBuffers, 0,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||||
|
auto glcontext = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:nullptr];
|
||||||
|
LOVE_UNUSED(glcontext);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
commandQueue = [device newCommandQueue];
|
commandQueue = [device newCommandQueue];
|
||||||
passDesc = [MTLRenderPassDescriptor new];
|
passDesc = [MTLRenderPassDescriptor new];
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,17 @@ function love.boot()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not can_has_game then
|
if not can_has_game then
|
||||||
|
-- when editing this message, change it at love.cpp too
|
||||||
|
print([[LÖVE is an *awesome* framework you can use to make 2D games in Lua
|
||||||
|
https://love2d.org
|
||||||
|
|
||||||
|
usage:
|
||||||
|
love --version prints LÖVE version and quits
|
||||||
|
love --help prints this message and quits
|
||||||
|
love path/to/gamedir runs the game from the given directory which contains a main.lua file
|
||||||
|
love path/to/packagedgame.love runs the packaged game from the provided .love file
|
||||||
|
love path/to/file.lua runs the game from the given .lua file
|
||||||
|
]]);
|
||||||
local nogame = require("love.nogame")
|
local nogame = require("love.nogame")
|
||||||
nogame()
|
nogame()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user