Przeglądaj źródła

Various emscripten compilation fixes.

legacy
Sam Hocevar 6 lat temu
rodzic
commit
7d42c3d58e
10 zmienionych plików z 34 dodań i 25 usunięć
  1. +1
    -0
      build/autotools/m4/lol-conf.m4
  2. +3
    -3
      src/application/application.cpp
  3. +3
    -3
      src/base/assert.cpp
  4. +1
    -1
      src/engine/ticker.cpp
  5. +5
    -5
      src/gpu/framebuffer.cpp
  6. +2
    -2
      src/gpu/shader.cpp
  7. +3
    -2
      src/lolgl.h
  8. +2
    -2
      src/messageservice.cpp
  9. +12
    -5
      src/platform/sdl/sdlinput.cpp
  10. +2
    -2
      src/sys/init.cpp

+ 1
- 0
build/autotools/m4/lol-conf.m4 Wyświetl plik

@@ -175,6 +175,7 @@ dnl Are we building using Emscripten?
ac_cv_my_have_emscripten="no"
AC_CHECK_HEADERS(emscripten.h,
[ac_cv_my_have_emscripten="yes"
AC_CHECK_HEADERS(html5/emscripten.h)
dnl XXX: activate this if memory heap is too small
#AM_CXXFLAGS="${AM_CXXFLAGS} -s ALLOW_MEMORY_GROWTH=1"
dnl HACK: until emcc properly adds these to EMSDK_OPTS


+ 3
- 3
src/application/application.cpp Wyświetl plik

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -147,7 +147,7 @@ class ApplicationData
#endif
};

#if EMSCRIPTEN
#if __EMSCRIPTEN__
static Application *g_app;

static void AppCallback()
@@ -179,7 +179,7 @@ void Application::Tick()

void Application::Run()
{
#if EMSCRIPTEN
#if __EMSCRIPTEN__
g_app = this;
emscripten_set_main_loop(AppCallback, 0, 1);
#else


+ 3
- 3
src/base/assert.cpp Wyświetl plik

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -19,7 +19,7 @@
# include <execinfo.h>
#endif

#if EMSCRIPTEN
#if HAVE_EMSCRIPTEN_H
# include <emscripten.h>
#endif

@@ -31,7 +31,7 @@ namespace debug

void dump_stack()
{
#if EMSCRIPTEN
#if __EMSCRIPTEN__
/* This would require demangling but we don't care yet. */
msg::debug("%s\n", emscripten_run_script_string("(new Error).stack"));
#elif HAVE_CXA_DEMANGLE && HAVE_BACKTRACE_SYMBOLS


+ 1
- 1
src/engine/ticker.cpp Wyświetl plik

@@ -532,7 +532,7 @@ void Ticker::tick_draw()
/* Clamp FPS */
Profiler::Stop(Profiler::STAT_TICK_BLIT);

#if !EMSCRIPTEN
#if !__EMSCRIPTEN__
/* If framerate is fixed, force wait time to 1/FPS. Otherwise, set wait
* time to 0. */
float frametime = data->fps ? 1.f / data->fps : 0.f;


+ 5
- 5
src/gpu/framebuffer.cpp Wyświetl plik

@@ -248,15 +248,15 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
{
m_data->m_size = size;
m_data->m_bound = false;
#if GL_VERSION_1_1
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormatOrder();
GLenum depth = GL_DEPTH_COMPONENT;
#elif GL_ES_VERSION_2_0
#if GL_ES_VERSION_2_0
/* In OpenGL ES, internal format and format must match. */
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormat();
GLenum depth = GL_DEPTH_COMPONENT16; /* for WebGL */
#elif GL_VERSION_1_1
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormatOrder();
GLenum depth = GL_DEPTH_COMPONENT;
#else
/* In OpenGL ES, internal format and format must match. */
GLenum internal_format = fbo_format.GetFormat();


+ 2
- 2
src/gpu/shader.cpp Wyświetl plik

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -312,7 +312,7 @@ Shader::Shader(std::string const &name,
GLint num_attribs;
glGetProgramiv(data->prog_id, GL_ACTIVE_ATTRIBUTES, &num_attribs);

#if EMSCRIPTEN //WebGL doesn't support GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, so chose a default size value.
#if __EMSCRIPTEN__ // WebGL doesn't support GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, so chose a default size value.
GLint max_len = 256;
#else
GLint max_len;


+ 3
- 2
src/lolgl.h Wyświetl plik

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -20,8 +20,9 @@
#define GL_GLEXT_PROTOTYPES

/* Prefer GLES on browsers */
#if defined EMSCRIPTEN
#if defined __EMSCRIPTEN__
# undef HAVE_GL_2X
# undef LOL_USE_GLEW
#endif

/* Only define one GL platform */


+ 2
- 2
src/messageservice.cpp Wyświetl plik

@@ -22,14 +22,14 @@ namespace lol
{

// This is needed to map MessageService::Send() to the JS when building the HTML.
#if EMSCRIPTEN
#if __EMSCRIPTEN__
extern "C"
{
int C_Send(const char* message) { return (int)MessageService::Send(MessageBucket::AppIn, message); }
//NOT IMPLEMENTED
//bool C_FetchFirst(std::string& message);
}
#endif //EMSCRIPTEN
#endif // __EMSCRIPTEN__

/*
* The global g_messageservice object, initialised by MessageService::Setup()


+ 12
- 5
src/platform/sdl/sdlinput.cpp Wyświetl plik

@@ -19,6 +19,9 @@
# include <SDL.h>
# endif
#endif
#if HAVE_EMSCRIPTEN_HTML5_H
# include <emscripten/html5.h>
#endif

#include "sdlinput.h"

@@ -28,7 +31,7 @@
* there is no SDL display (eg. on the Raspberry Pi). */
#define SDL_FORCE_POLL_JOYSTICK 1

#if EMSCRIPTEN
#if __EMSCRIPTEN__
# define MOUSE_SPEED_MOD 10.f
#else
# define MOUSE_SPEED_MOD 100.f
@@ -133,6 +136,9 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)
m_data->m_tick_in_draw_thread = true;
#endif

#if __EMSCRIPTEN__
emscripten_sample_gamepad_data();
#endif
#if LOL_USE_SDL
SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK);
#endif
@@ -141,7 +147,8 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)
m_data->m_mouse = InputDeviceInternal::CreateStandardMouse();

#if LOL_USE_SDL
# if !EMSCRIPTEN
// XXX: another option is to properly handle gamepad support
# if !__EMSCRIPTEN__
# if SDL_FORCE_POLL_JOYSTICK
SDL_JoystickEventState(SDL_QUERY);
# else
@@ -180,7 +187,7 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)

m_data->m_joysticks.push(sdlstick, stick);
}
# endif //EMSCRIPTEN
# endif // __EMSCRIPTEN__
#endif

m_gamegroup = GAMEGROUP_INPUT;
@@ -188,7 +195,7 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)

SdlInput::~SdlInput()
{
#if LOL_USE_SDL && !EMSCRIPTEN
#if LOL_USE_SDL && !__EMSCRIPTEN__
/* Unregister all the joysticks we added */
while (m_data->m_joysticks.count())
{
@@ -223,7 +230,7 @@ void SdlInputData::Tick(float seconds)
UNUSED(seconds);

/* Pump all joystick events because no event is coming to us. */
# if SDL_FORCE_POLL_JOYSTICK && !EMSCRIPTEN
# if SDL_FORCE_POLL_JOYSTICK && !__EMSCRIPTEN__
SDL_JoystickUpdate();
for (int j = 0; j < m_joysticks.count(); j++)
{


+ 2
- 2
src/sys/init.cpp Wyświetl plik

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -54,7 +54,7 @@ void init(int argc, char *argv[],
* and emscripten, and the current directory on other platforms.
*/

#if __ANDROID__ || EMSCRIPTEN
#if __ANDROID__ || __EMSCRIPTEN__
std::string binarydir = "";
#else
std::string binarydir = ".";


Ładowanie…
Anuluj
Zapisz