mirror of https://github.com/bjornbytes/lovr.git
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
|
||||
pid_t pid = getpid();
|
||||
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");
|
||||
if (file) {
|
||||
size_t read = fread(dest, 1, size, file);
|
||||
size_t read = fread(buffer, 1, size, file);
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
buffer[0] = '\0';
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ void lovrPlatformSwapBuffers() {
|
|||
}
|
||||
|
||||
void* lovrPlatformGetProcAddress(const char* function) {
|
||||
return (void*) eglGetProcAddress(function)
|
||||
return (void*) eglGetProcAddress(function);
|
||||
}
|
||||
|
||||
void lovrPlatformOnWindowClose(windowCloseCallback callback) {
|
||||
|
|
|
@ -311,8 +311,8 @@ bool lovrPlatformHasWindow() {
|
|||
#include "headset/oculus_mobile.h"
|
||||
|
||||
// Implicit from boot.lua.h
|
||||
extern unsigned char boot_lua[];
|
||||
extern unsigned int boot_lua_len;
|
||||
extern unsigned char src_resources_boot_lua[];
|
||||
extern unsigned int src_resources_boot_lua_len;
|
||||
|
||||
static lua_State *L, *T;
|
||||
static int coroutineRef = LUA_NOREF;
|
||||
|
@ -408,7 +408,7 @@ static void bridgeLovrInitState() {
|
|||
// Run init
|
||||
|
||||
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));
|
||||
lua_close(L);
|
||||
assert(0);
|
||||
|
|
|
@ -25,7 +25,7 @@ const char* lovrShaderVertexPrefix = ""
|
|||
"#else \n"
|
||||
"#define lovrVertex vec4(lovrPosition, 1.) \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 lovrNormal; \n"
|
||||
"in vec2 lovrTexCoord; \n"
|
||||
|
@ -69,7 +69,7 @@ const char* lovrShaderVertexSuffix = ""
|
|||
const char* lovrShaderFragmentPrefix = ""
|
||||
"#define PIXEL PIXEL \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 lovrVertexColor vertexColor \n"
|
||||
"in vec2 texCoord; \n"
|
||||
|
@ -123,12 +123,12 @@ const char* lovrShaderComputeSuffix = ""
|
|||
"}";
|
||||
|
||||
const char* lovrUnlitVertexShader = ""
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" return lovrProjection * lovrTransform * lovrVertex; \n"
|
||||
"}";
|
||||
|
||||
const char* lovrUnlitFragmentShader = ""
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" return lovrGraphicsColor * lovrVertexColor * lovrDiffuseColor * texture(lovrDiffuseTexture, lovrTexCoord); \n"
|
||||
"}";
|
||||
|
||||
|
@ -141,7 +141,7 @@ const char* lovrStandardVertexShader = ""
|
|||
"out vec3 vNormal; \n"
|
||||
"#endif \n"
|
||||
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" vVertexPositionWorld = vec3(lovrModel * lovrVertex); \n"
|
||||
" vCameraPositionWorld = -lovrView[3].xyz * mat3(lovrView); \n"
|
||||
"#ifdef FLAG_normalMap \n"
|
||||
|
@ -184,7 +184,7 @@ const char* lovrStandardFragmentShader = ""
|
|||
"vec2 prefilteredBRDF(float NoV, float roughness); \n"
|
||||
"vec3 tonemap_ACES(vec3 color); \n"
|
||||
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" vec3 result = vec3(0.); \n"
|
||||
|
||||
// Parameters
|
||||
|
@ -294,7 +294,7 @@ const char* lovrStandardFragmentShader = ""
|
|||
|
||||
const char* lovrCubeVertexShader = ""
|
||||
"out vec3 texturePosition[2]; \n"
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" texturePosition[lovrViewID] = inverse(mat3(lovrTransform)) * (inverse(lovrProjection) * lovrVertex).xyz; \n"
|
||||
" return lovrVertex; \n"
|
||||
"}";
|
||||
|
@ -302,14 +302,14 @@ const char* lovrCubeVertexShader = ""
|
|||
const char* lovrCubeFragmentShader = ""
|
||||
"in vec3 texturePosition[2]; \n"
|
||||
"uniform samplerCube lovrSkyboxTexture; \n"
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" return lovrGraphicsColor * texture(lovrSkyboxTexture, texturePosition[lovrViewID] * vec3(-1, 1, 1)); \n"
|
||||
"}";
|
||||
|
||||
const char* lovrPanoFragmentShader = ""
|
||||
"in vec3 texturePosition[2]; \n"
|
||||
"#define PI 3.141592653589 \n"
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" vec3 direction = texturePosition[lovrViewID]; \n"
|
||||
" float theta = acos(-direction.y / length(direction)); \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"
|
||||
" return max(min(r, g), min(max(r, g), b)); \n"
|
||||
"} \n"
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" vec3 col = texture(lovrDiffuseTexture, lovrTexCoord).rgb; \n"
|
||||
" float sdf = median(col.r, col.g, col.b); \n"
|
||||
" float w = fwidth(sdf); \n"
|
||||
|
@ -331,7 +331,7 @@ const char* lovrFontFragmentShader = ""
|
|||
"}";
|
||||
|
||||
const char* lovrFillVertexShader = ""
|
||||
"vec4 lovrMain() { \n"
|
||||
"vec4 lovrMain { \n"
|
||||
" return lovrVertex; \n"
|
||||
"}";
|
||||
|
||||
|
|
Loading…
Reference in New Issue