From 48733f87c45ff673fb9f1036552c97471d717124 Mon Sep 17 00:00:00 2001 From: bjorn Date: Tue, 1 Aug 2017 12:16:09 -0700 Subject: [PATCH] Just use EMCSRIPTEN instead of LOVR_WEB; --- CMakeLists.txt | 1 - src/audio/audio.c | 2 +- src/audio/audio.h | 2 +- src/filesystem/filesystem.c | 4 ++-- src/graphics/graphics.c | 12 ++++++------ src/graphics/mesh.c | 8 ++++---- src/graphics/shader.c | 4 ++-- src/graphics/texture.c | 4 ++-- src/lib/glfw.h | 2 +- src/lovr.c | 4 ++-- 10 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc3bac5f..033def3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ project(lovr) # Setup if(EMSCRIPTEN) message(STATUS "${EMSCRIPTEN_ROOT_PATH}") - add_definitions(-DLOVR_WEB=1) string(CONCAT LOVR_EMSCRIPTEN_FLAGS "-O3 " "-s USE_WEBGL2=1 " diff --git a/src/audio/audio.c b/src/audio/audio.c index a17659b5..74869fa3 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -19,7 +19,7 @@ void lovrAudioInit() { error("Unable to create OpenAL context"); } -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN static LPALCRESETDEVICESOFT alcResetDeviceSOFT; alcResetDeviceSOFT = (LPALCRESETDEVICESOFT) alcGetProcAddress(device, "alcResetDeviceSOFT"); state.isSpatialized = alcIsExtensionPresent(device, "ALC_SOFT_HRTF"); diff --git a/src/audio/audio.h b/src/audio/audio.h index 5b9c3e33..ddc0b375 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -2,7 +2,7 @@ #include "lib/vec/vec.h" #include #include -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN #include #endif diff --git a/src/filesystem/filesystem.c b/src/filesystem/filesystem.c index 55f24ecd..c501ac5c 100644 --- a/src/filesystem/filesystem.c +++ b/src/filesystem/filesystem.c @@ -78,7 +78,7 @@ int lovrFilesystemGetAppdataDirectory(char* dest, unsigned int size) { wcstombs(dest, appData, size); CoTaskMemFree(appData); return 0; -#elif LOVR_WEB +#elif EMSCRIPTEN strncpy(dest, "/home/web_user", size); return 0; #else @@ -99,7 +99,7 @@ int lovrFilesystemGetExecutablePath(char* dest, unsigned int size) { } #elif _WIN32 return !GetModuleFileName(NULL, dest, size); -#elif LOVR_WEB +#elif EMSCRIPTEN return 1; #else #error "This platform is missing an implementation for lovrFilesystemGetExecutablePath" diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index e723860c..14d833f3 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -25,7 +25,7 @@ static void onCloseWindow(GLFWwindow* window) { // Base void lovrGraphicsInit() { -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); @@ -49,14 +49,14 @@ void lovrGraphicsInit() { // Initialize all the things glfwMakeContextCurrent(state.window); glfwSetWindowCloseCallback(state.window, onCloseWindow); -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); #endif glfwSetTime(0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN glfwSwapInterval(0); glEnable(GL_LINE_SMOOTH); #endif @@ -89,7 +89,7 @@ void lovrGraphicsInit() { // System Limits glGetIntegerv(GL_MAX_TEXTURE_SIZE, &state.maxTextureSize); glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &state.maxTextureAnisotropy); -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN state.maxPointSize = 1.f; state.maxTextureMSAA = 1; #else @@ -384,7 +384,7 @@ float lovrGraphicsGetPointSize() { } void lovrGraphicsSetPointSize(float size) { -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN state.pointSize = size; glPointSize(size); #endif @@ -433,7 +433,7 @@ int lovrGraphicsIsWireframe() { } void lovrGraphicsSetWireframe(int wireframe) { -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN if (state.isWireframe != wireframe) { state.isWireframe = wireframe; glPolygonMode(GL_FRONT_AND_BACK, wireframe ? GL_LINE : GL_FILL); diff --git a/src/graphics/mesh.c b/src/graphics/mesh.c index 4144ae2e..1ad6d81a 100644 --- a/src/graphics/mesh.c +++ b/src/graphics/mesh.c @@ -91,7 +91,7 @@ Mesh* lovrMeshCreate(int count, MeshFormat* format, MeshDrawMode drawMode, MeshU glBufferData(GL_ARRAY_BUFFER, mesh->count * mesh->stride, NULL, mesh->usage); glGenVertexArrays(1, &mesh->vao); -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN mesh->data = malloc(mesh->count * mesh->stride); #endif @@ -108,7 +108,7 @@ void lovrMeshDestroy(const Ref* ref) { glDeleteVertexArrays(1, &mesh->vao); vec_deinit(&mesh->map); vec_deinit(&mesh->format); -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN free(mesh->data); #endif free(mesh); @@ -259,7 +259,7 @@ void lovrMeshSetTexture(Mesh* mesh, Texture* texture) { } void* lovrMeshMap(Mesh* mesh, int start, int count) { -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN mesh->isMapped = 1; mesh->mapStart = start; mesh->mapCount = count; @@ -286,7 +286,7 @@ void lovrMeshUnmap(Mesh* mesh) { mesh->isMapped = 0; glBindBuffer(GL_ARRAY_BUFFER, mesh->vbo); -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN int start = mesh->mapStart * mesh->stride; int count = mesh->mapCount * mesh->stride; glBufferSubData(GL_ARRAY_BUFFER, start, count, (char*) mesh->data + start); diff --git a/src/graphics/shader.c b/src/graphics/shader.c index 1890c17c..1d931961 100644 --- a/src/graphics/shader.c +++ b/src/graphics/shader.c @@ -4,7 +4,7 @@ #include const char* lovrShaderVertexPrefix = "" -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN "#version 300 es \n" "precision mediump float; \n" #else @@ -19,7 +19,7 @@ const char* lovrShaderVertexPrefix = "" "uniform mat4 lovrProjection; \n"; const char* lovrShaderFragmentPrefix = "" -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN "#version 300 es \n" "precision mediump float; \n" #else diff --git a/src/graphics/texture.c b/src/graphics/texture.c index 1cf3fcc7..a2a82da2 100644 --- a/src/graphics/texture.c +++ b/src/graphics/texture.c @@ -17,11 +17,11 @@ static void lovrTextureCreateStorage(Texture* texture) { int mipmapCount = log2(MAX(w, h)) + 1; GLenum internalFormat = textureData->format.glInternalFormat; GLenum format = textureData->format.glFormat; -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN if (GLAD_GL_ARB_texture_storage) { #endif glTexStorage2D(GL_TEXTURE_2D, mipmapCount, internalFormat, w, h); -#ifndef LOVR_WEB +#ifndef EMSCRIPTEN } else { for (int i = 0; i < mipmapCount; i++) { glTexImage2D(GL_TEXTURE_2D, i, internalFormat, w, h, 0, format, GL_UNSIGNED_BYTE, NULL); diff --git a/src/lib/glfw.h b/src/lib/glfw.h index a7777a7a..73d68f8e 100644 --- a/src/lib/glfw.h +++ b/src/lib/glfw.h @@ -1,6 +1,6 @@ #pragma once -#if LOVR_WEB +#if EMSCRIPTEN #define GLFW_INCLUDE_ES3 #define GLFW_INCLUDE_GLEXT #elif __APPLE__ diff --git a/src/lovr.c b/src/lovr.c index 97497268..291f70fd 100644 --- a/src/lovr.c +++ b/src/lovr.c @@ -41,7 +41,7 @@ static int lovrGetOS(lua_State* L) { #elif __APPLE__ lua_pushstring(L, "macOS"); return 1; -#elif LOVR_WEB +#elif EMSCRIPTEN lua_pushstring(L, "Web"); #else lua_pushnil(L); @@ -121,7 +121,7 @@ void lovrDestroy(int exitCode) { exit(exitCode); } -#ifdef LOVR_WEB +#ifdef EMSCRIPTEN #include static int stepRef = 0;