mymake now works with Emscripten
This commit is contained in:
parent
9a2b464778
commit
35d26d1595
23
hyperweb.cpp
23
hyperweb.cpp
|
@ -2,19 +2,14 @@
|
||||||
// This is the main file when the online version of HyperRogue is compiled with Emscripten.
|
// This is the main file when the online version of HyperRogue is compiled with Emscripten.
|
||||||
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
||||||
|
|
||||||
|
#ifndef ISWEB
|
||||||
#define ISWEB 1
|
#define ISWEB 1
|
||||||
#define ISMINI 0
|
#define ISMINI 0
|
||||||
#define CAP_AUDIO 0
|
|
||||||
#define CAP_SDLGFX 0
|
|
||||||
#define CAP_PNG 0
|
|
||||||
#define CAP_TOUR 1
|
|
||||||
#define CAP_SDLTTF 0
|
|
||||||
#define CAP_SHMUP 0
|
|
||||||
#define CAP_RUG 1
|
|
||||||
#define CAP_INV 0
|
#define CAP_INV 0
|
||||||
#define CAP_URL 1
|
#define CAP_URL 1
|
||||||
#define GLES_ONLY
|
#define GLES_ONLY
|
||||||
#define CAP_COMPLEX2 1
|
#define SCU
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CAP_ROGUEVIZ
|
#if CAP_ROGUEVIZ
|
||||||
#define MAXMDIM 4
|
#define MAXMDIM 4
|
||||||
|
@ -53,7 +48,11 @@ namespace hr {
|
||||||
void offer_download(std::string sfilename, std::string smimetype);
|
void offer_download(std::string sfilename, std::string smimetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SCU
|
||||||
#include "hyper.cpp"
|
#include "hyper.cpp"
|
||||||
|
#else
|
||||||
|
#include "hyper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace hr {
|
namespace hr {
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ string get_value(string name) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void offer_download(string sfilename, string smimetype) {
|
EX void offer_download(string sfilename, string smimetype) {
|
||||||
|
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
var name = UTF8ToString($0, $1);
|
var name = UTF8ToString($0, $1);
|
||||||
|
@ -105,7 +104,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void offer_choose_file(reaction_t r) {
|
EX void offer_choose_file(reaction_t r) {
|
||||||
on_use_file = r;
|
on_use_file = r;
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
fileElem.click();
|
fileElem.click();
|
||||||
|
@ -221,7 +220,7 @@ EM_BOOL fsc_callback(int eventType, const EmscriptenFullscreenChangeEvent *fulls
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initweb() {
|
EX void initweb() {
|
||||||
// toggleanim(false);
|
// toggleanim(false);
|
||||||
emscripten_set_fullscreenchange_callback(0, NULL, false, fsc_callback);
|
emscripten_set_fullscreenchange_callback(0, NULL, false, fsc_callback);
|
||||||
printf("showstartmenu = %d\n", showstartmenu);
|
printf("showstartmenu = %d\n", showstartmenu);
|
||||||
|
@ -241,7 +240,7 @@ transmatrix getOrientation() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void emscripten_get_commandline() {
|
EX void emscripten_get_commandline() {
|
||||||
#ifdef EMSCRIPTEN_FIXED_ARG
|
#ifdef EMSCRIPTEN_FIXED_ARG
|
||||||
string s = EMSCRIPTEN_FIXED_ARG;
|
string s = EMSCRIPTEN_FIXED_ARG;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -62,7 +62,10 @@ struct fullnoun {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !CAP_TRANS
|
#if !CAP_TRANS
|
||||||
|
#if HDR
|
||||||
#define NUMEXTRA 11
|
#define NUMEXTRA 11
|
||||||
|
extern const char* natchars[NUMEXTRA];
|
||||||
|
#endif
|
||||||
const char* natchars[NUMEXTRA] = {"°","é","á", "²", "½", "Θ", "δ", "π", "ϕ", "ᵈ", "∞"};
|
const char* natchars[NUMEXTRA] = {"°","é","á", "²", "½", "Θ", "δ", "π", "ϕ", "ᵈ", "∞"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -638,6 +638,7 @@ EX void initConfig() {
|
||||||
multi::scs[5].uicolor = 0x00C0C0FF;
|
multi::scs[5].uicolor = 0x00C0C0FF;
|
||||||
multi::scs[6].uicolor = 0xC0C0C0FF;
|
multi::scs[6].uicolor = 0xC0C0C0FF;
|
||||||
|
|
||||||
|
#if CAP_CONFIG
|
||||||
addsaver(multi::players, "mode-number of players");
|
addsaver(multi::players, "mode-number of players");
|
||||||
addsaver(alwaysuse, "use configured keys");
|
addsaver(alwaysuse, "use configured keys");
|
||||||
// unfortunately we cannot use key names here because SDL is not yet initialized
|
// unfortunately we cannot use key names here because SDL is not yet initialized
|
||||||
|
@ -656,6 +657,7 @@ EX void initConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=0; i<7; i++) addsaver(multi::scs[i], "player"+its(i));
|
for(int i=0; i<7; i++) addsaver(multi::scs[i], "player"+its(i));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void handleInput(int delta) {
|
EX void handleInput(int delta) {
|
||||||
|
|
19
mymake.cpp
19
mymake.cpp
|
@ -59,6 +59,19 @@ void set_win() {
|
||||||
standard = "";
|
standard = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_web() {
|
||||||
|
preprocessor = "/usr/lib/emscripten/em++ -E";
|
||||||
|
compiler = "/usr/lib/emscripten/em++ -c";
|
||||||
|
default_standard = standard = " -std=c++17";
|
||||||
|
opts = "-DISWEB=1";
|
||||||
|
linker =
|
||||||
|
"/usr/lib/emscripten/em++ -s USE_ZLIB=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s TOTAL_MEMORY=512MB "
|
||||||
|
"-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"FS\",\"ccall\"]' "
|
||||||
|
"-s EXPORTED_FUNCTIONS=\"['_main', '_use_file']\" "
|
||||||
|
"-s DISABLE_EXCEPTION_CATCHING=0 -o mhyper.html";
|
||||||
|
libs = "";
|
||||||
|
}
|
||||||
|
|
||||||
vector<string> modules;
|
vector<string> modules;
|
||||||
|
|
||||||
time_t get_file_time(const string s) {
|
time_t get_file_time(const string s) {
|
||||||
|
@ -118,6 +131,12 @@ int main(int argc, char **argv) {
|
||||||
obj_dir += "/linux";
|
obj_dir += "/linux";
|
||||||
setdir += "../";
|
setdir += "../";
|
||||||
}
|
}
|
||||||
|
else if(s == "-web") {
|
||||||
|
set_web();
|
||||||
|
modules.push_back("hyperweb");
|
||||||
|
obj_dir += "/web";
|
||||||
|
setdir += "../";
|
||||||
|
}
|
||||||
else if(s.substr(0, 2) == "-f") {
|
else if(s.substr(0, 2) == "-f") {
|
||||||
opts += " " + s;
|
opts += " " + s;
|
||||||
obj_dir += "/";
|
obj_dir += "/";
|
||||||
|
|
|
@ -127,11 +127,11 @@ unsigned char fonttable[] = {
|
||||||
|
|
||||||
unsigned char *ftv = fonttable;
|
unsigned char *ftv = fonttable;
|
||||||
|
|
||||||
void resetTabFont() {
|
EX void resetTabFont() {
|
||||||
ftv = fonttable;
|
ftv = fonttable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCompressedChar(int &otwidth, int &otheight, unsigned char *tpix) {
|
EX void loadCompressedChar(int &otwidth, int &otheight, unsigned char *tpix) {
|
||||||
if(*ftv == 255) {
|
if(*ftv == 255) {
|
||||||
fprintf(stderr, "There is something wrong with the font table\n");
|
fprintf(stderr, "There is something wrong with the font table\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
13
sysconfig.h
13
sysconfig.h
|
@ -206,7 +206,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_TOUR
|
#ifndef CAP_TOUR
|
||||||
#define CAP_TOUR (!ISWEB && !ISMINI)
|
#define CAP_TOUR (!ISMINI)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_ROGUEVIZ
|
#ifndef CAP_ROGUEVIZ
|
||||||
|
@ -285,7 +285,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_SHMUP
|
#ifndef CAP_SHMUP
|
||||||
#define CAP_SHMUP 1
|
#define CAP_SHMUP (!ISWEB)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_BITFIELD
|
#ifndef CAP_BITFIELD
|
||||||
|
@ -403,6 +403,10 @@ extern "C" {
|
||||||
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB)
|
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ISWEB
|
||||||
|
#define GLES_ONLY
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CAP_GL
|
#if CAP_GL
|
||||||
#if CAP_GLEW
|
#if CAP_GLEW
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
@ -462,6 +466,11 @@ typedef unsigned GLuint;
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ISWEB
|
||||||
|
#include <emscripten.h>
|
||||||
|
#include <emscripten/html5.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CAP_GMP
|
#if CAP_GMP
|
||||||
#include <gmpxx.h>
|
#include <gmpxx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue