Merge branch 'master' into dev

This commit is contained in:
bjorn 2021-12-20 17:12:39 +02:00
commit 20e4567bd6
13 changed files with 247 additions and 98 deletions

View File

@ -729,7 +729,7 @@ elseif(ANDROID)
# - Imported targets need to have their libraries manually copied to raw/lib/<ABI>
# - Figure out which Java class (Activity) and AndroidManifest.xml to use
# - Oculus uses the regular android os layer, pico implements its own in the headset backend
# - Some of the Pico SDK is in a jar that has to be added to the classpath and dx invocation
# - Some of the Pico SDK is in a jar that has to be added to the classpath and d8 invocation
# TODO error (probably way earlier) if no headset API is defined, since everything will break
if(LOVR_USE_OPENXR)
set(MANIFEST "oculus")
@ -781,7 +781,7 @@ elseif(ANDROID)
COMMAND ${CMAKE_COMMAND} -E copy "${ANDROID_MANIFEST}" AndroidManifest.xml
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Activity_${ACTIVITY}.java Activity.java
COMMAND ${Java_JAVAC_EXECUTABLE} -classpath "${ANDROID_CLASSPATH}" -d . Activity.java
COMMAND ${ANDROID_TOOLS}/dx --dex --output raw/classes.dex ${EXTRA_JAR} org/lovr/app/Activity.class
COMMAND ${ANDROID_TOOLS}/d8 --min-api ${ANDROID_NATIVE_API_LEVEL} --output raw ${EXTRA_JAR} org/lovr/app/Activity.class
COMMAND
${ANDROID_TOOLS}/aapt
package -f

View File

@ -54,6 +54,20 @@ static int l_lovrRasterizerHasGlyphs(lua_State* L) {
return 1;
}
static int l_lovrRasterizerGetWidth(lua_State* L) {
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
size_t length;
const char* string = luaL_checklstring(L, 2, &length);
float wrap = luax_optfloat(L, 4, 0.f);
float width, lastLineWidth, height;
uint32_t lineCount, glyphCount;
lovrRasterizerMeasure(rasterizer, string, length, wrap, &width, &lastLineWidth, &height, &lineCount, &glyphCount);
lua_pushnumber(L, width);
lua_pushnumber(L, lineCount + 1);
lua_pushnumber(L, lastLineWidth);
return 2;
}
const luaL_Reg lovrRasterizer[] = {
{ "getHeight", l_lovrRasterizerGetHeight },
{ "getAdvance", l_lovrRasterizerGetAdvance },
@ -62,5 +76,6 @@ const luaL_Reg lovrRasterizer[] = {
{ "getLineHeight", l_lovrRasterizerGetLineHeight },
{ "getGlyphCount", l_lovrRasterizerGetGlyphCount },
{ "hasGlyphs", l_lovrRasterizerHasGlyphs },
{ "getWidth", l_lovrRasterizerGetWidth },
{ NULL, NULL }
};

View File

@ -292,6 +292,7 @@ static int l_lovrMeshSetVertices(lua_State* L) {
uint32_t capacity = lovrMeshGetVertexCount(mesh);
uint32_t start = luaL_optinteger(L, 3, 1) - 1;
lovrAssert(start < capacity, "Starting vertex index must be in range [1, %d]", capacity);
uint32_t count = luaL_optinteger(L, 4, capacity - start);
size_t stride = firstAttribute->stride;

View File

@ -170,7 +170,7 @@ static int l_lovrVec2Add(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] += x;
v[1] += x;
v[1] += luax_optfloat(L, 3, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC2, "vec2 or number");
v[0] += u[0];
@ -185,7 +185,7 @@ static int l_lovrVec2Sub(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] -= x;
v[1] -= x;
v[1] -= luax_optfloat(L, 3, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC2, "vec2 or number");
v[0] -= u[0];
@ -200,7 +200,7 @@ static int l_lovrVec2Mul(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] *= x;
v[1] *= x;
v[1] *= luax_optfloat(L, 3, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC2, "vec2 or number");
v[0] *= u[0];
@ -215,7 +215,7 @@ static int l_lovrVec2Div(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] /= x;
v[1] /= x;
v[1] /= luax_optfloat(L, 3, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC2, "vec2 or number");
v[0] /= u[0];
@ -245,7 +245,15 @@ static int l_lovrVec2Normalize(lua_State* L) {
static int l_lovrVec2Distance(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC2, NULL);
float* u = luax_checkvector(L, 2, V_VEC2, NULL);
float* u;
float uvec[2];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC2, NULL);
}
float dx = v[0] - u[0];
float dy = v[1] - u[1];
lua_pushnumber(L, sqrtf(dx * dx + dy * dy));
@ -254,15 +262,33 @@ static int l_lovrVec2Distance(lua_State* L) {
static int l_lovrVec2Dot(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC2, NULL);
float* u = luax_checkvector(L, 2, V_VEC2, NULL);
float* u;
float uvec[2];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC2, NULL);
}
lua_pushnumber(L, v[0] * u[0] + v[1] * u[1]);
return 1;
}
static int l_lovrVec2Lerp(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC2, NULL);
float* u = luax_checkvector(L, 2, V_VEC2, NULL);
float t = luax_checkfloat(L, 3);
float* u;
float uvec[2];
float t;
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
u = uvec;
t = luax_checkfloat(L, 4);
} else {
u = luax_checkvector(L, 2, V_VEC2, NULL);
t = luax_checkfloat(L, 3);
}
v[0] = v[0] + (u[0] - v[0]) * t;
v[1] = v[1] + (u[1] - v[1]) * t;
lua_settop(L, 1);
@ -516,7 +542,10 @@ static int l_lovrVec3Add(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] += x, v[1] += x, v[2] += x, v[3] += x;
v[0] += x;
v[1] += luax_optfloat(L, 3, x);
v[2] += luax_optfloat(L, 4, x);
v[3] += 0.f;
} else {
vec3 u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
vec3_add(v, u);
@ -529,7 +558,10 @@ static int l_lovrVec3Sub(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] -= x, v[1] -= x, v[2] -= x, v[3] -= x;
v[0] -= x;
v[1] -= luax_optfloat(L, 3, x);
v[2] -= luax_optfloat(L, 4, x);
v[3] -= 0.f;
} else {
vec3 u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
vec3_sub(v, u);
@ -541,10 +573,15 @@ static int l_lovrVec3Sub(lua_State* L) {
static int l_lovrVec3Mul(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
if (lua_type(L, 2) == LUA_TNUMBER) {
vec3_scale(v, lua_tonumber(L, 2));
float x = lua_tonumber(L, 2);
v[0] *= x;
v[1] *= luax_optfloat(L, 3, x);
v[2] *= luax_optfloat(L, 4, x);
} else {
vec3 u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
v[0] = v[0] * u[0], v[1] = v[1] * u[1], v[2] = v[2] * u[2];
v[0] *= u[0];
v[1] *= u[1];
v[2] *= u[2];
}
lua_settop(L, 1);
return 1;
@ -553,10 +590,15 @@ static int l_lovrVec3Mul(lua_State* L) {
static int l_lovrVec3Div(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
if (lua_type(L, 2) == LUA_TNUMBER) {
vec3_scale(v, 1.f / (float) lua_tonumber(L, 2));
float x = lua_tonumber(L, 2);
v[0] /= x;
v[1] /= luax_optfloat(L, 3, x);
v[2] /= luax_optfloat(L, 4, x);
} else {
vec3 u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
v[0] = v[0] / u[0], v[1] = v[1] / u[1], v[2] = v[2] / u[2];
v[0] /= u[0];
v[1] /= u[1];
v[2] /= u[2];
}
lua_settop(L, 1);
return 1;
@ -577,21 +619,48 @@ static int l_lovrVec3Normalize(lua_State* L) {
static int l_lovrVec3Distance(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
vec3 u = luax_checkvector(L, 2, V_VEC3, NULL);
vec3 u;
float uvec[4];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
}
lua_pushnumber(L, vec3_distance(v, u));
return 1;
}
static int l_lovrVec3Dot(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
vec3 u = luax_checkvector(L, 2, V_VEC3, NULL);
vec3 u;
float uvec[4];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
}
lua_pushnumber(L, vec3_dot(v, u));
return 1;
}
static int l_lovrVec3Cross(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
vec3 u = luax_checkvector(L, 2, V_VEC3, NULL);
vec3 u;
float uvec[4];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
}
vec3_cross(v, u);
lua_settop(L, 1);
return 1;
@ -599,8 +668,19 @@ static int l_lovrVec3Cross(lua_State* L) {
static int l_lovrVec3Lerp(lua_State* L) {
vec3 v = luax_checkvector(L, 1, V_VEC3, NULL);
vec3 u = luax_checkvector(L, 2, V_VEC3, NULL);
float t = luax_checkfloat(L, 3);
vec3 u;
float uvec[4];
float t;
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
u = uvec;
t = luax_checkfloat(L, 5);
} else {
u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
t = luax_checkfloat(L, 3);
}
vec3_lerp(v, u, t);
lua_settop(L, 1);
return 1;
@ -856,9 +936,9 @@ static int l_lovrVec4Add(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] += x;
v[1] += x;
v[2] += x;
v[3] += x;
v[1] += luax_optfloat(L, 3, x);
v[2] += luax_optfloat(L, 4, x);
v[3] += luax_optfloat(L, 5, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC4, "vec4 or number");
v[0] += u[0];
@ -875,9 +955,9 @@ static int l_lovrVec4Sub(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] -= x;
v[1] -= x;
v[2] -= x;
v[3] -= x;
v[1] -= luax_optfloat(L, 3, x);
v[2] -= luax_optfloat(L, 4, x);
v[3] -= luax_optfloat(L, 5, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC4, "vec4 or number");
v[0] -= u[0];
@ -894,9 +974,9 @@ static int l_lovrVec4Mul(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] *= x;
v[1] *= x;
v[2] *= x;
v[3] *= x;
v[1] *= luax_optfloat(L, 3, x);
v[2] *= luax_optfloat(L, 4, x);
v[3] *= luax_optfloat(L, 5, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC4, "vec4 or number");
v[0] *= u[0];
@ -913,9 +993,9 @@ static int l_lovrVec4Div(lua_State* L) {
if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
v[0] /= x;
v[1] /= x;
v[2] /= x;
v[3] /= x;
v[1] /= luax_optfloat(L, 3, x);
v[2] /= luax_optfloat(L, 4, x);
v[3] /= luax_optfloat(L, 5, x);
} else {
float* u = luax_checkvector(L, 2, V_VEC4, "vec4 or number");
v[0] /= u[0];
@ -949,7 +1029,17 @@ static int l_lovrVec4Normalize(lua_State* L) {
static int l_lovrVec4Distance(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC4, NULL);
float* u = luax_checkvector(L, 2, V_VEC4, NULL);
float* u;
float uvec[4];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);;
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
uvec[3] = luax_checkfloat(L, 5);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC4, NULL);
}
float dx = v[0] - u[0];
float dy = v[1] - u[1];
float dz = v[2] - u[2];
@ -960,15 +1050,37 @@ static int l_lovrVec4Distance(lua_State* L) {
static int l_lovrVec4Dot(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC4, NULL);
float* u = luax_checkvector(L, 2, V_VEC4, NULL);
float* u;
float uvec[4];
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
uvec[3] = luax_checkfloat(L, 5);
u = uvec;
} else {
u = luax_checkvector(L, 2, V_VEC4, NULL);
}
lua_pushnumber(L, v[0] * u[0] + v[1] * u[1] + v[2] * u[2] + v[3] * u[3]);
return 1;
}
static int l_lovrVec4Lerp(lua_State* L) {
float* v = luax_checkvector(L, 1, V_VEC4, NULL);
float* u = luax_checkvector(L, 2, V_VEC4, NULL);
float t = luax_checkfloat(L, 3);
float* u;
float uvec[4];
float t;
if (lua_type(L, 2) == LUA_TNUMBER) {
uvec[0] = lua_tonumber(L, 2);
uvec[1] = luax_checkfloat(L, 3);
uvec[2] = luax_checkfloat(L, 4);
uvec[3] = luax_checkfloat(L, 5);
u = uvec;
t = luax_checkfloat(L, 6);
} else {
u = luax_checkvector(L, 2, V_VEC4, NULL);
t = luax_checkfloat(L, 3);
}
v[0] = v[0] + (u[0] - v[0]) * t;
v[1] = v[1] + (u[1] - v[1]) * t;
v[2] = v[2] + (u[2] - v[2]) * t;

View File

@ -184,3 +184,56 @@ void lovrRasterizerLoadGlyph(Rasterizer* rasterizer, uint32_t character, uint32_
int32_t lovrRasterizerGetKerning(Rasterizer* rasterizer, uint32_t left, uint32_t right) {
return stbtt_GetCodepointKernAdvance(&rasterizer->font, left, right) * rasterizer->scale;
}
void lovrRasterizerMeasure(Rasterizer* rasterizer, const char* str, size_t length, float wrap, float* width, float* lastLineWidth, float* height, uint32_t* lineCount, uint32_t* glyphCount) {
float x = 0.f;
const char* end = str + length;
size_t bytes;
unsigned int previous = '\0';
unsigned int codepoint;
*width = 0.f;
*lastLineWidth = 0.f;
*lineCount = 0;
*glyphCount = 0;
while ((bytes = utf8_decode(str, end, &codepoint)) > 0) {
if (codepoint == '\n' || (wrap && x > wrap && codepoint == ' ')) {
*width = MAX(*width, x);
(*lineCount)++;
x = 0.f;
previous = '\0';
str += bytes;
continue;
}
// Tabs
if (codepoint == '\t') {
int glyphIndex = stbtt_FindGlyphIndex(&rasterizer->font, ' ');
int advance, bearing;
stbtt_GetGlyphHMetrics(&rasterizer->font, glyphIndex, &advance, &bearing);
x += advance * 4.f;
str += bytes;
continue;
}
int glyphIndex = stbtt_FindGlyphIndex(&rasterizer->font, codepoint);
int advance, bearing;
stbtt_GetGlyphHMetrics(&rasterizer->font, glyphIndex, &advance, &bearing);
int x0, y0, x1, y1;
if (stbtt_GetGlyphBox(&rasterizer->font, glyphIndex, &x0, &y0, &x1, &y1)) {
float w = ceilf((x1 - x0) * rasterizer->scale);
float h = ceilf((y1 - y0) * rasterizer->scale);
if (w > 0 && h > 0) {
(*glyphCount)++;
}
}
x += roundf(advance * rasterizer->scale) + lovrRasterizerGetKerning(rasterizer, previous, codepoint);
previous = codepoint;
str += bytes;
}
*width = MAX(*width, x);
*lastLineWidth = x;
*height = ((*lineCount + 1) * lovrRasterizerGetHeight(rasterizer));
}

View File

@ -1,5 +1,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#pragma once
@ -32,3 +33,4 @@ bool lovrRasterizerHasGlyph(Rasterizer* fontData, uint32_t character);
bool lovrRasterizerHasGlyphs(Rasterizer* fontData, const char* str);
void lovrRasterizerLoadGlyph(Rasterizer* fontData, uint32_t character, uint32_t padding, double spread, Glyph* glyph);
int32_t lovrRasterizerGetKerning(Rasterizer* fontData, uint32_t left, uint32_t right);
void lovrRasterizerMeasure(Rasterizer* rasterizer, const char* str, size_t length, float wrap, float* width, float* lastLineWidth, float* height, uint32_t* lineCount, uint32_t* glyphCount);

View File

@ -200,49 +200,11 @@ void lovrFontRender(Font* font, const char* str, size_t length, float wrap, Hori
}
void lovrFontMeasure(Font* font, const char* str, size_t length, float wrap, float* width, float* lastLineWidth, float* height, uint32_t* lineCount, uint32_t* glyphCount) {
float x = 0.f;
const char* end = str + length;
size_t bytes;
unsigned int previous = '\0';
unsigned int codepoint;
float scale = 1.f / font->pixelDensity;
*width = 0.f;
*lastLineWidth = 0.f;
*lineCount = 0;
*glyphCount = 0;
while ((bytes = utf8_decode(str, end, &codepoint)) > 0) {
if (codepoint == '\n' || (wrap && x * scale > wrap && codepoint == ' ')) {
*width = MAX(*width, x * scale);
(*lineCount)++;
x = 0.f;
previous = '\0';
str += bytes;
continue;
}
// Tabs
if (codepoint == '\t') {
Glyph* space = lovrFontGetGlyph(font, ' ');
x += space->advance * 4.f;
str += bytes;
continue;
}
Glyph* glyph = lovrFontGetGlyph(font, codepoint);
if (glyph->w > 0 && glyph->h > 0) {
(*glyphCount)++;
}
x += glyph->advance + lovrFontGetKerning(font, previous, codepoint);
previous = codepoint;
str += bytes;
}
*width = MAX(*width, x * scale);
*lastLineWidth = x * scale;
*height = ((*lineCount + 1) * lovrRasterizerGetHeight(font->rasterizer) * font->lineHeight) * (font->flip ? -1 : 1);
wrap *= font->pixelDensity;
lovrRasterizerMeasure(font->rasterizer, str, length, wrap, width, lastLineWidth, height, lineCount, glyphCount);
*width /= font->pixelDensity;
*lastLineWidth /= font->pixelDensity;
*height *= font->lineHeight * (font->flip ? -1 : 1);
}
uint32_t lovrFontGetPadding(Font* font) {

View File

@ -1062,7 +1062,7 @@ void lovrGraphicsArc(DrawStyle style, ArcMode mode, Material* material, mat4 tra
for (int i = 0; i <= segments; i++) {
float x = cosf(theta);
float y = sinf(theta);
memcpy(vertices, ((float[]) { x, y, 0.f, 0.f, 0.f, 1.f, x + .5f, 1.f - (y + .5f) }), 8 * sizeof(float));
memcpy(vertices, ((float[]) { x, y, 0.f, 0.f, 0.f, 1.f, (1.f + x) * .5f, (1.f - y) * .5f }), 8 * sizeof(float));
vertices += 8;
theta += angleShift;
}

View File

@ -611,8 +611,13 @@ static void getViews(XrView views[2], uint32_t* count) {
.space = state.referenceSpace
};
for (uint32_t i = 0; i < 2; i++) {
views[i].type = XR_TYPE_VIEW;
views[i].next = NULL;
}
XrViewState viewState = { .type = XR_TYPE_VIEW_STATE };
XR(xrLocateViews(state.session, &viewLocateInfo, &viewState, 2 * sizeof(XrView), count, views));
XR(xrLocateViews(state.session, &viewLocateInfo, &viewState, 2, count, views));
}
static uint32_t openxr_getViewCount(void) {

View File

@ -90,7 +90,7 @@ JNIEXPORT void JNICALL Java_org_lovr_app_Activity_lovrPermissionEvent(JNIEnv* jn
}
}
void os_request_permission(Permission permission) {
void os_request_permission(os_permission permission) {
// TODO
}
@ -114,7 +114,7 @@ void os_on_key(fn_key* callback) {
//
}
void os_on_text*(fn_text* callback) {
void os_on_text(fn_text* callback) {
// TODO
}
@ -122,7 +122,7 @@ void os_on_permission(fn_permission* callback) {
os.onPermissionEvent = callback;
}
bool os_window_open(const WindowFlags* flags) {
bool os_window_open(const os_window_config* config) {
return true;
}
@ -148,8 +148,8 @@ void os_window_swap() {
//
}
void* os_get_gl_proc_address(const char* function) {
return (void*) eglGetProcAddress(function);
fn_gl_proc* os_get_gl_proc_address(const char* function) {
return eglGetProcAddress(function);
}
size_t os_get_home_directory(char* buffer, size_t size) {
@ -457,8 +457,12 @@ HeadsetInterface lovrHeadsetPicoDriver = {
// Activity callbacks
static lua_State* L;
static lua_State* T;
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
static struct lua_State* L;
static struct lua_State* T;
static Variant cookie;
static void lovrPicoBoot(void) {
@ -467,11 +471,7 @@ static void lovrPicoBoot(void) {
L = luaL_newstate();
luax_setmainthread(L);
luaL_openlibs(L);
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
luax_register(L, lovrModules);
lua_pop(L, 2);
luax_preload(L);
lua_pushcfunction(L, luax_getstack);
if (luaL_loadbuffer(L, (const char*) src_resources_boot_lua, src_resources_boot_lua_len, "@boot.lua") || lua_pcall(L, 0, 1, -2)) {

View File

@ -120,7 +120,7 @@ static bool vrapi_getName(char* buffer, size_t length) {
}
static HeadsetOrigin vrapi_getOriginType(void) {
return vrapi_GetTrackingSpace(state.session) == VRAPI_TRACKING_SPACE_STAGE ? ORIGIN_FLOOR : ORIGIN_HEAD;
return vrapi_GetTrackingSpace(state.session) == VRAPI_TRACKING_SPACE_LOCAL_FLOOR ? ORIGIN_FLOOR : ORIGIN_HEAD;
}
static void vrapi_getDisplayDimensions(uint32_t* width, uint32_t* height) {
@ -722,7 +722,7 @@ static void vrapi_update(float dt) {
config.WindowSurface = (size_t) window;
state.session = vrapi_EnterVrMode(&config);
state.frameIndex = 0;
vrapi_SetTrackingSpace(state.session, VRAPI_TRACKING_SPACE_STAGE);
vrapi_SetTrackingSpace(state.session, VRAPI_TRACKING_SPACE_LOCAL_FLOOR);
state.offset = 0.f;
} else if (state.session && (appState != APP_CMD_RESUME || !window)) {
vrapi_LeaveVrMode(state.session);

View File

@ -184,7 +184,6 @@ int lovrWorldCollide(World* world, Shape* a, Shape* b, float friction, float res
contacts[c].surface.mode = 0;
contacts[c].surface.mu = friction;
contacts[c].surface.bounce = restitution;
contacts[c].surface.mu = dInfinity;
if (restitution > 0) {
contacts[c].surface.mode |= dContactBounce;

View File

@ -11,10 +11,10 @@
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="false" android:label="LÖVR" android:extractNativeLibs="false" android:debuggable="true">
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<activity android:name="Activity" android:launchMode="singleTask" android:screenOrientation="landscape" android:excludeFromRecents="true">
<meta-data android:name="android.app.lib_name" android:value="lovr"/>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="com.oculus.intent.category.VR"/>