1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-19 11:49:59 +00:00

made it compile with RUG on emscripten (at least it should -- it does not work for me because of an emscripten bug apparently)

This commit is contained in:
Zeno Rogue 2018-02-03 14:31:17 +01:00
parent 84b7f73920
commit ad172724e8
10 changed files with 59 additions and 38 deletions

View File

@ -1074,9 +1074,11 @@ void saveHighQualityShot(const char *fname, const char *caption, int fade) {
for(int i=0; i<numi; i++) {
glbuf.clear(numi==1 ? backcolor : i ? 0xFFFFFF : 0);
#if CAP_RUG
if(rug::rugged)
rug::drawRugScene();
else
#endif
drawfullmap();
callhooks(hooks_hqshot, &glbuf);

View File

@ -268,7 +268,7 @@ void initConfig() {
addsaver(geom3::highdetail, "3D highdetail");
addsaver(geom3::middetail, "3D middetail");
addsaver(memory_saving_mode, "memory_saving_mode", (ISMOBILE || ISPANDORA) ? 1 : 0);
addsaver(memory_saving_mode, "memory_saving_mode", (ISMOBILE || ISPANDORA || ISWEB) ? 1 : 0);
addsaver(rug::renderonce, "rug-renderonce");
addsaver(rug::rendernogl, "rug-rendernogl");
@ -342,7 +342,9 @@ void initConfig() {
shmup::initConfig();
#endif
#if CAP_CONFIG
for(auto s: savers) s->reset();
#endif
}
bool inSpecialMode() {

View File

@ -813,7 +813,9 @@ void displayabutton(int px, int py, string s, int col) {
#endif
void gmodekeys(int sym, int uni) {
#if CAP_RUG
if(rug::rugged) rug::handlekeys(sym, uni);
#endif
if(uni == '1' && !rug::rugged) { vid.alpha = 999; vid.scale = 998; vid.xposition = vid.yposition = 0; }
if(uni == '2' && !rug::rugged) { vid.alpha = 1; vid.scale = 0.4; vid.xposition = vid.yposition = 0; }
if(uni == '3' && !rug::rugged) { vid.alpha = 1; vid.scale = 1; vid.xposition = vid.yposition = 0; }

View File

@ -851,6 +851,9 @@ namespace dialog {
//-- choose file dialog--
#define CDIR 0xC0C0C0
#define CFILE forecolor
bool filecmp(const pair<string,int> &f1, const pair<string,int> &f2) {
if(f1.first == "../") return true;
if(f2.first == "../") return false;

View File

@ -6,6 +6,7 @@
#define CAP_TOUR 1
#define CAP_SDLTTF 0
#define CAP_SHMUP 0
#define CAP_RUG 1
#ifdef FAKEWEB
void mainloopiter();

View File

@ -299,9 +299,13 @@ void gdpush(int t);
typedef int SDL_Event;
#endif
#if ISWEB
inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; }
#endif
// #if ISWEB
// inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; }
// #endif
extern "C" {
Uint8 *SDL_GetKeyState(void*);
}
#ifndef CAP_GLEW
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX)

View File

@ -21,6 +21,36 @@ namespace mapeditor {
} ew, ewsearch;
bool autochoose = ISMOBILE;
void scaleall(ld z) {
// (mx,my) = (xcb,ycb) + ss * (xpos,ypos) + (mrx,mry) * scale
// (mrx,mry) * (scale-scale') =
// ss * ((xpos',ypos')-(xpos,ypos))
// mx = xb + ssiz*xpos + mrx * scale
// mx = xb + ssiz*xpos' + mrx * scale'
ld mrx = (.0 + mousex - vid.xcenter) / vid.scale;
ld mry = (.0 + mousey - vid.ycenter) / vid.scale;
if(vid.xres > vid.yres) {
vid.xposition += (vid.scale - vid.scale*z) * mrx / vid.scrsize;
vid.yposition += (vid.scale - vid.scale*z) * mry / vid.scrsize;
}
vid.scale *= z;
printf("scale = " LDF "\n", vid.scale);
#if CAP_TEXTURE
texture::itt = xyscale(texture::itt, 1/z);
display(texture::itt);
if(texture::tstate) {
calcparam();
texture::perform_mapping();
}
#endif
}
#if CAP_EDIT
map<int, cell*> modelcell;
@ -427,9 +457,6 @@ namespace mapeditor {
bool choosefile = false;
#define CDIR 0xC0C0C0
#define CFILE forecolor
void displayFunctionKeys() {
int fs = min(vid.fsize + 5, vid.yres/26);
displayButton(8, vid.yres-8-fs*11, XLAT("F1 = help"), SDLK_F1, 0);
@ -1348,36 +1375,6 @@ namespace mapeditor {
return true;
}
void scaleall(ld z) {
// (mx,my) = (xcb,ycb) + ss * (xpos,ypos) + (mrx,mry) * scale
// (mrx,mry) * (scale-scale') =
// ss * ((xpos',ypos')-(xpos,ypos))
// mx = xb + ssiz*xpos + mrx * scale
// mx = xb + ssiz*xpos' + mrx * scale'
ld mrx = (.0 + mousex - vid.xcenter) / vid.scale;
ld mry = (.0 + mousey - vid.ycenter) / vid.scale;
if(vid.xres > vid.yres) {
vid.xposition += (vid.scale - vid.scale*z) * mrx / vid.scrsize;
vid.yposition += (vid.scale - vid.scale*z) * mry / vid.scrsize;
}
vid.scale *= z;
printf("scale = " LDF "\n", vid.scale);
#if CAP_TEXTURE
texture::itt = xyscale(texture::itt, 1/z);
display(texture::itt);
if(texture::tstate) {
calcparam();
texture::perform_mapping();
}
#endif
}
hyperpoint lstart;
cell *lstartcell;

View File

@ -1300,7 +1300,9 @@ namespace patterns {
if(among(uni, PAT_EMERALD, PAT_PALACE, PAT_ZEBRA, PAT_DOWN, PAT_FIELD, PAT_COLORING, PAT_SIBLING, PAT_CHESS)) {
if(whichPattern == uni) whichPattern = 0;
else whichPattern = uni;
#if CAP_EDIT
mapeditor::modelcell.clear();
#endif
}
else if(uni >= '0' && uni <= '5')

View File

@ -22,6 +22,8 @@ GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers)
#endif
#endif
bool glew = false;
renderbuffer::renderbuffer(int x, int y, bool gl) : x(x), y(y) {
valid = false;

View File

@ -28,7 +28,6 @@ eGeometry gwhere = gEuclid;
bool rugged = false;
bool genrug = false;
bool glew = false;
int vertex_limit = 20000;
@ -1289,6 +1288,10 @@ bool handlekeys(int sym, int uni) {
apply_rotation(rotmatrix(M_PI/2, 0, 2));
return true;
}
#if !CAP_SDL
else if(uni == SDLK_PAGEUP || uni == '[') rug_perspective ? push_all_points(-.1) : model_distance /= exp(.1);
else if(uni == SDLK_PAGEDOWN || uni == ']') rug_perspective ? push_all_points(+.1) : model_distance *= exp(.1);
#endif
else return false;
}
@ -1305,6 +1308,8 @@ void actDraw() {
if(!renderonce) prepareTexture();
physics();
drawRugScene();
#if CAP_SDL
Uint8 *keystate = SDL_GetKeyState(NULL);
int qm = 0;
double alpha = (ticks - lastticks) / 1000.0;
@ -1380,6 +1385,7 @@ void actDraw() {
if(qm) apply_rotation(t);
}
#endif
}
catch(rug_exception) {
rug::close();