mirror of https://github.com/bjornbytes/lovr.git
WIP;
This commit is contained in:
parent
0f1acae42a
commit
872ceb365d
|
@ -78,7 +78,7 @@ add_executable(lovr ${LOVR_SRC} ${LOVR_HEADSET})
|
|||
|
||||
if(EMSCRIPTEN)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
add_definitions(-s USE_ZLIB=1 -s ASSERTIONS=2 -s FULL_ES2=1)
|
||||
add_definitions(-s USE_ZLIB=1 -s ASSERTIONS=2 -s FULL_ES2=1 -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s OUTLINING_LIMIT=15000)
|
||||
set(ZLIB_FOUND 1)
|
||||
set(ZLIB_LIBRARIES "-s USE_ZLIB=1")
|
||||
set(ZLIB_INCLUDE_DIR .)
|
||||
|
@ -198,7 +198,9 @@ elseif(NOT EMSCRIPTEN)
|
|||
endif()
|
||||
|
||||
# FreeType
|
||||
if (WIN32 OR EMSCRIPTEN)
|
||||
if (EMSCRIPTEN)
|
||||
add_definitions(-s USE_FREETYPE=1)
|
||||
elseif (WIN32)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(FREETYPE_NO_DIST TRUE CACHE BOOL "")
|
||||
add_subdirectory(deps/freetype freetype)
|
||||
|
|
|
@ -1,22 +1,41 @@
|
|||
#include "headset/headset.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include <math/mat4.h>
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/vr.h>
|
||||
|
||||
static headsetRenderCallback renderCallback;
|
||||
|
||||
static void onRequestAnimationFrame(void* userdata) {
|
||||
lovrGraphicsSetBackgroundColor(1, 0, 0, 1);
|
||||
lovrGraphicsClear(1, 1);
|
||||
printf("Yay rendering!\n");
|
||||
|
||||
int width = emscripten_vr_get_display_width();
|
||||
int height = emscripten_vr_get_display_height();
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
renderCallback(EYE_LEFT, userdata);
|
||||
float projection[16];
|
||||
float transform[16];
|
||||
|
||||
glViewport(width, 0, width, height);
|
||||
mat4_set(projection, emscripten_vr_get_projection_matrix(0));
|
||||
mat4_set(transform, emscripten_vr_get_view_matrix(0));
|
||||
|
||||
lovrGraphicsPush();
|
||||
lovrGraphicsOrigin();
|
||||
lovrGraphicsMatrixTransform(transform);
|
||||
lovrGraphicsSetProjection(projection);
|
||||
lovrGraphicsSetViewport(0, 0, width / 2, height);
|
||||
renderCallback(EYE_LEFT, userdata);
|
||||
lovrGraphicsPop();
|
||||
|
||||
mat4_set(projection, emscripten_vr_get_projection_matrix(1));
|
||||
mat4_set(transform, emscripten_vr_get_view_matrix(1));
|
||||
|
||||
lovrGraphicsPush();
|
||||
lovrGraphicsOrigin();
|
||||
lovrGraphicsMatrixTransform(transform);
|
||||
lovrGraphicsSetProjection(projection);
|
||||
lovrGraphicsSetViewport(width / 2, 0, width / 2, height);
|
||||
renderCallback(EYE_RIGHT, userdata);
|
||||
lovrGraphicsPop();
|
||||
}
|
||||
|
||||
void lovrHeadsetInit() {
|
||||
|
@ -48,7 +67,8 @@ void lovrHeadsetSetMirrored(int mirror) {
|
|||
}
|
||||
|
||||
void lovrHeadsetGetDisplayDimensions(int* width, int* height) {
|
||||
*width = *height = 0;
|
||||
*width = emscripten_vr_get_display_width();
|
||||
*height = emscripten_vr_get_display_height();
|
||||
}
|
||||
|
||||
void lovrHeadsetGetClipDistance(float* near, float* far) {
|
||||
|
|
Loading…
Reference in New Issue