From 21aba100a105668a11261c494b7975d7301d36b9 Mon Sep 17 00:00:00 2001 From: bjorn Date: Mon, 14 Nov 2016 13:47:15 -0800 Subject: [PATCH] Refactor lovr.graphics.getDimensions and friends; --- src/graphics/graphics.c | 12 ++++++++++-- src/graphics/graphics.h | 3 ++- src/lovr/graphics.c | 14 ++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 0095a6e2..5178958b 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -318,8 +318,16 @@ void lovrGraphicsMatrixTransform(mat4 transform) { mat4_multiply(vec_last(&state.transforms), transform); } -void lovrGraphicsGetDimensions(int* width, int* height) { - glfwGetFramebufferSize(window, width, height); +int lovrGraphicsGetWidth() { + int width; + glfwGetFramebufferSize(window, &width, NULL); + return width; +} + +int lovrGraphicsGetHeight() { + int height; + glfwGetFramebufferSize(window, NULL, &height); + return height; } void lovrGraphicsSetShapeData(float* data, int dataCount, unsigned int* indices, int indicesCount) { diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index 7952951e..b9d55e39 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -92,7 +92,8 @@ void lovrGraphicsRotate(float w, float x, float y, float z); void lovrGraphicsScale(float x, float y, float z); void lovrGraphicsTransform(float tx, float ty, float tz, float sx, float sy, float sz, float angle, float ax, float ay, float az); void lovrGraphicsMatrixTransform(mat4 transform); -void lovrGraphicsGetDimensions(int* width, int* height); +int lovrGraphicsGetWidth(); +int lovrGraphicsGetHeight(); void lovrGraphicsSetShapeData(float* data, int dataCount, unsigned int* indices, int indicesCount); void lovrGraphicsDrawLinedShape(GLenum mode); void lovrGraphicsDrawFilledShape(); diff --git a/src/lovr/graphics.c b/src/lovr/graphics.c index 55ca6b5a..021c1975 100644 --- a/src/lovr/graphics.c +++ b/src/lovr/graphics.c @@ -421,24 +421,18 @@ int l_lovrGraphicsCube(lua_State* L) { } int l_lovrGraphicsGetWidth(lua_State* L) { - int width; - lovrGraphicsGetDimensions(&width, NULL); - lua_pushnumber(L, width); + lua_pushnumber(L, lovrGraphicsGetWidth()); return 1; } int l_lovrGraphicsGetHeight(lua_State* L) { - int height; - lovrGraphicsGetDimensions(NULL, &height); - lua_pushnumber(L, height); + lua_pushnumber(L, lovrGraphicsGetHeight()); return 1; } int l_lovrGraphicsGetDimensions(lua_State* L) { - int width, height; - lovrGraphicsGetDimensions(&width, &height); - lua_pushnumber(L, width); - lua_pushnumber(L, height); + lua_pushnumber(L, lovrGraphicsGetWidth()); + lua_pushnumber(L, lovrGraphicsGetHeight()); return 2; }