mirror of https://github.com/bjornbytes/lovr.git
lovr.graphics.isInitialized;
Returns whether the graphics module is initialized. Used by the default error handler to know if it's safe to try to render the error screen.
This commit is contained in:
parent
5e2b44ad08
commit
36e1471cf0
|
@ -167,7 +167,9 @@ function lovr.errhand(message)
|
||||||
message = tostring(message) .. formatTraceback(debug.traceback('', 4))
|
message = tostring(message) .. formatTraceback(debug.traceback('', 4))
|
||||||
print('Error:\n' .. message)
|
print('Error:\n' .. message)
|
||||||
|
|
||||||
if not lovr.graphics then return function() return 1 end end
|
if not lovr.graphics or not lovr.graphics.isInitialized() then
|
||||||
|
return function() return 1 end
|
||||||
|
end
|
||||||
|
|
||||||
if lovr.audio then lovr.audio.stop() end
|
if lovr.audio then lovr.audio.stop() end
|
||||||
|
|
||||||
|
|
|
@ -682,6 +682,12 @@ static int l_lovrGraphicsInitialize(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_lovrGraphicsIsInitialized(lua_State* L) {
|
||||||
|
bool initialized = lovrGraphicsIsInitialized();
|
||||||
|
lua_pushboolean(L, initialized);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_lovrGraphicsSubmit(lua_State* L) {
|
static int l_lovrGraphicsSubmit(lua_State* L) {
|
||||||
bool table = lua_istable(L, 1);
|
bool table = lua_istable(L, 1);
|
||||||
int length = table ? luax_len(L, 1) : lua_gettop(L);
|
int length = table ? luax_len(L, 1) : lua_gettop(L);
|
||||||
|
@ -1492,6 +1498,7 @@ static int l_lovrGraphicsGetPass(lua_State* L) {
|
||||||
|
|
||||||
static const luaL_Reg lovrGraphics[] = {
|
static const luaL_Reg lovrGraphics[] = {
|
||||||
{ "initialize", l_lovrGraphicsInitialize },
|
{ "initialize", l_lovrGraphicsInitialize },
|
||||||
|
{ "isInitialized", l_lovrGraphicsIsInitialized },
|
||||||
{ "submit", l_lovrGraphicsSubmit },
|
{ "submit", l_lovrGraphicsSubmit },
|
||||||
{ "present", l_lovrGraphicsPresent },
|
{ "present", l_lovrGraphicsPresent },
|
||||||
{ "wait", l_lovrGraphicsWait },
|
{ "wait", l_lovrGraphicsWait },
|
||||||
|
|
|
@ -741,6 +741,10 @@ void lovrGraphicsDestroy() {
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lovrGraphicsIsInitialized() {
|
||||||
|
return state.initialized;
|
||||||
|
}
|
||||||
|
|
||||||
void lovrGraphicsGetDevice(GraphicsDevice* device) {
|
void lovrGraphicsGetDevice(GraphicsDevice* device) {
|
||||||
device->deviceId = state.device.deviceId;
|
device->deviceId = state.device.deviceId;
|
||||||
device->vendorId = state.device.vendorId;
|
device->vendorId = state.device.vendorId;
|
||||||
|
|
|
@ -96,6 +96,7 @@ enum {
|
||||||
|
|
||||||
bool lovrGraphicsInit(GraphicsConfig* config);
|
bool lovrGraphicsInit(GraphicsConfig* config);
|
||||||
void lovrGraphicsDestroy(void);
|
void lovrGraphicsDestroy(void);
|
||||||
|
bool lovrGraphicsIsInitialized(void);
|
||||||
|
|
||||||
void lovrGraphicsGetDevice(GraphicsDevice* device);
|
void lovrGraphicsGetDevice(GraphicsDevice* device);
|
||||||
void lovrGraphicsGetFeatures(GraphicsFeatures* features);
|
void lovrGraphicsGetFeatures(GraphicsFeatures* features);
|
||||||
|
|
Loading…
Reference in New Issue