Emscripten flavor now compiles correctly
This commit is contained in:
+3
-3
@@ -99,7 +99,7 @@ WAGIC_OPTION(BUILD_PNG "build png from source" (WIN32 OR APPLE OR PSP OR
|
|||||||
WAGIC_OPTION(BUILD_UNZIP "build unzip from source" ON)
|
WAGIC_OPTION(BUILD_UNZIP "build unzip from source" ON)
|
||||||
WAGIC_OPTION(BUILD_TINYXML "build tinyxml from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN))
|
WAGIC_OPTION(BUILD_TINYXML "build tinyxml from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN))
|
||||||
WAGIC_OPTION(BUILD_ZIPFS "build zipfs from source" ON)
|
WAGIC_OPTION(BUILD_ZIPFS "build zipfs from source" ON)
|
||||||
WAGIC_OPTION(BUILD_SDL2 "build SDL2 from source" (backend_sdl AND (UNIX OR WIN32 OR ANDROID OR EMSCRIPTEN)))
|
WAGIC_OPTION(BUILD_SDL2 "build SDL2 from source" (backend_sdl AND (UNIX OR WIN32 OR ANDROID) AND (NOT EMSCRIPTEN)))
|
||||||
|
|
||||||
#project options
|
#project options
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
@@ -138,6 +138,8 @@ include(FindOrBuild)
|
|||||||
if(PSP)
|
if(PSP)
|
||||||
FindOrBuildPSPSDK()
|
FindOrBuildPSPSDK()
|
||||||
include(platforms/psp/configure.cmake)
|
include(platforms/psp/configure.cmake)
|
||||||
|
elseif(EMSCRIPTEN)
|
||||||
|
include(platforms/emscripten/configure.cmake)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
include(platforms/win/configure.cmake)
|
include(platforms/win/configure.cmake)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
@@ -146,8 +148,6 @@ elseif(UNIX)
|
|||||||
include(platforms/unix/configure.cmake)
|
include(platforms/unix/configure.cmake)
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
include(platforms/android/configure.cmake)
|
include(platforms/android/configure.cmake)
|
||||||
elseif(EMSCRIPTEN)
|
|
||||||
include(platforms/emscripten/configure.cmake)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#set backend dependend configurations
|
#set backend dependend configurations
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
set_target_properties(wagic PROPERTIES LINK_FLAGS "-s USE_SDL=2")
|
set(CMAKE_CXX_FLAGS "-s USE_SDL=2 -std=c++11")
|
||||||
set(CMAKE_CXX_FLAGS "-s USE_SDL=2")
|
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
|
add_definitions(-DLINUX)
|
||||||
|
add_definitions(-DUSERDIR=".wagic")
|
||||||
|
add_definitions(-DRESDIR="Res")
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined FORCE_GLES)
|
#if (defined FORCE_GLES)
|
||||||
#undef GL_ES_VERSION_2_0
|
#undef GL_ES_VERSION_2_0
|
||||||
#undef GL_VERSION_2_0
|
#undef GL_VERSION_2_0
|
||||||
@@ -101,7 +105,7 @@ class SdlApp
|
|||||||
public: /* For easy interfacing with JGE static functions */
|
public: /* For easy interfacing with JGE static functions */
|
||||||
bool Running;
|
bool Running;
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
SDL_GLContext gl_context;
|
SDL_GLContext gl_context;
|
||||||
SDL_Rect viewPort;
|
SDL_Rect viewPort;
|
||||||
Uint32 lastMouseUpTime;
|
Uint32 lastMouseUpTime;
|
||||||
Uint32 lastFingerDownTime;
|
Uint32 lastFingerDownTime;
|
||||||
@@ -112,10 +116,27 @@ public: /* For easy interfacing with JGE static functions */
|
|||||||
|
|
||||||
int mMouseDownX;
|
int mMouseDownX;
|
||||||
int mMouseDownY;
|
int mMouseDownY;
|
||||||
|
static SdlApp* sInstance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SdlApp() : Running(true), window(NULL), gl_context(NULL), lastMouseUpTime(0), lastFingerDownTime(0), mMouseDownX(0), mMouseDownY(0)
|
SdlApp() : Running(true), window(NULL), gl_context(NULL), lastMouseUpTime(0), lastFingerDownTime(0), mMouseDownX(0), mMouseDownY(0)
|
||||||
{
|
{
|
||||||
|
sInstance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OneIter()
|
||||||
|
{
|
||||||
|
SDL_Event Event;
|
||||||
|
if (g_engine)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 5 && SDL_WaitEventTimeout(&Event, 10); ++x)
|
||||||
|
{
|
||||||
|
if(!g_engine->IsPaused())
|
||||||
|
sInstance->OnEvent(&Event);
|
||||||
|
}
|
||||||
|
if(!g_engine->IsPaused())
|
||||||
|
sInstance->OnUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnExecute()
|
int OnExecute()
|
||||||
@@ -125,22 +146,14 @@ public:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Event Event;
|
#ifdef __EMSCRIPTEN__
|
||||||
|
emscripten_set_main_loop(OneIter, 60, 1);
|
||||||
|
#else
|
||||||
while(Running)
|
while(Running)
|
||||||
{
|
{
|
||||||
if (g_engine)
|
OneIter();
|
||||||
{
|
|
||||||
for (int x = 0; x < 5 && SDL_WaitEventTimeout(&Event, 10); ++x)
|
|
||||||
{
|
|
||||||
if(!g_engine->IsPaused())
|
|
||||||
OnEvent(&Event);
|
|
||||||
}
|
|
||||||
if(!g_engine->IsPaused())
|
|
||||||
OnUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
OnCleanup();
|
OnCleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -280,6 +293,7 @@ public:
|
|||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
SdlApp* SdlApp::sInstance = 0;
|
||||||
|
|
||||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user