From 5deae0a103cc1d19734ebb3c98f5b1457e69cdd2 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 20 Jan 2019 20:06:40 -0800 Subject: [PATCH] Rename setWindow back to createWindow; I'm not sure why this was changed. It doesn't make very much sense because setWindow can't be called multiple times, and it can't be called with nil/NULL. --- src/api/graphics.c | 13 ++++--------- src/graphics/graphics.c | 14 +++++--------- src/graphics/graphics.h | 2 +- src/platform.h | 2 +- src/platform/android.c | 2 +- src/platform/glfw.h | 2 +- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/api/graphics.c b/src/api/graphics.c index f19262bf..45854793 100644 --- a/src/api/graphics.c +++ b/src/api/graphics.c @@ -283,12 +283,7 @@ static int l_lovrGraphicsPresent(lua_State* L) { return 0; } -static int l_lovrGraphicsSetWindow(lua_State* L) { - if (lua_isnoneornil(L, 1)) { - lovrGraphicsSetWindow(NULL); - return 0; - } - +static int l_lovrGraphicsCreateWindow(lua_State* L) { WindowFlags flags = { 0 }; luaL_checktype(L, 1, LUA_TTABLE); @@ -322,7 +317,7 @@ static int l_lovrGraphicsSetWindow(lua_State* L) { } lua_pop(L, 1); - lovrGraphicsSetWindow(&flags); + lovrGraphicsCreateWindow(&flags); luax_atexit(L, lovrGraphicsDestroy); // The lua_State that creates the window shall be the one to destroy it lovrRelease(textureData); return 0; @@ -1360,7 +1355,7 @@ static const luaL_Reg lovrGraphics[] = { // Base { "present", l_lovrGraphicsPresent }, - { "setWindow", l_lovrGraphicsSetWindow }, + { "createWindow", l_lovrGraphicsCreateWindow }, { "getWidth", l_lovrGraphicsGetWidth }, { "getHeight", l_lovrGraphicsGetHeight }, { "getDimensions", l_lovrGraphicsGetDimensions }, @@ -1469,7 +1464,7 @@ int luaopen_lovr_graphics(lua_State* L) { lovrGraphicsInit(gammaCorrect); - lua_pushcfunction(L, l_lovrGraphicsSetWindow); + lua_pushcfunction(L, l_lovrGraphicsCreateWindow); lua_getfield(L, -2, "window"); lua_call(L, 1, 0); diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index ff3e67cd..94faf742 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -187,19 +187,15 @@ void lovrGraphicsPresent() { lovrGpuPresent(); } -void lovrGraphicsSetWindow(WindowFlags* flags) { +void lovrGraphicsCreateWindow(WindowFlags* flags) { lovrAssert(!state.initialized, "Window is already created"); - - if (flags) { - flags->srgb = state.gammaCorrect; + flags->srgb = state.gammaCorrect; #ifdef EMSCRIPTEN - flags->vsync = 1; + flags->vsync = 1; #else - flags->vsync = 0; + flags->vsync = 0; #endif - } - - lovrAssert(lovrPlatformSetWindow(flags), "Could not create window"); + lovrAssert(lovrPlatformCreateWindow(flags), "Could not create window"); lovrPlatformOnWindowClose(onCloseWindow); lovrPlatformOnWindowResize(onResizeWindow); lovrPlatformGetFramebufferSize(&state.width, &state.height); diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index abb84037..7cc697b8 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -196,7 +196,7 @@ typedef struct { bool lovrGraphicsInit(bool gammaCorrect); void lovrGraphicsDestroy(); void lovrGraphicsPresent(); -void lovrGraphicsSetWindow(WindowFlags* flags); +void lovrGraphicsCreateWindow(WindowFlags* flags); int lovrGraphicsGetWidth(); int lovrGraphicsGetHeight(); void lovrGraphicsSetCamera(Camera* camera, bool clear); diff --git a/src/platform.h b/src/platform.h index 22617402..abd18599 100644 --- a/src/platform.h +++ b/src/platform.h @@ -74,7 +74,7 @@ void lovrPlatformDestroy(); void lovrPlatformPollEvents(); double lovrPlatformGetTime(); void lovrPlatformSetTime(double t); -bool lovrPlatformSetWindow(WindowFlags* flags); +bool lovrPlatformCreateWindow(WindowFlags* flags); void lovrPlatformGetWindowSize(int* width, int* height); void lovrPlatformGetFramebufferSize(int* width, int* height); void lovrPlatformSwapBuffers(); diff --git a/src/platform/android.c b/src/platform/android.c index 0e5c4cc0..b2acb030 100644 --- a/src/platform/android.c +++ b/src/platform/android.c @@ -24,7 +24,7 @@ void lovrPlatformSetTime(double t) { } */ -bool lovrPlatformSetWindow(WindowFlags* flags) { +bool lovrPlatformCreateWindow(WindowFlags* flags) { return true; } diff --git a/src/platform/glfw.h b/src/platform/glfw.h index 009691c8..d6763d1f 100644 --- a/src/platform/glfw.h +++ b/src/platform/glfw.h @@ -81,7 +81,7 @@ void lovrPlatformSetTime(double t) { glfwSetTime(t); } -bool lovrPlatformSetWindow(WindowFlags* flags) { +bool lovrPlatformCreateWindow(WindowFlags* flags) { if (state.window) { return true; }