mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-02 20:43:35 +00:00
Android fixes. Major change is lovrMain() {} is now lovrMain {}
The oculus drivers choke on #define lovrMain()
This commit is contained in:
parent
0e52e49529
commit
c563787f7d
|
@ -416,15 +416,16 @@ size_t fs_getBundleId(char* buffer, size_t size) {
|
||||||
// TODO
|
// TODO
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
char path[32];
|
char path[32];
|
||||||
snprintf(path, LOVR_PATH_MAX, "/proc/%i/cmdline", (int) pid);
|
snprintf(path, 32, "/proc/%i/cmdline", (int) pid);
|
||||||
FILE* file = fopen(path, "r");
|
FILE* file = fopen(path, "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
size_t read = fread(dest, 1, size, file);
|
size_t read = fread(buffer, 1, size, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
buffer[0] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ void lovrPlatformSwapBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* lovrPlatformGetProcAddress(const char* function) {
|
void* lovrPlatformGetProcAddress(const char* function) {
|
||||||
return (void*) eglGetProcAddress(function)
|
return (void*) eglGetProcAddress(function);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrPlatformOnWindowClose(windowCloseCallback callback) {
|
void lovrPlatformOnWindowClose(windowCloseCallback callback) {
|
||||||
|
|
|
@ -311,8 +311,8 @@ bool lovrPlatformHasWindow() {
|
||||||
#include "headset/oculus_mobile.h"
|
#include "headset/oculus_mobile.h"
|
||||||
|
|
||||||
// Implicit from boot.lua.h
|
// Implicit from boot.lua.h
|
||||||
extern unsigned char boot_lua[];
|
extern unsigned char src_resources_boot_lua[];
|
||||||
extern unsigned int boot_lua_len;
|
extern unsigned int src_resources_boot_lua_len;
|
||||||
|
|
||||||
static lua_State *L, *T;
|
static lua_State *L, *T;
|
||||||
static int coroutineRef = LUA_NOREF;
|
static int coroutineRef = LUA_NOREF;
|
||||||
|
@ -408,7 +408,7 @@ static void bridgeLovrInitState() {
|
||||||
// Run init
|
// Run init
|
||||||
|
|
||||||
lua_pushcfunction(L, luax_getstack);
|
lua_pushcfunction(L, luax_getstack);
|
||||||
if (luaL_loadbuffer(L, (const char*) boot_lua, boot_lua_len, "boot.lua") || lua_pcall(L, 0, 1, -2)) {
|
if (luaL_loadbuffer(L, (const char*) src_resources_boot_lua, src_resources_boot_lua_len, "boot.lua") || lua_pcall(L, 0, 1, -2)) {
|
||||||
WARN("\n LUA STARTUP FAILED: %s\n", lua_tostring(L, -1));
|
WARN("\n LUA STARTUP FAILED: %s\n", lua_tostring(L, -1));
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -25,7 +25,7 @@ const char* lovrShaderVertexPrefix = ""
|
||||||
"#else \n"
|
"#else \n"
|
||||||
"#define lovrVertex vec4(lovrPosition, 1.) \n"
|
"#define lovrVertex vec4(lovrPosition, 1.) \n"
|
||||||
"#endif \n"
|
"#endif \n"
|
||||||
"#define lovrMain() position(mat4 _projection, mat4 _transform, vec4 _vertex) \n"
|
"#define lovrMain position(mat4 _projection, mat4 _transform, vec4 _vertex) \n"
|
||||||
"in vec3 lovrPosition; \n"
|
"in vec3 lovrPosition; \n"
|
||||||
"in vec3 lovrNormal; \n"
|
"in vec3 lovrNormal; \n"
|
||||||
"in vec2 lovrTexCoord; \n"
|
"in vec2 lovrTexCoord; \n"
|
||||||
|
@ -69,7 +69,7 @@ const char* lovrShaderVertexSuffix = ""
|
||||||
const char* lovrShaderFragmentPrefix = ""
|
const char* lovrShaderFragmentPrefix = ""
|
||||||
"#define PIXEL PIXEL \n"
|
"#define PIXEL PIXEL \n"
|
||||||
"#define FRAGMENT FRAGMENT \n"
|
"#define FRAGMENT FRAGMENT \n"
|
||||||
"#define lovrMain() color(vec4 _graphicsColor, sampler2D _image, vec2 _uv) \n"
|
"#define lovrMain color(vec4 _graphicsColor, sampler2D _image, vec2 _uv) \n"
|
||||||
"#define lovrTexCoord texCoord \n"
|
"#define lovrTexCoord texCoord \n"
|
||||||
"#define lovrVertexColor vertexColor \n"
|
"#define lovrVertexColor vertexColor \n"
|
||||||
"in vec2 texCoord; \n"
|
"in vec2 texCoord; \n"
|
||||||
|
@ -123,12 +123,12 @@ const char* lovrShaderComputeSuffix = ""
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char* lovrUnlitVertexShader = ""
|
const char* lovrUnlitVertexShader = ""
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" return lovrProjection * lovrTransform * lovrVertex; \n"
|
" return lovrProjection * lovrTransform * lovrVertex; \n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char* lovrUnlitFragmentShader = ""
|
const char* lovrUnlitFragmentShader = ""
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" return lovrGraphicsColor * lovrVertexColor * lovrDiffuseColor * texture(lovrDiffuseTexture, lovrTexCoord); \n"
|
" return lovrGraphicsColor * lovrVertexColor * lovrDiffuseColor * texture(lovrDiffuseTexture, lovrTexCoord); \n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ const char* lovrStandardVertexShader = ""
|
||||||
"out vec3 vNormal; \n"
|
"out vec3 vNormal; \n"
|
||||||
"#endif \n"
|
"#endif \n"
|
||||||
|
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" vVertexPositionWorld = vec3(lovrModel * lovrVertex); \n"
|
" vVertexPositionWorld = vec3(lovrModel * lovrVertex); \n"
|
||||||
" vCameraPositionWorld = -lovrView[3].xyz * mat3(lovrView); \n"
|
" vCameraPositionWorld = -lovrView[3].xyz * mat3(lovrView); \n"
|
||||||
"#ifdef FLAG_normalMap \n"
|
"#ifdef FLAG_normalMap \n"
|
||||||
|
@ -184,7 +184,7 @@ const char* lovrStandardFragmentShader = ""
|
||||||
"vec2 prefilteredBRDF(float NoV, float roughness); \n"
|
"vec2 prefilteredBRDF(float NoV, float roughness); \n"
|
||||||
"vec3 tonemap_ACES(vec3 color); \n"
|
"vec3 tonemap_ACES(vec3 color); \n"
|
||||||
|
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" vec3 result = vec3(0.); \n"
|
" vec3 result = vec3(0.); \n"
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
|
@ -294,7 +294,7 @@ const char* lovrStandardFragmentShader = ""
|
||||||
|
|
||||||
const char* lovrCubeVertexShader = ""
|
const char* lovrCubeVertexShader = ""
|
||||||
"out vec3 texturePosition[2]; \n"
|
"out vec3 texturePosition[2]; \n"
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" texturePosition[lovrViewID] = inverse(mat3(lovrTransform)) * (inverse(lovrProjection) * lovrVertex).xyz; \n"
|
" texturePosition[lovrViewID] = inverse(mat3(lovrTransform)) * (inverse(lovrProjection) * lovrVertex).xyz; \n"
|
||||||
" return lovrVertex; \n"
|
" return lovrVertex; \n"
|
||||||
"}";
|
"}";
|
||||||
|
@ -302,14 +302,14 @@ const char* lovrCubeVertexShader = ""
|
||||||
const char* lovrCubeFragmentShader = ""
|
const char* lovrCubeFragmentShader = ""
|
||||||
"in vec3 texturePosition[2]; \n"
|
"in vec3 texturePosition[2]; \n"
|
||||||
"uniform samplerCube lovrSkyboxTexture; \n"
|
"uniform samplerCube lovrSkyboxTexture; \n"
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" return lovrGraphicsColor * texture(lovrSkyboxTexture, texturePosition[lovrViewID] * vec3(-1, 1, 1)); \n"
|
" return lovrGraphicsColor * texture(lovrSkyboxTexture, texturePosition[lovrViewID] * vec3(-1, 1, 1)); \n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char* lovrPanoFragmentShader = ""
|
const char* lovrPanoFragmentShader = ""
|
||||||
"in vec3 texturePosition[2]; \n"
|
"in vec3 texturePosition[2]; \n"
|
||||||
"#define PI 3.141592653589 \n"
|
"#define PI 3.141592653589 \n"
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" vec3 direction = texturePosition[lovrViewID]; \n"
|
" vec3 direction = texturePosition[lovrViewID]; \n"
|
||||||
" float theta = acos(-direction.y / length(direction)); \n"
|
" float theta = acos(-direction.y / length(direction)); \n"
|
||||||
" float phi = atan(direction.x, -direction.z); \n"
|
" float phi = atan(direction.x, -direction.z); \n"
|
||||||
|
@ -321,7 +321,7 @@ const char* lovrFontFragmentShader = ""
|
||||||
"float median(float r, float g, float b) { \n"
|
"float median(float r, float g, float b) { \n"
|
||||||
" return max(min(r, g), min(max(r, g), b)); \n"
|
" return max(min(r, g), min(max(r, g), b)); \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" vec3 col = texture(lovrDiffuseTexture, lovrTexCoord).rgb; \n"
|
" vec3 col = texture(lovrDiffuseTexture, lovrTexCoord).rgb; \n"
|
||||||
" float sdf = median(col.r, col.g, col.b); \n"
|
" float sdf = median(col.r, col.g, col.b); \n"
|
||||||
" float w = fwidth(sdf); \n"
|
" float w = fwidth(sdf); \n"
|
||||||
|
@ -331,7 +331,7 @@ const char* lovrFontFragmentShader = ""
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char* lovrFillVertexShader = ""
|
const char* lovrFillVertexShader = ""
|
||||||
"vec4 lovrMain() { \n"
|
"vec4 lovrMain { \n"
|
||||||
" return lovrVertex; \n"
|
" return lovrVertex; \n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue