Add lovr.graphics.setProjection;

It's not very good.  It only takes Transforms and sets the projection
for both eyes.  And the projection gets reset at the beginning and
end of lovr.headset.renderTo.  It's meant to be a backdoor.
This commit is contained in:
bjorn 2018-10-26 17:17:18 -07:00
parent f6d5bf325a
commit 654b894ded
3 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "data/textureData.h"
#include "data/vertexData.h"
#include "filesystem/filesystem.h"
#include "math/transform.h"
#include "util.h"
#define _USE_MATH_DEFINES
#include <math.h>
@ -584,6 +585,12 @@ static int l_lovrGraphicsTransform(lua_State* L) {
return 0;
}
static int l_lovrGraphicsSetProjection(lua_State* L) {
Transform* transform = luax_checktype(L, 1, Transform);
lovrGraphicsSetProjection(transform->matrix);
return 0;
}
// Rendering
static int l_lovrGraphicsClear(lua_State* L) {
@ -1302,6 +1309,7 @@ static const luaL_Reg lovrGraphics[] = {
{ "rotate", l_lovrGraphicsRotate },
{ "scale", l_lovrGraphicsScale },
{ "transform", l_lovrGraphicsTransform },
{ "setProjection", l_lovrGraphicsSetProjection },
// Rendering
{ "clear", l_lovrGraphicsClear },

View File

@ -361,6 +361,11 @@ void lovrGraphicsMatrixTransform(mat4 transform) {
mat4_multiply(state.transforms[state.transform], transform);
}
void lovrGraphicsSetProjection(mat4 projection) {
mat4_set(state.camera.projection[0], projection);
mat4_set(state.camera.projection[1], projection);
}
// Rendering
VertexPointer lovrGraphicsGetVertexPointer(uint32_t count) {

View File

@ -206,6 +206,7 @@ void lovrGraphicsTranslate(float x, float y, float z);
void lovrGraphicsRotate(float angle, float ax, float ay, float az);
void lovrGraphicsScale(float x, float y, float z);
void lovrGraphicsMatrixTransform(mat4 transform);
void lovrGraphicsSetProjection(mat4 projection);
// Rendering
VertexPointer lovrGraphicsGetVertexPointer(uint32_t capacity);