瀏覽代碼

Fix emscripten regressions.

legacy
Sam Hocevar 5 年之前
父節點
當前提交
269ab7c1ac
共有 5 個文件被更改,包括 26 次插入8 次删除
  1. +7
    -3
      src/application/sdl-app.cpp
  2. +6
    -1
      src/base/features.cpp
  3. +3
    -1
      src/engine/ticker.cpp
  4. +3
    -3
      src/gpu/debug.cpp
  5. +7
    -0
      src/gpu/vertexbuffer.cpp

+ 7
- 3
src/application/sdl-app.cpp 查看文件

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 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
@@ -41,6 +41,7 @@ sdl::app_display::app_display(char const *title, ivec2 res)
/* Initialise SDL */
if (!SDL_WasInit(0))
{
msg::debug("initialising SDL\n");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) < 0)
{
msg::error("cannot initialise SDL: %s\n", SDL_GetError());
@@ -51,18 +52,20 @@ sdl::app_display::app_display(char const *title, ivec2 res)
// This seems to fix a bug we used to have at context swap. Maybe remove one day.
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);

#if 0
#if !defined __EMSCRIPTEN__
// Ask for GL 3.2 at least
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
#endif
#if LOL_BUILD_DEBUG
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
#endif
#endif

int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
if (window_size == ivec2(0))
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
msg::debug("initialising main window\n");
m_window = SDL_CreateWindow(title,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
window_size.x, window_size.y, flags);
@@ -75,6 +78,7 @@ sdl::app_display::app_display(char const *title, ivec2 res)
SDL_GetWindowSize(m_window, &res.x, &res.y);

m_glcontext = SDL_GL_CreateContext(m_window);
SDL_GL_MakeCurrent(m_window, m_glcontext);
msg::info("created GL context: %s\n", glGetString(GL_VERSION));

/* Initialise everything */


+ 6
- 1
src/base/features.cpp 查看文件

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 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,6 +19,11 @@ bool has_threads()
{
static char const *var = getenv("LOL_NOTHREADS");
static bool const disable_threads = var && var[0];
#if defined __EMSCRIPTEN__ && !defined __EMSCRIPTEN_PTHREADS__
// For some reason hardware_concurrency() will return the actual number
// of threads/cores even though the system cannot spawn threads.
return false;
#endif
return !disable_threads && std::thread::hardware_concurrency() > 1;
}



+ 3
- 1
src/engine/ticker.cpp 查看文件

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 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
@@ -30,6 +30,7 @@ class ticker_data
public:
ticker_data()
{
msg::debug("platform %s threads\n", has_threads() ? "has" : "has no");
if (has_threads())
{
gamethread = std::make_unique<thread>(std::bind(&ticker_data::GameThreadMain, this));
@@ -557,6 +558,7 @@ void Ticker::SetStateWhenMatch(entity * /* entity */, uint32_t /* state */,

void ticker::setup(float fps)
{
msg::debug("creating ticker\n");
data = std::make_unique<ticker_data>();
data->fps = fps;
}


+ 3
- 3
src/gpu/debug.cpp 查看文件

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 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
@@ -17,7 +17,7 @@
namespace lol
{

#if LOL_BUILD_DEBUG
#if LOL_BUILD_DEBUG && !defined __EMSCRIPTEN__
static std::map<GLenum, char const *> gl_dbg_source_to_str
{
{ GL_DEBUG_SOURCE_API, "API" },
@@ -88,7 +88,7 @@ static void LOL_ATTR_STDCALL

void gpu::setup_debug()
{
#if LOL_BUILD_DEBUG
#if LOL_BUILD_DEBUG && !defined __EMSCRIPTEN__
GLint glflags;
glGetIntegerv(GL_CONTEXT_FLAGS, &glflags);



+ 7
- 0
src/gpu/vertexbuffer.cpp 查看文件

@@ -14,6 +14,13 @@

#include "lolgl.h"

// FIXME: can we make this more generic?
#if defined __EMSCRIPTEN__
#define glGenVertexArrays glGenVertexArraysOES
#define glBindVertexArray glBindVertexArrayOES
#define glDeleteVertexArrays glDeleteVertexArraysOES
#endif

// FIXME: fine-tune this define
#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X



Loading…
取消
儲存