Refactor lovr.graphics.getDimensions and friends;

This commit is contained in:
bjorn 2016-11-14 13:47:15 -08:00
parent 36bc1ad9a2
commit 21aba100a1
3 changed files with 16 additions and 13 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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;
}