mirror of https://github.com/bjornbytes/lovr.git
Simplify lovr.graphics.getWidth/Height;
This commit is contained in:
parent
b64489b020
commit
fe75c666a9
|
@ -345,18 +345,24 @@ int l_lovrGraphicsCreateWindow(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsGetWidth(lua_State* L) {
|
int l_lovrGraphicsGetWidth(lua_State* L) {
|
||||||
lua_pushnumber(L, lovrGraphicsGetWidth());
|
int width;
|
||||||
|
lovrGraphicsGetDimensions(&width, NULL);
|
||||||
|
lua_pushnumber(L, width);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsGetHeight(lua_State* L) {
|
int l_lovrGraphicsGetHeight(lua_State* L) {
|
||||||
lua_pushnumber(L, lovrGraphicsGetHeight());
|
int height;
|
||||||
|
lovrGraphicsGetDimensions(NULL, &height);
|
||||||
|
lua_pushnumber(L, height);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsGetDimensions(lua_State* L) {
|
int l_lovrGraphicsGetDimensions(lua_State* L) {
|
||||||
lua_pushnumber(L, lovrGraphicsGetWidth());
|
int width, height;
|
||||||
lua_pushnumber(L, lovrGraphicsGetHeight());
|
lovrGraphicsGetDimensions(&width, &height);
|
||||||
|
lua_pushnumber(L, width);
|
||||||
|
lua_pushnumber(L, height);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,12 @@ void lovrGraphicsDestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsReset() {
|
void lovrGraphicsReset() {
|
||||||
int w = lovrGraphicsGetWidth();
|
int width, height;
|
||||||
int h = lovrGraphicsGetHeight();
|
lovrGraphicsGetDimensions(&width, &height);
|
||||||
state.transform = 0;
|
state.transform = 0;
|
||||||
state.layer = 0;
|
state.layer = 0;
|
||||||
memcpy(state.layers[state.layer].viewport, (int[]) { 0, 0, w, h }, 4 * sizeof(uint32_t));
|
memcpy(state.layers[state.layer].viewport, (int[]) { 0, 0, width, height }, 4 * sizeof(uint32_t));
|
||||||
mat4_perspective(state.layers[state.layer].projection, .01f, 100.f, 67 * M_PI / 180., (float) w / h);
|
mat4_perspective(state.layers[state.layer].projection, .01f, 100.f, 67 * M_PI / 180., (float) width / height);
|
||||||
mat4_identity(state.layers[state.layer].view);
|
mat4_identity(state.layers[state.layer].view);
|
||||||
lovrGraphicsSetBackgroundColor((Color) { 0, 0, 0, 1. });
|
lovrGraphicsSetBackgroundColor((Color) { 0, 0, 0, 1. });
|
||||||
lovrGraphicsSetBlendMode(BLEND_ALPHA, BLEND_ALPHA_MULTIPLY);
|
lovrGraphicsSetBlendMode(BLEND_ALPHA, BLEND_ALPHA_MULTIPLY);
|
||||||
|
@ -140,16 +140,8 @@ void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const cha
|
||||||
state.initialized = true;
|
state.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lovrGraphicsGetWidth() {
|
void lovrGraphicsGetDimensions(int* width, int* height) {
|
||||||
int width, height;
|
glfwGetFramebufferSize(state.window, width, height);
|
||||||
glfwGetFramebufferSize(state.window, &width, &height);
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lovrGraphicsGetHeight() {
|
|
||||||
int width, height;
|
|
||||||
glfwGetFramebufferSize(state.window, &width, &height);
|
|
||||||
return height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuStats lovrGraphicsGetStats() {
|
GpuStats lovrGraphicsGetStats() {
|
||||||
|
|
|
@ -70,8 +70,7 @@ void lovrGraphicsReset();
|
||||||
void lovrGraphicsClear(Color* color, float* depth, int* stencil);
|
void lovrGraphicsClear(Color* color, float* depth, int* stencil);
|
||||||
void lovrGraphicsPresent();
|
void lovrGraphicsPresent();
|
||||||
void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const char* title, const char* icon);
|
void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const char* title, const char* icon);
|
||||||
int lovrGraphicsGetWidth();
|
void lovrGraphicsGetDimensions(int* width, int* height);
|
||||||
int lovrGraphicsGetHeight();
|
|
||||||
GpuStats lovrGraphicsGetStats();
|
GpuStats lovrGraphicsGetStats();
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
Loading…
Reference in New Issue