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.
This commit is contained in:
bjorn 2019-01-20 20:06:40 -08:00
parent 8f9d24c51f
commit 5deae0a103
6 changed files with 13 additions and 22 deletions

View File

@ -283,12 +283,7 @@ static int l_lovrGraphicsPresent(lua_State* L) {
return 0; return 0;
} }
static int l_lovrGraphicsSetWindow(lua_State* L) { static int l_lovrGraphicsCreateWindow(lua_State* L) {
if (lua_isnoneornil(L, 1)) {
lovrGraphicsSetWindow(NULL);
return 0;
}
WindowFlags flags = { 0 }; WindowFlags flags = { 0 };
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
@ -322,7 +317,7 @@ static int l_lovrGraphicsSetWindow(lua_State* L) {
} }
lua_pop(L, 1); 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 luax_atexit(L, lovrGraphicsDestroy); // The lua_State that creates the window shall be the one to destroy it
lovrRelease(textureData); lovrRelease(textureData);
return 0; return 0;
@ -1360,7 +1355,7 @@ static const luaL_Reg lovrGraphics[] = {
// Base // Base
{ "present", l_lovrGraphicsPresent }, { "present", l_lovrGraphicsPresent },
{ "setWindow", l_lovrGraphicsSetWindow }, { "createWindow", l_lovrGraphicsCreateWindow },
{ "getWidth", l_lovrGraphicsGetWidth }, { "getWidth", l_lovrGraphicsGetWidth },
{ "getHeight", l_lovrGraphicsGetHeight }, { "getHeight", l_lovrGraphicsGetHeight },
{ "getDimensions", l_lovrGraphicsGetDimensions }, { "getDimensions", l_lovrGraphicsGetDimensions },
@ -1469,7 +1464,7 @@ int luaopen_lovr_graphics(lua_State* L) {
lovrGraphicsInit(gammaCorrect); lovrGraphicsInit(gammaCorrect);
lua_pushcfunction(L, l_lovrGraphicsSetWindow); lua_pushcfunction(L, l_lovrGraphicsCreateWindow);
lua_getfield(L, -2, "window"); lua_getfield(L, -2, "window");
lua_call(L, 1, 0); lua_call(L, 1, 0);

View File

@ -187,19 +187,15 @@ void lovrGraphicsPresent() {
lovrGpuPresent(); lovrGpuPresent();
} }
void lovrGraphicsSetWindow(WindowFlags* flags) { void lovrGraphicsCreateWindow(WindowFlags* flags) {
lovrAssert(!state.initialized, "Window is already created"); lovrAssert(!state.initialized, "Window is already created");
flags->srgb = state.gammaCorrect;
if (flags) {
flags->srgb = state.gammaCorrect;
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
flags->vsync = 1; flags->vsync = 1;
#else #else
flags->vsync = 0; flags->vsync = 0;
#endif #endif
} lovrAssert(lovrPlatformCreateWindow(flags), "Could not create window");
lovrAssert(lovrPlatformSetWindow(flags), "Could not create window");
lovrPlatformOnWindowClose(onCloseWindow); lovrPlatformOnWindowClose(onCloseWindow);
lovrPlatformOnWindowResize(onResizeWindow); lovrPlatformOnWindowResize(onResizeWindow);
lovrPlatformGetFramebufferSize(&state.width, &state.height); lovrPlatformGetFramebufferSize(&state.width, &state.height);

View File

@ -196,7 +196,7 @@ typedef struct {
bool lovrGraphicsInit(bool gammaCorrect); bool lovrGraphicsInit(bool gammaCorrect);
void lovrGraphicsDestroy(); void lovrGraphicsDestroy();
void lovrGraphicsPresent(); void lovrGraphicsPresent();
void lovrGraphicsSetWindow(WindowFlags* flags); void lovrGraphicsCreateWindow(WindowFlags* flags);
int lovrGraphicsGetWidth(); int lovrGraphicsGetWidth();
int lovrGraphicsGetHeight(); int lovrGraphicsGetHeight();
void lovrGraphicsSetCamera(Camera* camera, bool clear); void lovrGraphicsSetCamera(Camera* camera, bool clear);

View File

@ -74,7 +74,7 @@ void lovrPlatformDestroy();
void lovrPlatformPollEvents(); void lovrPlatformPollEvents();
double lovrPlatformGetTime(); double lovrPlatformGetTime();
void lovrPlatformSetTime(double t); void lovrPlatformSetTime(double t);
bool lovrPlatformSetWindow(WindowFlags* flags); bool lovrPlatformCreateWindow(WindowFlags* flags);
void lovrPlatformGetWindowSize(int* width, int* height); void lovrPlatformGetWindowSize(int* width, int* height);
void lovrPlatformGetFramebufferSize(int* width, int* height); void lovrPlatformGetFramebufferSize(int* width, int* height);
void lovrPlatformSwapBuffers(); void lovrPlatformSwapBuffers();

View File

@ -24,7 +24,7 @@ void lovrPlatformSetTime(double t) {
} }
*/ */
bool lovrPlatformSetWindow(WindowFlags* flags) { bool lovrPlatformCreateWindow(WindowFlags* flags) {
return true; return true;
} }

View File

@ -81,7 +81,7 @@ void lovrPlatformSetTime(double t) {
glfwSetTime(t); glfwSetTime(t);
} }
bool lovrPlatformSetWindow(WindowFlags* flags) { bool lovrPlatformCreateWindow(WindowFlags* flags) {
if (state.window) { if (state.window) {
return true; return true;
} }