Improve lovr.graphics.clear;

This commit is contained in:
bjorn 2016-09-16 20:11:11 -07:00
parent 55f804de7a
commit 020a4207bb
3 changed files with 16 additions and 4 deletions

View File

@ -24,8 +24,18 @@ void lovrGraphicsInit() {
map_set(&BufferDrawModes, "fan", GL_TRIANGLE_FAN);
}
void lovrGraphicsClear() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
void lovrGraphicsClear(int color, int depth) {
int bits = 0;
if (color) {
bits |= GL_COLOR_BUFFER_BIT;
}
if (depth) {
bits |= GL_DEPTH_BUFFER_BIT;
}
glClear(bits);
}
void lovrGraphicsPresent() {

View File

@ -3,7 +3,7 @@
#include "shader.h"
void lovrGraphicsInit();
void lovrGraphicsClear();
void lovrGraphicsClear(int color, int depth);
void lovrGraphicsPresent();
void lovrGraphicsGetClearColor(float* r, float* g, float* b, float* a);
void lovrGraphicsSetClearColor(float r, float g, float b, float a);

View File

@ -28,7 +28,9 @@ int l_lovrGraphicsInit(lua_State* L) {
}
int l_lovrGraphicsClear(lua_State* L) {
lovrGraphicsClear();
int color = lua_gettop(L) < 1 || lua_toboolean(L, 1);
int depth = lua_gettop(L) < 2 || lua_toboolean(L, 2);
lovrGraphicsClear(color, depth);
return 0;
}