1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-19 07:57:39 +00:00

refactored some global and stereo:: variables into display_data structure

This commit is contained in:
Zeno Rogue
2018-11-17 19:24:02 +01:00
parent 680dca90c8
commit d935febf09
28 changed files with 445 additions and 389 deletions

View File

@@ -3,6 +3,9 @@
namespace hr { namespace hr {
display_data default_display;
display_data *current_display = &default_display;
unsigned backcolor = 0; unsigned backcolor = 0;
unsigned bordcolor = 0; unsigned bordcolor = 0;
unsigned forecolor = 0xFFFFFF; unsigned forecolor = 0xFFFFFF;
@@ -27,15 +30,15 @@ namespace stereo {
GLfloat scrdist, scrdist_text; GLfloat scrdist, scrdist_text;
} }
bool stereo::in_anaglyph() { return stereo::mode == stereo::sAnaglyph; } bool display_data::in_anaglyph() { return vid.stereo_mode == sAnaglyph; }
bool stereo::active() { return stereo::mode != sOFF; } bool display_data::stereo_active() { return vid.stereo_mode != sOFF; }
ld stereo::eyewidth() { ld display_data::eyewidth() {
switch(stereo::mode) { switch(vid.stereo_mode) {
case stereo::sAnaglyph: case sAnaglyph:
return stereo::anaglyph_eyewidth; return vid.anaglyph_eyewidth;
case stereo::sLR: case sLR:
return stereo::lr_eyewidth; return vid.lr_eyewidth;
default: default:
return 0; return 0;
} }
@@ -176,24 +179,31 @@ void setcameraangle(bool b) {
bool shaderside_projection; bool shaderside_projection;
int subscreen;
void start_projection(int ed, bool perspective) { void start_projection(int ed, bool perspective) {
glhr::new_projection(); glhr::new_projection();
shaderside_projection = perspective; shaderside_projection = perspective;
if(ed && stereo::mode == stereo::sLR) { auto cd = current_display;
if(subscreen)
glhr::projection_multiply(glhr::scale(1/(cd->xmax-cd->ymin), 1/(cd->ymax-cd->ymin), 1));
if(ed && vid.stereo_mode == sLR) {
glhr::projection_multiply(glhr::translate(ed, 0, 0)); glhr::projection_multiply(glhr::translate(ed, 0, 0));
glhr::projection_multiply(glhr::scale(2, 1, 1)); glhr::projection_multiply(glhr::scale(2, 1, 1));
} }
glhr::projection_multiply(glhr::translate((vid.xcenter*2.)/vid.xres - 1, 1 - (vid.ycenter*2.)/vid.yres, 0)); glhr::projection_multiply(glhr::translate((current_display->xcenter*2.)/vid.xres - 1, 1 - (current_display->ycenter*2.)/vid.yres, 0));
} }
void eyewidth_translate(int ed) { void eyewidth_translate(int ed) {
if(ed) glhr::projection_multiply(glhr::translate(-ed * stereo::eyewidth(), 0, 0)); if(ed) glhr::projection_multiply(glhr::translate(-ed * current_display->eyewidth(), 0, 0));
} }
void stereo::set_projection(int ed, bool apply_models) { void display_data::set_projection(int ed, bool apply_models) {
DEBB(DF_GRAPH, (debugfile,"stereo::set_projection\n")); DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n"));
shaderside_projection = false; shaderside_projection = false;
glhr::new_shader_projection = glhr::shader_projection::standard; glhr::new_shader_projection = glhr::shader_projection::standard;
@@ -205,7 +215,7 @@ void stereo::set_projection(int ed, bool apply_models) {
start_projection(ed, shaderside_projection); start_projection(ed, shaderside_projection);
if(!shaderside_projection) { if(!shaderside_projection) {
glhr::projection_multiply(glhr::ortho(vid.xres/2, -vid.yres/2, abs(stereo::scrdist) + 30000)); glhr::projection_multiply(glhr::ortho(vid.xres/2, -vid.yres/2, abs(current_display->scrdist) + 30000));
if(ed) { if(ed) {
glhr::glmatrix m = glhr::id; glhr::glmatrix m = glhr::id;
m[2][0] -= ed; m[2][0] -= ed;
@@ -228,20 +238,28 @@ void stereo::set_projection(int ed, bool apply_models) {
glhr::projection_multiply(glhr::frustum(vid.xres * 1. / vid.yres, 1)); glhr::projection_multiply(glhr::frustum(vid.xres * 1. / vid.yres, 1));
GLfloat sc = vid.radius / (vid.yres/2.); GLfloat sc = current_display->radius / (vid.yres/2.);
glhr::projection_multiply(glhr::scale(sc, -sc, -1)); glhr::projection_multiply(glhr::scale(sc, -sc, -1));
if(ed) glhr::projection_multiply(glhr::translate(stereo::ipd * ed/2, 0, 0)); if(ed) glhr::projection_multiply(glhr::translate(vid.ipd * ed/2, 0, 0));
stereo::scrdist_text = vid.yres * sc / 2; current_display->scrdist_text = vid.yres * sc / 2;
if(glhr::new_shader_projection == glhr::shader_projection::band) {
glhr::projection_multiply(glhr::scale(2 / M_PI, 2 / M_PI,1));
glhr::glmatrix s = glhr::id;
for(int a=0; a<2; a++)
conformal::apply_orientation(s[a][1], s[a][0]);
glhr::projection_multiply(s);
}
} }
cameraangle_on = false; cameraangle_on = false;
} }
void stereo::set_mask(int ed) { void display_data::set_mask(int ed) {
if(ed == 0 || stereo::mode != stereo::sAnaglyph) { if(ed == 0 || vid.stereo_mode != sAnaglyph) {
glColorMask( GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE ); glColorMask( GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE );
} }
else if(ed == 1) { else if(ed == 1) {
@@ -252,14 +270,20 @@ void stereo::set_mask(int ed) {
} }
} }
void stereo::set_viewport(int ed) { void display_data::set_viewport(int ed) {
if(ed == 0 || stereo::mode != stereo::sLR) ld xmin = vid.xres * current_display->xmin;
glViewport(0, 0, vid.xres, vid.yres); ld xmax = vid.xres * current_display->xmax;
else if(ed == 1) ld ymin = vid.yres * current_display->ymin;
glViewport(0, 0, vid.xres/2, vid.yres); ld ymax = vid.yres * current_display->ymax;
else if(ed == -1)
glViewport(vid.xres/2, 0, vid.xres/2, vid.yres); ld xsize = xmax - xmin, ysize = ymax - ymin;
}
if(ed == 0 || vid.stereo_mode != sLR) ;
else if(ed == 1) xsize /= 2;
else if(ed == -1) xsize /= 2, xmin += xsize;
glViewport(xmin, ymin, xsize, ysize);
}
bool model_needs_depth() { bool model_needs_depth() {
return pmodel == mdBall; return pmodel == mdBall;
@@ -315,7 +339,7 @@ void setGLProjection(color_t col) {
GLERR("setGLProjection"); GLERR("setGLProjection");
stereo::set_projection(0, true); current_display->set_projection(0, true);
GLERR("after set_projection"); GLERR("after set_projection");
} }
@@ -822,7 +846,7 @@ color_t colormix(color_t a, color_t b, color_t c) {
int rhypot(int a, int b) { return (int) sqrt(a*a - b*b); } int rhypot(int a, int b) { return (int) sqrt(a*a - b*b); }
ld realradius() { ld realradius() {
ld vradius = vid.radius; ld vradius = current_display->radius;
if(sphere) { if(sphere) {
if(sphereflipped()) if(sphereflipped())
vradius /= sqrt(vid.alpha*vid.alpha - 1); vradius /= sqrt(vid.alpha*vid.alpha - 1);
@@ -830,7 +854,7 @@ ld realradius() {
vradius = 1e12; // use the following vradius = 1e12; // use the following
} }
if(euclid) if(euclid)
vradius = vid.radius * get_sightrange() / (1 + vid.alpha) / 2.5; vradius = current_display->radius * get_sightrange() / (1 + vid.alpha) / 2.5;
vradius = min<ld>(vradius, min(vid.xres, vid.yres) / 2); vradius = min<ld>(vradius, min(vid.xres, vid.yres) / 2);
return vradius; return vradius;
} }
@@ -838,14 +862,14 @@ ld realradius() {
void drawmessage(const string& s, int& y, color_t col) { void drawmessage(const string& s, int& y, color_t col) {
int rrad = (int) realradius(); int rrad = (int) realradius();
int space; int space;
if(y > vid.ycenter + rrad * vid.stretch) if(y > current_display->ycenter + rrad * vid.stretch)
space = vid.xres; space = vid.xres;
else if(y > vid.ycenter) else if(y > current_display->ycenter)
space = vid.xcenter - rhypot(rrad, (y-vid.ycenter) / vid.stretch); space = current_display->xcenter - rhypot(rrad, (y-current_display->ycenter) / vid.stretch);
else if(y > vid.ycenter - vid.fsize) else if(y > current_display->ycenter - vid.fsize)
space = vid.xcenter - rrad; space = current_display->xcenter - rrad;
else if(y > vid.ycenter - vid.fsize - rrad * vid.stretch) else if(y > current_display->ycenter - vid.fsize - rrad * vid.stretch)
space = vid.xcenter - rhypot(rrad, (vid.ycenter-vid.fsize-y) / vid.stretch); space = current_display->xcenter - rhypot(rrad, (current_display->ycenter-vid.fsize-y) / vid.stretch);
else else
space = vid.xres; space = vid.xres;
@@ -923,13 +947,13 @@ void drawCircle(int x, int y, int size, color_t color, color_t fillcolor) {
glhr::be_nontextured(); glhr::be_nontextured();
glhr::id_modelview(); glhr::id_modelview();
glcoords.clear(); glcoords.clear();
x -= vid.xcenter; y -= vid.ycenter; x -= current_display->xcenter; y -= current_display->ycenter;
int pts = size * 4; int pts = size * 4;
if(pts > 1500) pts = 1500; if(pts > 1500) pts = 1500;
if(ISMOBILE && pts > 72) pts = 72; if(ISMOBILE && pts > 72) pts = 72;
for(int r=0; r<pts; r++) { for(int r=0; r<pts; r++) {
float rr = (M_PI * 2 * r) / pts; float rr = (M_PI * 2 * r) / pts;
glcoords.push_back(make_array<GLfloat>(x + size * sin(rr), y + size * vid.stretch * cos(rr), stereo::scrdist)); glcoords.push_back(make_array<GLfloat>(x + size * sin(rr), y + size * vid.stretch * cos(rr), current_display->scrdist));
} }
glhr::vertices(glcoords); glhr::vertices(glcoords);
glhr::set_depthtest(false); glhr::set_depthtest(false);
@@ -997,7 +1021,7 @@ void displayColorButton(int x, int y, const string& name, int key, int align, in
} }
ld textscale() { ld textscale() {
return vid.fsize / (vid.radius * crossf) * (1+vid.alpha) * 2; return vid.fsize / (current_display->radius * crossf) * (1+vid.alpha) * 2;
} }
// bool notgl = false; // bool notgl = false;

View File

@@ -278,11 +278,11 @@ void initConfig() {
addsaver(viewdists, "expansion mode"); addsaver(viewdists, "expansion mode");
addsaver(backbrightness, "brightness behind sphere"); addsaver(backbrightness, "brightness behind sphere");
addsaver(stereo::ipd, "interpupilar-distance", 0.05); addsaver(vid.ipd, "interpupilar-distance", 0.05);
addsaver(stereo::lr_eyewidth, "eyewidth-lr", 0.5); addsaver(vid.lr_eyewidth, "eyewidth-lr", 0.5);
addsaver(stereo::anaglyph_eyewidth, "eyewidth-anaglyph", 0.1); addsaver(vid.anaglyph_eyewidth, "eyewidth-anaglyph", 0.1);
addsaver(stereo::fov, "field-of-vision", 90); addsaver(vid.fov, "field-of-vision", 90);
addsaverenum(stereo::mode, "stereo-mode"); addsaverenum(vid.stereo_mode, "stereo-mode");
addsaver(vid.euclid_to_sphere, "euclid to sphere projection", 1.5); addsaver(vid.euclid_to_sphere, "euclid to sphere projection", 1.5);
addsaver(vid.twopoint_param, "twopoint parameter", 1); addsaver(vid.twopoint_param, "twopoint parameter", 1);
addsaver(vid.stretch, "stretch", 1); addsaver(vid.stretch, "stretch", 1);
@@ -1181,22 +1181,22 @@ void showStereo() {
string modenames[4] = { "OFF", "anaglyph", "side-by-side", "ODS" }; string modenames[4] = { "OFF", "anaglyph", "side-by-side", "ODS" };
dialog::addSelItem(XLAT("stereo mode"), XLAT(modenames[stereo::mode]), 'm'); dialog::addSelItem(XLAT("stereo mode"), XLAT(modenames[vid.stereo_mode]), 'm');
dialog::addSelItem(XLAT("pupillary distance"), fts3(stereo::ipd), 'e'); dialog::addSelItem(XLAT("pupillary distance"), fts3(vid.ipd), 'e');
switch(stereo::mode) { switch(vid.stereo_mode) {
case stereo::sAnaglyph: case sAnaglyph:
dialog::addSelItem(XLAT("distance between images"), fts(stereo::anaglyph_eyewidth), 'd'); dialog::addSelItem(XLAT("distance between images"), fts(vid.anaglyph_eyewidth), 'd');
break; break;
case stereo::sLR: case sLR:
dialog::addSelItem(XLAT("distance between images"), fts(stereo::lr_eyewidth), 'd'); dialog::addSelItem(XLAT("distance between images"), fts(vid.lr_eyewidth), 'd');
break; break;
default: default:
dialog::addBreak(100); dialog::addBreak(100);
break; break;
} }
dialog::addSelItem(XLAT("field of view"), fts(stereo::fov) + "°", 'f'); dialog::addSelItem(XLAT("field of view"), fts(vid.fov) + "°", 'f');
dialog::addBack(); dialog::addBack();
dialog::display(); dialog::display();
@@ -1216,26 +1216,26 @@ void showStereo() {
) + "\n\n"; ) + "\n\n";
if(uni == 'm') if(uni == 'm')
{ stereo::mode = stereo::eStereo((1 + stereo::mode) % (CAP_ODS ? 4 : 3)); return; } { vid.stereo_mode = eStereo((1 + vid.stereo_mode) % (CAP_ODS ? 4 : 3)); return; }
else if(uni == 'e') else if(uni == 'e')
dialog::editNumber(stereo::ipd, -10, 10, 0.01, 0, XLAT("pupillary distance"), dialog::editNumber(vid.ipd, -10, 10, 0.01, 0, XLAT("pupillary distance"),
help3 + help3 +
XLAT("The distance between your eyes in the represented 3D object. This is given in absolute units.") XLAT("The distance between your eyes in the represented 3D object. This is given in absolute units.")
); );
else if(uni == 'd' && stereo::mode == stereo::sAnaglyph) else if(uni == 'd' && vid.stereo_mode == sAnaglyph)
dialog::editNumber(stereo::anaglyph_eyewidth, -1, 1, 0.01, 0, XLAT("distance between images"), dialog::editNumber(vid.anaglyph_eyewidth, -1, 1, 0.01, 0, XLAT("distance between images"),
help3 + help3 +
XLAT("The distance between your eyes. 1 is the width of the screen.")); XLAT("The distance between your eyes. 1 is the width of the screen."));
else if(uni == 'd' && stereo::mode == stereo::sLR) else if(uni == 'd' && vid.stereo_mode == sLR)
dialog::editNumber(stereo::lr_eyewidth, -1, 1, 0.01, 0, XLAT("distance between images"), dialog::editNumber(vid.lr_eyewidth, -1, 1, 0.01, 0, XLAT("distance between images"),
help3 + help3 +
XLAT("The distance between your eyes. 1 is the width of the screen.")); XLAT("The distance between your eyes. 1 is the width of the screen."));
else if(uni == 'f') else if(uni == 'f')
dialog::editNumber(stereo::fov, 1, 170, 1, 45, "field of view", dialog::editNumber(vid.fov, 1, 170, 1, 45, "field of view",
help3 + XLAT( help3 + XLAT(
"Horizontal field of view, in angles. " "Horizontal field of view, in angles. "
"This affects the Hypersian Rug mode (even when stereo is OFF) " "This affects the Hypersian Rug mode (even when stereo is OFF) "
@@ -1823,10 +1823,10 @@ unordered_map<string, ld&> params = {
{"mtrans", conformal::model_transition}, {"mtrans", conformal::model_transition},
{"hp", conformal::halfplane_scale}, {"hp", conformal::halfplane_scale},
{"back", backbrightness}, {"back", backbrightness},
{"ipd", stereo::ipd}, {"ipd", vid.ipd},
{"lr", stereo::lr_eyewidth}, {"lr", vid.lr_eyewidth},
{"anaglyph", stereo::anaglyph_eyewidth}, {"anaglyph", vid.anaglyph_eyewidth},
{"fov", stereo::fov}, {"fov", vid.fov},
{"ets", vid.euclid_to_sphere}, {"ets", vid.euclid_to_sphere},
{"stretch", vid.stretch}, {"stretch", vid.stretch},
{"twopoint", vid.twopoint_param}, {"twopoint", vid.twopoint_param},

View File

@@ -471,9 +471,9 @@ namespace conformal {
renderbuffer glbuf(bandfull, bandfull, vid.usingGL); renderbuffer glbuf(bandfull, bandfull, vid.usingGL);
vid.xres = vid.yres = bandfull; vid.xres = vid.yres = bandfull;
glbuf.enable(); vid.radius = bandhalf; glbuf.enable(); current_display->radius = bandhalf;
calcparam(); calcparam();
stereo::set_viewport(0); current_display->set_viewport(0);
ld xpos = 0; ld xpos = 0;
@@ -505,7 +505,7 @@ namespace conformal {
progress(s0 + buf + " ("+its(j+bonus)+"/"+its(siz+bonus+bonus-1)+")"); */ progress(s0 + buf + " ("+its(j+bonus)+"/"+its(siz+bonus+bonus-1)+")"); */
// calcparam(); vid.radius = bandhalf; // calcparam(); current_display->radius = bandhalf;
phase = j; movetophase(); phase = j; movetophase();
glbuf.clear(backcolor); glbuf.clear(backcolor);
@@ -515,7 +515,7 @@ namespace conformal {
hyperpoint last = ggmatrix(last_base) * last_relative; hyperpoint last = ggmatrix(last_base) * last_relative;
hyperpoint hscr; hyperpoint hscr;
applymodel(last, hscr); applymodel(last, hscr);
ld bwidth = -vid.radius * hscr[0]; ld bwidth = -current_display->radius * hscr[0];
printf("bwidth = %lf/%lf\n", bwidth, len); printf("bwidth = %lf/%lf\n", bwidth, len);
drawsegment: drawsegment:
@@ -563,7 +563,7 @@ namespace conformal {
} }
rbuf.reset(); rbuf.reset();
stereo::set_viewport(0); current_display->set_viewport(0);
if(includeHistory) restoreBack(); if(includeHistory) restoreBack();
@@ -641,11 +641,11 @@ namespace conformal {
initquickqueue(); initquickqueue();
queuereset(mdUnchanged, PPR::LINE); queuereset(mdUnchanged, PPR::LINE);
for(int a=-1; a<=1; a++) { for(int a=-1; a<=1; a++) {
curvepoint(hpxyz(-M_PI/2 * vid.radius, a*vid.radius, 0)); curvepoint(hpxyz(-M_PI/2 * current_display->radius, a*current_display->radius, 0));
curvepoint(hpxyz(+M_PI/2 * vid.radius, a*vid.radius, 0)); curvepoint(hpxyz(+M_PI/2 * current_display->radius, a*current_display->radius, 0));
queuecurve(forecolor, 0, PPR::LINE); queuecurve(forecolor, 0, PPR::LINE);
curvepoint(hpxyz(a*vid.radius, -M_PI/2*vid.radius, 0)); curvepoint(hpxyz(a*current_display->radius, -M_PI/2*current_display->radius, 0));
curvepoint(hpxyz(a*vid.radius, +M_PI/2*vid.radius, 0)); curvepoint(hpxyz(a*current_display->radius, +M_PI/2*current_display->radius, 0));
queuecurve(forecolor, 0, PPR::LINE); queuecurve(forecolor, 0, PPR::LINE);
} }
queuereset(pmodel, PPR::LINE); queuereset(pmodel, PPR::LINE);

View File

@@ -38,7 +38,6 @@ movedir mousedest;
ld shiftmul = 1; ld shiftmul = 1;
cell *mouseover, *mouseover2, *lmouseover; cell *mouseover, *mouseover2, *lmouseover;
cellwalker centerover;
ld modist, modist2, centdist; ld modist, modist2, centdist;
int lastt; int lastt;
@@ -278,8 +277,8 @@ void handlePanning(int sym, int uni) {
if(isGravityLand(cwt.at->land)) playermoved = false; if(isGravityLand(cwt.at->land)) playermoved = false;
if(sym == PSEUDOKEY_WHEELUP) { if(sym == PSEUDOKEY_WHEELUP) {
ld jx = (mousex - vid.xcenter - .0) / vid.radius / 10; ld jx = (mousex - current_display->xcenter - .0) / current_display->radius / 10;
ld jy = (mousey - vid.ycenter - .0) / vid.radius / 10; ld jy = (mousey - current_display->ycenter - .0) / current_display->radius / 10;
playermoved = false; playermoved = false;
View = gpushxto0(hpxy(jx, jy)) * View; View = gpushxto0(hpxy(jx, jy)) * View;
sym = 1; sym = 1;
@@ -392,7 +391,7 @@ void handleKeyNormal(int sym, int uni) {
else quitmainloop = true; else quitmainloop = true;
} }
if(uni == 'o' && DEFAULTNOR(sym)) setAppropriateOverview(); if(uni == 'o' && DEFAULTNOR(sym)) get_o_key().second();
#if CAP_INV #if CAP_INV
if(uni == 'i' && DEFAULTNOR(sym) && inv::on) if(uni == 'i' && DEFAULTNOR(sym) && inv::on)
pushScreen(inv::show); pushScreen(inv::show);
@@ -766,8 +765,8 @@ void handle_event(SDL_Event& ev) {
if((rightclick || (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2()) { if((rightclick || (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2()) {
fix_mouseh(); fix_mouseh();
if(anyctrl) { if(anyctrl) {
vid.xposition += (mousex - lmousex) * 1. / vid.scrsize, vid.xposition += (mousex - lmousex) * 1. / current_display->scrsize,
vid.yposition += (mousey - lmousey) * 1. / vid.scrsize; vid.yposition += (mousey - lmousey) * 1. / current_display->scrsize;
} }
else if(mouseh[2] < 50 && mouseoh[2] < 50) { else if(mouseh[2] < 50 && mouseoh[2] < 50) {
panning(mouseoh, mouseh); panning(mouseoh, mouseh);
@@ -777,8 +776,8 @@ void handle_event(SDL_Event& ev) {
#ifdef SIMULATE_JOYSTICK #ifdef SIMULATE_JOYSTICK
// pretend that both joysticks are present // pretend that both joysticks are present
stick = panstick = (SDL_Joystick*) (&vid); stick = panstick = (SDL_Joystick*) (&vid);
panjoyx = 20 * (mousex - vid.xcenter); panjoyx = 20 * (mousex - current_display->xcenter);
panjoyy = 20 * (mousey - vid.ycenter); panjoyy = 20 * (mousey - current_display->ycenter);
checkjoy(); checkjoy();
#endif #endif
@@ -831,18 +830,18 @@ void displayabutton(int px, int py, string s, int col) {
// TMP // TMP
int siz = vid.yres > vid.xres ? vid.fsize*2 : vid.fsize * 3/2; int siz = vid.yres > vid.xres ? vid.fsize*2 : vid.fsize * 3/2;
int rad = (int) realradius(); int rad = (int) realradius();
if(stereo::mode == stereo::sLR) rad = 99999; if(vid.stereo_mode == sLR) rad = 99999;
int vrx = min(rad, vid.xres/2 - 40); int vrx = min(rad, vid.xres/2 - 40);
int vry = min(rad, min(vid.ycenter, vid.yres - vid.ycenter) - 20); int vry = min(rad, min(current_display->ycenter, vid.yres - current_display->ycenter) - 20);
int x = vid.xcenter + px * vrx; int x = current_display->xcenter + px * vrx;
int y = vid.ycenter + py * (vry - siz/2); int y = current_display->ycenter + py * (vry - siz/2);
int vrr = int(hypot(vrx, vry) * sqrt(2.)); int vrr = int(hypot(vrx, vry) * sqrt(2.));
if(gtouched && !mouseover if(gtouched && !mouseover
&& abs(mousex - vid.xcenter) < vrr && abs(mousex - current_display->xcenter) < vrr
&& abs(mousey - vid.ycenter) < vrr && abs(mousey - current_display->ycenter) < vrr
&& hypot(mousex-vid.xcenter, mousey-vid.ycenter) > vrr && hypot(mousex-current_display->xcenter, mousey-current_display->ycenter) > vrr
&& px == (mousex > vid.xcenter ? 1 : -1) && px == (mousex > current_display->xcenter ? 1 : -1)
&& py == (mousey > vid.ycenter ? 1 : -1) && py == (mousey > current_display->ycenter ? 1 : -1)
) col = 0xFF0000; ) col = 0xFF0000;
if(displayfr(x, y, 0, siz, s, col, 8+8*px)) if(displayfr(x, y, 0, siz, s, col, 8+8*px))
buttonclicked = true; buttonclicked = true;
@@ -969,7 +968,7 @@ void show() {
if(!sphere) set_geometry(gSphere); if(!sphere) set_geometry(gSphere);
mode = 0; fullcenter(); mode = 0; fullcenter();
mode = 2; sensitivity = 1; mode = 2; sensitivity = 1;
stereo::mode = stereo::sLR; stereo::ipd = 0.2; vid.stereo_mode = sLR; vid.ipd = 0.2;
vid.alpha = 0; vid.scale = 1; vid.alpha = 0; vid.scale = 1;
}); });

View File

@@ -477,7 +477,7 @@ int read_cheat_args() {
} }
else if(argis("-SM")) { else if(argis("-SM")) {
PHASEFROM(2); PHASEFROM(2);
shift(); stereo::mode = stereo::eStereo(argi()); shift(); vid.stereo_mode = eStereo(argi());
} }
#if CAP_INV #if CAP_INV
else if(argis("-IU")) { else if(argis("-IU")) {

View File

@@ -245,7 +245,7 @@ namespace dialog {
int lastspace = 0; int lastspace = 0;
int xs, xo; int xs, xo;
if(sidescreen) if(current_display->sidescreen)
xs = dwidth - vid.fsize*2, xo = vid.yres + vid.fsize; xs = dwidth - vid.fsize*2, xo = vid.yres + vid.fsize;
else else
xs = vid.xres * 618/1000, xo = vid.xres * 186/1000; xs = vid.xres * 618/1000, xo = vid.xres * 186/1000;
@@ -314,7 +314,7 @@ namespace dialog {
dcenter = vid.xres/2; dcenter = vid.xres/2;
dwidth = vid.xres; dwidth = vid.xres;
if(sidescreen) { if(current_display->sidescreen) {
dwidth = vid.xres - vid.yres; dwidth = vid.xres - vid.yres;
dcenter = vid.xres - dwidth / 2; dcenter = vid.xres - dwidth / 2;
} }
@@ -382,7 +382,7 @@ namespace dialog {
else if(I.type == diSlider) { else if(I.type == diSlider) {
bool xthis = (mousey >= top && mousey < tothei); bool xthis = (mousey >= top && mousey < tothei);
int sl, sr; int sl, sr;
if(sidescreen) if(current_display->sidescreen)
sl = vid.yres + vid.fsize*2, sr = vid.xres - vid.fsize*2; sl = vid.yres + vid.fsize*2, sr = vid.xres - vid.fsize*2;
else else
sl = vid.xres/4, sr = vid.xres*3/4; sl = vid.xres/4, sr = vid.xres*3/4;
@@ -523,7 +523,7 @@ namespace dialog {
dcenter = vid.xres/2; dcenter = vid.xres/2;
dwidth = vid.xres; dwidth = vid.xres;
if(sidescreen) { if(current_display->sidescreen) {
dwidth = vid.xres - vid.yres; dwidth = vid.xres - vid.yres;
dcenter = vid.xres - dwidth / 2; dcenter = vid.xres - dwidth / 2;
} }
@@ -710,7 +710,7 @@ namespace dialog {
} }
else if(uni == 500) { else if(uni == 500) {
int sl, sr; int sl, sr;
if(sidescreen) if(current_display->sidescreen)
sl = vid.yres + vid.fsize*2, sr = vid.xres - vid.fsize*2; sl = vid.yres + vid.fsize*2, sr = vid.xres - vid.fsize*2;
else else
sl = vid.xres/4, sr = vid.xres*3/4; sl = vid.xres/4, sr = vid.xres*3/4;

View File

@@ -2288,8 +2288,8 @@ vector<glhr::colored_vertex> auravertices;
void drawaura() { void drawaura() {
if(!haveaura()) return; if(!haveaura()) return;
if(stereo::mode) return; if(vid.stereo_mode) return;
double rad = vid.radius; double rad = current_display->radius;
if(sphere && !mdAzimuthalEqui()) rad /= sqrt(vid.alpha*vid.alpha - 1); if(sphere && !mdAzimuthalEqui()) rad /= sqrt(vid.alpha*vid.alpha - 1);
for(int v=0; v<4; v++) sumaura(v); for(int v=0; v<4; v++) sumaura(v);
@@ -2312,8 +2312,8 @@ void drawaura() {
for(int y=0; y<vid.yres; y++) for(int y=0; y<vid.yres; y++)
for(int x=0; x<vid.xres; x++) { for(int x=0; x<vid.xres; x++) {
ld hx = (x * 1. - vid.xcenter) / rad; ld hx = (x * 1. - current_display->xcenter) / rad;
ld hy = (y * 1. - vid.ycenter) / rad / vid.stretch; ld hy = (y * 1. - current_display->ycenter) / rad / vid.stretch;
if(vid.camera_angle) camrotate(hx, hy); if(vid.camera_angle) camrotate(hx, hy);
@@ -5004,7 +5004,7 @@ void fallingMonsterAnimation(cell *c, eMonster m, int id) {
void queuecircleat(cell *c, double rad, color_t col) { void queuecircleat(cell *c, double rad, color_t col) {
if(!c) return; if(!c) return;
if(!gmatrix.count(c)) return; if(!gmatrix.count(c)) return;
if(stereo::mode || sphere) { if(vid.stereo_mode || sphere) {
dynamicval<color_t> p(poly_outline, col); dynamicval<color_t> p(poly_outline, col);
queuepolyat(gmatrix[c] * spintick(100), shGem[1], 0, PPR::LINE); queuepolyat(gmatrix[c] * spintick(100), shGem[1], 0, PPR::LINE);
return; return;
@@ -5044,7 +5044,7 @@ void drawMarkers() {
if(!inHighQual) { if(!inHighQual) {
bool ok = !ISPANDORA || mousepressed; bool ok = !ISPANDORA || mousepressed;
if(G(dragon::target) && haveMount()) { if(G(dragon::target) && haveMount()) {
queuechr(Gm0(dragon::target), 2*vid.fsize, 'X', queuechr(Gm0(dragon::target), 2*vid.fsize, 'X',
@@ -5054,30 +5054,30 @@ void drawMarkers() {
/* for(int i=0; i<12; i++) if(c->type == 5 && c->master == &dodecahedron[i]) /* for(int i=0; i<12; i++) if(c->type == 5 && c->master == &dodecahedron[i])
queuechr(xc, yc, sc, 4*vid.fsize, 'A'+i, iinf[itOrbDomination].color); */ queuechr(xc, yc, sc, 4*vid.fsize, 'A'+i, iinf[itOrbDomination].color); */
{ if(1) {
using namespace yendor; using namespace yendor;
if(yii < isize(yi) && !yi[yii].found) { if(yii < isize(yi) && !yi[yii].found) {
cell *keycell = NULL; cell *keycell = NULL;
int i; int i;
for(i=0; i<YDIST; i++) for(i=0; i<YDIST; i++)
if(yi[yii].path[i]->cpdist <= get_sightrange_ambush()) { if(yi[yii].path[i]->cpdist <= get_sightrange_ambush()) {
keycell = yi[yii].path[i]; keycell = yi[yii].path[i];
break; break;
}
if(keycell) {
for(; i<YDIST; i++) {
cell *c = yi[yii].path[i];
if(inscreenrange(c))
keycell = c;
}
hyperpoint H = tC0(ggmatrix(keycell));
queuechr(H, 2*vid.fsize, 'X', 0x10101 * int(128 + 100 * sintick(150)));
queuestr(H, vid.fsize, its(celldistance(cwt.at, yi[yii].key())), 0x10101 * int(128 - 100 * sintick(150)));
addauraspecial(H, iinf[itOrbYendor].color, 0);
} }
if(keycell) {
for(; i<YDIST; i++) {
cell *c = yi[yii].path[i];
if(inscreenrange(c))
keycell = c;
}
hyperpoint H = tC0(ggmatrix(keycell));
queuechr(H, 2*vid.fsize, 'X', 0x10101 * int(128 + 100 * sintick(150)));
queuestr(H, vid.fsize, its(celldistance(cwt.at, yi[yii].key())), 0x10101 * int(128 - 100 * sintick(150)));
addauraspecial(H, iinf[itOrbYendor].color, 0);
} }
} }
}
if(lmouseover && vid.drawmousecircle && ok && DEFAULTCONTROL && MOBON) { if(lmouseover && vid.drawmousecircle && ok && DEFAULTCONTROL && MOBON) {
queuecircleat(lmouseover, .8, darkena(lmouseover->cpdist > 1 ? 0x00FFFF : 0xFF0000, 0, 0xFF)); queuecircleat(lmouseover, .8, darkena(lmouseover->cpdist > 1 ? 0x00FFFF : 0xFF0000, 0, 0xFF));
} }
@@ -5480,20 +5480,23 @@ bool dronemode;
purehookset hooks_calcparam; purehookset hooks_calcparam;
void calcparam() { void calcparam() {
auto cd = current_display;
DEBB(DF_GRAPH, (debugfile,"calc param\n")); DEBB(DF_GRAPH, (debugfile,"calc param\n"));
vid.xcenter = vid.xres / 2; cd->xcenter = vid.xres * (cd->xmax + cd->xmin) / 2;
vid.ycenter = vid.yres / 2; cd->ycenter = vid.yres * (cd->ymax + cd->ymin) / 2;
if(vid.scale > -1e-2 && vid.scale < 1e-2) vid.scale = 1; if(vid.scale > -1e-2 && vid.scale < 1e-2) vid.scale = 1;
ld realradius = min(vid.xcenter, vid.ycenter); ld realradius = min(vid.xres * (cd->xmax - cd->xmin) / 2, vid.yres * (cd->ymax - cd->ymin) / 2);
vid.scrsize = realradius - (inHighQual ? 0 : ISANDROID ? 2 : ISIOS ? 40 : 40); cd->scrsize = realradius - (inHighQual ? 0 : ISANDROID ? 2 : ISIOS ? 40 : 40);
sidescreen = false; sidescreen = false;
if(vid.xres < vid.yres - 2 * vid.fsize && !inHighQual) { if(vid.xres < vid.yres - 2 * vid.fsize && !inHighQual) {
vid.ycenter = vid.yres - vid.scrsize - vid.fsize; cd->ycenter = vid.yres - cd->scrsize - vid.fsize;
} }
else { else {
if(vid.xres >= vid.yres * 5/4-16 && (cmode & sm::SIDE)) if(vid.xres >= vid.yres * 5/4-16 && (cmode & sm::SIDE))
@@ -5503,24 +5506,24 @@ void calcparam() {
sidescreen = true; sidescreen = true;
#endif #endif
if(sidescreen) vid.xcenter = vid.yres/2; if(sidescreen) cd->xcenter = vid.yres/2;
} }
vid.radius = vid.scale * vid.scrsize; cd->radius = vid.scale * cd->scrsize;
realradius = min(realradius, vid.radius); realradius = min(realradius, cd->radius);
if(dronemode) { vid.ycenter -= vid.radius; vid.ycenter += vid.fsize/2; vid.ycenter += vid.fsize/2; vid.radius *= 2; } if(dronemode) { cd->ycenter -= cd->radius; cd->ycenter += vid.fsize/2; cd->ycenter += vid.fsize/2; cd->radius *= 2; }
vid.xcenter += vid.scrsize * vid.xposition; cd->xcenter += cd->scrsize * vid.xposition;
vid.ycenter += vid.scrsize * vid.yposition; cd->ycenter += cd->scrsize * vid.yposition;
stereo::tanfov = tan(stereo::fov * degree / 2); cd->tanfov = tan(vid.fov * degree / 2);
if(pmodel) if(pmodel)
stereo::scrdist = vid.xres / 2 / stereo::tanfov; cd->scrdist = vid.xres / 2 / cd->tanfov;
else else
stereo::scrdist = vid.radius; cd->scrdist = cd->radius;
stereo::scrdist_text = stereo::scrdist; cd->scrdist_text = cd->scrdist;
callhooks(hooks_calcparam); callhooks(hooks_calcparam);
} }
@@ -5615,7 +5618,7 @@ void gamescreen(int _darken) {
buttonclicked = false; buttonclicked = false;
if((cmode & sm::NORMAL) && stereo::mode != stereo::sLR) { if((cmode & sm::NORMAL) && vid.stereo_mode != sLR) {
if(andmode == 0 && shmup::on) { if(andmode == 0 && shmup::on) {
using namespace shmupballs; using namespace shmupballs;
calc(); calc();
@@ -5668,7 +5671,7 @@ void normalscreen() {
keyhandler = handleKeyNormal; keyhandler = handleKeyNormal;
if(!playerfound && !anims::any_on()) if(!playerfound && !anims::any_on())
displayButton(vid.xcenter, vid.ycenter, XLAT(mousing ? "find the player" : "press SPACE to find the player"), ' ', 8); displayButton(current_display->xcenter, current_display->ycenter, XLAT(mousing ? "find the player" : "press SPACE to find the player"), ' ', 8);
describeMouseover(); describeMouseover();
} }
@@ -5754,12 +5757,12 @@ void drawscreen() {
for(int p=0; p<numplayers(); p++) if(multi::playerActive(p)) for(int p=0; p<numplayers(); p++) if(multi::playerActive(p))
displayfr(vid.xres * (p+.5) / numplayers(), displayfr(vid.xres * (p+.5) / numplayers(),
vid.ycenter - vid.radius * 3/4, 2, current_display->ycenter - current_display->radius * 3/4, 2,
vid.fsize, vid.fsize,
XLAT(minetexts[mines[p]]), minecolors[mines[p]], 8); XLAT(minetexts[mines[p]]), minecolors[mines[p]], 8);
if(minefieldNearby && !shmup::on && cwt.at->land != laMinefield && cwt.peek()->land != laMinefield) { if(minefieldNearby && !shmup::on && cwt.at->land != laMinefield && cwt.peek()->land != laMinefield) {
displayfr(vid.xres/2, vid.ycenter - vid.radius * 3/4 - vid.fsize*3/2, 2, displayfr(vid.xres/2, current_display->ycenter - current_display->radius * 3/4 - vid.fsize*3/2, 2,
vid.fsize, vid.fsize,
XLAT("WARNING: you are entering a minefield!"), XLAT("WARNING: you are entering a minefield!"),
col, 8); col, 8);
@@ -5822,7 +5825,6 @@ void resetGeometry() {
//=== animation //=== animation
map<cell*, animation> animations[ANIMLAYERS]; map<cell*, animation> animations[ANIMLAYERS];
unordered_map<cell*, transmatrix> gmatrix, gmatrix0;
int revhint(cell *c, int hint) { int revhint(cell *c, int hint) {
if(hint >= 0 && hint < c->type) return c->c.spin(hint); if(hint >= 0 && hint < c->type) return c->c.spin(hint);

View File

@@ -344,18 +344,18 @@ void drawMobileArrow(int i) {
bool nofps = false; bool nofps = false;
void drawStats() { void drawStats() {
if(nohud || stereo::mode == stereo::sLR) return; if(nohud || vid.stereo_mode == sLR) return;
if(callhandlers(false, hooks_prestats)) return; if(callhandlers(false, hooks_prestats)) return;
if(viewdists && show_distance_lists) if(viewdists && show_distance_lists)
expansion.view_distances_dialog(); expansion.view_distances_dialog();
if(sidescreen) return; if(current_display->sidescreen) return;
{ {
dynamicval<eModel> pm(pmodel, mdDisk); dynamicval<eModel> pm(pmodel, mdDisk);
dynamicval<videopar> v(vid, vid); dynamicval<videopar> v(vid, vid);
vid.alpha = vid.scale = 1; vid.alpha = vid.scale = 1;
calcparam(); calcparam();
stereo::set_projection(0, false); current_display->set_projection(0, false);
if(haveMobileCompass()) { if(haveMobileCompass()) {
initquickqueue(); initquickqueue();
@@ -476,7 +476,7 @@ void drawStats() {
} }
} }
} }
calcparam(); stereo::set_projection(0, false); calcparam(); current_display->set_projection(0, false);
string s0; string s0;
if(!peace::on) { if(!peace::on) {

83
hyper.h
View File

@@ -950,7 +950,7 @@ void drawCircle(int x, int y, int size, color_t color, color_t fillcolor = 0);
void fixcolor(int& col); void fixcolor(int& col);
ld displayspin(cell *c, int d); ld displayspin(cell *c, int d);
hyperpoint gethyper(ld x, ld y); hyperpoint gethyper(ld x, ld y);
void resetview(); extern heptspin viewctr; extern cellwalker centerover; void resetview();
void drawthemap(); void drawthemap();
void drawfullmap(); void drawfullmap();
extern function<void()> wrap_drawfullmap; extern function<void()> wrap_drawfullmap;
@@ -985,6 +985,8 @@ extern reaction_t help_delegate;
#define HELPFUN(x) (help_delegate = x, "HELPFUN") #define HELPFUN(x) (help_delegate = x, "HELPFUN")
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
struct videopar { struct videopar {
ld scale, alpha, sspeed, mspeed, yshift, camera_angle; ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch, binary_width; ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch, binary_width;
@@ -1005,11 +1007,6 @@ struct videopar {
ld xposition, yposition; ld xposition, yposition;
// paramaters calculated from the above
int xcenter, ycenter;
ld radius;
int scrsize;
bool grid; bool grid;
int particles; int particles;
@@ -1058,6 +1055,11 @@ struct videopar {
int cells_drawn_limit; int cells_drawn_limit;
ld skiprope; ld skiprope;
eStereo stereo_mode;
ld ipd;
ld lr_eyewidth, anaglyph_eyewidth;
ld fov;
}; };
extern videopar vid; extern videopar vid;
@@ -1068,8 +1070,43 @@ template<class T> void pushScreen(const T& x) { screens.push_back(x); }
inline void popScreen() { screens.pop_back(); } inline void popScreen() { screens.pop_back(); }
inline void popScreenAll() { while(isize(screens)>1) popScreen(); } inline void popScreenAll() { while(isize(screens)>1) popScreen(); }
extern transmatrix View; // current rotation, relative to viewctr struct display_data {
extern transmatrix cwtV; // player-relative view transmatrix view_matrix; // current rotation, relative to viewctr
transmatrix player_matrix; // player-relative view
heptspin view_center;
cellwalker precise_center;
unordered_map<cell*, transmatrix> cellmatrices, old_cellmatrices;
ld xmin, ymin, xmax, ymax;
display_data() { xmin = ymin = 0; xmax = ymax = 1; }
// paramaters calculated from the above
int xcenter, ycenter;
ld radius;
int scrsize;
bool sidescreen;
ld tanfov;
GLfloat scrdist, scrdist_text;
ld eyewidth();
bool stereo_active();
bool in_anaglyph();
void set_viewport(int ed);
void set_projection(int ed, bool apply_models);
void set_mask(int ed);
};
extern display_data default_display;
extern display_data *current_display;
#define View (current_display->view_matrix)
#define cwtV (current_display->player_matrix)
#define viewctr (current_display->view_center)
#define centerover (current_display->precise_center)
#define gmatrix (current_display->cellmatrices)
#define gmatrix0 (current_display->old_cellmatrices)
extern cell *mouseover, *mouseover2, *lmouseover; extern cell *mouseover, *mouseover2, *lmouseover;
extern string mouseovers; extern string mouseovers;
@@ -1866,7 +1903,6 @@ struct animation {
#define LAYER_BOAT 2 // mark that a boat has moved #define LAYER_BOAT 2 // mark that a boat has moved
extern map<cell*, animation> animations[ANIMLAYERS]; extern map<cell*, animation> animations[ANIMLAYERS];
extern unordered_map<cell*, transmatrix> gmatrix, gmatrix0;
void animateAttack(cell *src, cell *tgt, int layer, int direction_hint); void animateAttack(cell *src, cell *tgt, int layer, int direction_hint);
@@ -2375,7 +2411,6 @@ void buildHelpText();
void buildCredits(); void buildCredits();
void setAppropriateOverview(); void setAppropriateOverview();
bool quitsaves(); bool quitsaves();
extern bool sidescreen;
extern const char* COLORBAR; extern const char* COLORBAR;
@@ -3292,25 +3327,6 @@ struct resetbuffer {
void reset(); void reset();
}; };
namespace stereo {
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
extern eStereo mode;
extern ld ipd;
extern ld lr_eyewidth, anaglyph_eyewidth;
extern ld fov, tanfov;
extern GLfloat scrdist, scrdist_text;
ld eyewidth();
bool active();
bool in_anaglyph();
void set_viewport(int ed);
void set_projection(int ed, bool apply_models);
void set_mask(int ed);
}
double randd(); double randd();
#if CAP_ORIENTATION #if CAP_ORIENTATION
@@ -3649,7 +3665,7 @@ namespace glhr {
colored_vertex(GLfloat x, GLfloat y, GLfloat r, GLfloat g, GLfloat b) { colored_vertex(GLfloat x, GLfloat y, GLfloat r, GLfloat g, GLfloat b) {
coords[0] = x; coords[0] = x;
coords[1] = y; coords[1] = y;
coords[2] = stereo::scrdist; coords[2] = current_display->scrdist;
color[0] = r; color[0] = r;
color[1] = g; color[1] = g;
color[2] = b; color[2] = b;
@@ -4372,6 +4388,13 @@ namespace dq {
void enqueue(heptagon *h, const transmatrix& T); void enqueue(heptagon *h, const transmatrix& T);
} }
typedef pair<string, reaction_t> named_functionality;
inline named_functionality named_dialog(string x, reaction_t dialog) { return named_functionality(x, [dialog] () { pushScreen(dialog); }); }
extern hookset<named_functionality()> *hooks_o_key;
named_functionality get_o_key();
bool do_draw(cell *c, const transmatrix& T); bool do_draw(cell *c, const transmatrix& T);
} }

View File

@@ -69,8 +69,8 @@ hyperpoint space_to_perspective(hyperpoint z, ld alpha) {
hyperpoint gethyper(ld x, ld y) { hyperpoint gethyper(ld x, ld y) {
ld hx = (x - vid.xcenter) / vid.radius; ld hx = (x - current_display->xcenter) / current_display->radius;
ld hy = (y - vid.ycenter) / vid.radius / vid.stretch; ld hy = (y - current_display->ycenter) / current_display->radius / vid.stretch;
if(pmodel) { if(pmodel) {
ghx = hx, ghy = hy; ghx = hx, ghy = hy;
@@ -101,11 +101,11 @@ void apply_depth(hyperpoint &f, ld z) {
if(vid.usingGL) if(vid.usingGL)
f[2] = z; f[2] = z;
else { else {
z = z * vid.radius; z = z * current_display->radius;
ld mul = stereo::scrdist / (stereo::scrdist + z); ld mul = current_display->scrdist / (current_display->scrdist + z);
f[0] = f[0] * mul; f[0] = f[0] * mul;
f[1] = f[1] * mul; f[1] = f[1] * mul;
f[2] = vid.xres * stereo::eyewidth() / 2 / vid.radius + stereo::ipd * mul / 2; f[2] = vid.xres * current_display->eyewidth() / 2 / current_display->radius + vid.ipd * mul / 2;
} }
} }
@@ -175,7 +175,7 @@ template<class T> void makeband(hyperpoint H, hyperpoint& ret, const T& f) {
ld yzf = y * zf; y *= yf; ld yzf = y * zf; y *= yf;
conformal::apply_orientation(y, x); conformal::apply_orientation(y, x);
ret = hpxyz(x / M_PI, y / M_PI, 0); ret = hpxyz(x / M_PI, y / M_PI, 0);
if(zlev != 1 && stereo::active()) if(zlev != 1 && current_display->stereo_active())
apply_depth(ret, yzf / M_PI); apply_depth(ret, yzf / M_PI);
return; return;
} }
@@ -231,7 +231,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
switch(pmodel) { switch(pmodel) {
case mdUnchanged: case mdUnchanged:
ret = H / vid.radius; ret = H / current_display->radius;
return; return;
case mdBall: { case mdBall: {
@@ -248,7 +248,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
if(!vid.camera_angle) { if(!vid.camera_angle) {
ret[0] = H[0] / tz; ret[0] = H[0] / tz;
ret[1] = H[1] / tz; ret[1] = H[1] / tz;
ret[2] = vid.xres * stereo::eyewidth() / 2 / vid.radius - stereo::ipd / tz / 2; ret[2] = vid.xres * current_display->eyewidth() / 2 / current_display->radius - vid.ipd / tz / 2;
} }
else { else {
ld tx = H[0]; ld tx = H[0];
@@ -259,7 +259,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
ld ux = tx, uy = ty * cc - ss * tz, uz = tz * cc + ss * ty; ld ux = tx, uy = ty * cc - ss * tz, uz = tz * cc + ss * ty;
ret[0] = ux / uz; ret[0] = ux / uz;
ret[1] = uy / uz; ret[1] = uy / uz;
ret[2] = vid.xres * stereo::eyewidth() / 2 / vid.radius - stereo::ipd / uz / 2; ret[2] = vid.xres * current_display->eyewidth() / 2 / current_display->radius - vid.ipd / uz / 2;
} }
return; return;
} }
@@ -292,7 +292,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
} }
ret[1] = conformal::ocos + H[1]; ret[1] = conformal::ocos + H[1];
ret[2] = 0; ret[2] = 0;
if(zlev != 1 && stereo::active()) if(zlev != 1 && current_display->stereo_active())
apply_depth(ret, -H[1] * geom3::factor_to_lev(zlev)); apply_depth(ret, -H[1] * geom3::factor_to_lev(zlev));
break; break;
} }
@@ -510,7 +510,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
ret = H * (d * df / rad / M_PI); ret = H * (d * df / rad / M_PI);
ret[2] = 0; ret[2] = 0;
if(zlev != 1 && stereo::active()) if(zlev != 1 && current_display->stereo_active())
apply_depth(ret, d * zf / M_PI); apply_depth(ret, d * zf / M_PI);
break; break;
@@ -577,10 +577,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
// game-related graphics // game-related graphics
transmatrix View; // current rotation, relative to viewctr
transmatrix cwtV = Id; // player-relative view
transmatrix sphereflip; // on the sphere, flip transmatrix sphereflip; // on the sphere, flip
heptspin viewctr; // heptagon and rotation where the view is centered at
bool playerfound; // has player been found in the last drawing? bool playerfound; // has player been found in the last drawing?
#define eurad crossf #define eurad crossf
@@ -695,19 +692,19 @@ bool in_smart_range(const transmatrix& T) {
applymodel(tC0(T), h1); applymodel(tC0(T), h1);
if(std::isnan(h1[0]) || std::isnan(h1[1])) return false; if(std::isnan(h1[0]) || std::isnan(h1[1])) return false;
if(std::isinf(h1[0]) || std::isinf(h1[1])) return false; if(std::isinf(h1[0]) || std::isinf(h1[1])) return false;
ld x = vid.xcenter + vid.radius * h1[0]; ld x = current_display->xcenter + current_display->radius * h1[0];
ld y = vid.ycenter + vid.radius * h1[1] * vid.stretch; ld y = current_display->ycenter + current_display->radius * h1[1] * vid.stretch;
if(x > vid.xres * 2) return false; if(x > vid.xres * 2) return false;
if(x < -vid.xres) return false; if(x < -vid.xres) return false;
if(y > vid.yres * 2) return false; if(y > vid.yres * 2) return false;
if(y < -vid.yres) return false; if(y < -vid.yres) return false;
ld epsilon = 0.01; ld epsilon = 0.01;
applymodel(T * xpush0(epsilon), h2); applymodel(T * xpush0(epsilon), h2);
ld x1 = vid.radius * abs(h2[0] - h1[0]) / epsilon; ld x1 = current_display->radius * abs(h2[0] - h1[0]) / epsilon;
ld y1 = vid.radius * abs(h2[1] - h1[1]) * vid.stretch / epsilon; ld y1 = current_display->radius * abs(h2[1] - h1[1]) * vid.stretch / epsilon;
applymodel(T * ypush(epsilon) * C0, h3); applymodel(T * ypush(epsilon) * C0, h3);
ld x2 = vid.radius * abs(h3[0] - h1[0]) / epsilon; ld x2 = current_display->radius * abs(h3[0] - h1[0]) / epsilon;
ld y2 = vid.radius * abs(h3[1] - h1[1]) * vid.stretch / epsilon; ld y2 = current_display->radius * abs(h3[1] - h1[1]) * vid.stretch / epsilon;
ld scale = sqrt(hypot(x1, y1) * hypot(x2, y2)) * scalefactor * hcrossf7; ld scale = sqrt(hypot(x1, y1) * hypot(x2, y2)) * scalefactor * hcrossf7;
if(svg::in) scale /= svg::divby; if(svg::in) scale /= svg::divby;
return return
@@ -1036,7 +1033,7 @@ void optimizeview() {
void addball(ld a, ld b, ld c) { void addball(ld a, ld b, ld c) {
hyperpoint h; hyperpoint h;
ballmodel(h, a, b, c); ballmodel(h, a, b, c);
for(int i=0; i<3; i++) h[i] *= vid.radius; for(int i=0; i<3; i++) h[i] *= current_display->radius;
curvepoint(h); curvepoint(h);
} }
@@ -1093,19 +1090,19 @@ void fullcenter() {
transmatrix screenpos(ld x, ld y) { transmatrix screenpos(ld x, ld y) {
transmatrix V = Id; transmatrix V = Id;
V[0][2] += (x - vid.xcenter) / vid.radius * (1+vid.alpha); V[0][2] += (x - current_display->xcenter) / current_display->radius * (1+vid.alpha);
V[1][2] += (y - vid.ycenter) / vid.radius * (1+vid.alpha); V[1][2] += (y - current_display->ycenter) / current_display->radius * (1+vid.alpha);
return V; return V;
} }
transmatrix atscreenpos(ld x, ld y, ld size) { transmatrix atscreenpos(ld x, ld y, ld size) {
transmatrix V = Id; transmatrix V = Id;
V[0][2] += (x - vid.xcenter); V[0][2] += (x - current_display->xcenter);
V[1][2] += (y - vid.ycenter); V[1][2] += (y - current_display->ycenter);
V[0][0] = size * 2 * hcrossf / crossf; V[0][0] = size * 2 * hcrossf / crossf;
V[1][1] = size * 2 * hcrossf / crossf; V[1][1] = size * 2 * hcrossf / crossf;
V[2][2] = stereo::scrdist; V[2][2] = current_display->scrdist;
return V; return V;
} }
@@ -1115,7 +1112,7 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio)
hyperpoint ret; hyperpoint ret;
applymodel(xpush0(radius), ret); applymodel(xpush0(radius), ret);
ld r = hypot2(ret); ld r = hypot2(ret);
queuecircle(vid.xcenter, vid.ycenter, r * vid.radius, linecol, prio, fillcol); queuecircle(current_display->xcenter, current_display->ycenter, r * current_display->radius, linecol, prio, fillcol);
return; return;
} }
for(int i=0; i<=360; i++) curvepoint(xspinpush0(i * degree, 10)); for(int i=0; i<=360; i++) curvepoint(xspinpush0(i * degree, 10));
@@ -1143,7 +1140,7 @@ void draw_model_elements() {
} }
case mdBall: { case mdBall: {
queuecircle(vid.xcenter, vid.ycenter, vid.radius, ringcolor, PPR::OUTCIRCLE, modelcolor); queuecircle(current_display->xcenter, current_display->ycenter, current_display->radius, ringcolor, PPR::OUTCIRCLE, modelcolor);
ballgeometry(); ballgeometry();
return; return;
} }
@@ -1200,7 +1197,7 @@ void queuestraight(hyperpoint X, int style, color_t lc, color_t fc, PPR p) {
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
hyperpoint H; hyperpoint H;
applymodel(X, H); applymodel(X, H);
H *= vid.radius; H *= current_display->radius;
ld mul = hypot(vid.xres, vid.yres) / hypot2(H); ld mul = hypot(vid.xres, vid.yres) / hypot2(H);
ld m = style == 1 ? -mul : -1; ld m = style == 1 ? -mul : -1;
@@ -1242,7 +1239,7 @@ void draw_boundary(int w) {
switch(pmodel) { switch(pmodel) {
case mdTwoPoint: { case mdTwoPoint: {
if(twopoint_do_flips || stereo::active() || !sphere) return; if(twopoint_do_flips || current_display->stereo_active() || !sphere) return;
queuereset(vid.usingGL ? mdDisk : mdUnchanged, p); queuereset(vid.usingGL ? mdDisk : mdUnchanged, p);
for(int b=-1; b<=1; b+=2) for(int b=-1; b<=1; b+=2)
@@ -1303,7 +1300,7 @@ void draw_boundary(int w) {
queuereset(mdUnchanged, p); queuereset(mdUnchanged, p);
for(int i=0; i<=360; i++) { for(int i=0; i<=360; i++) {
ld s = sin(i * degree); ld s = sin(i * degree);
curvepoint(hpxyz(vid.radius * cos(i * degree), vid.radius * s * (conformal::cos_ball * s >= 0 - 1e-6 ? 1 : abs(conformal::sin_ball)), 0)); curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * s * (conformal::cos_ball * s >= 0 - 1e-6 ? 1 : abs(conformal::sin_ball)), 0));
} }
queuecurve(lc, fc, p); queuecurve(lc, fc, p);
queuereset(pmodel, p); queuereset(pmodel, p);
@@ -1312,7 +1309,7 @@ void draw_boundary(int w) {
for(int i=0; i<=360; i++) { for(int i=0; i<=360; i++) {
ld s = sin(i * degree); ld s = sin(i * degree);
curvepoint(hpxyz(vid.radius * cos(i * degree), vid.radius * s * conformal::sin_ball, 0)); curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * s * conformal::sin_ball, 0));
} }
queuecurve(lc, fc, p); queuecurve(lc, fc, p);
queuereset(pmodel, p); queuereset(pmodel, p);
@@ -1320,7 +1317,7 @@ void draw_boundary(int w) {
if(euclid || sphere) { if(euclid || sphere) {
queuereset(mdUnchanged, p); queuereset(mdUnchanged, p);
for(int i=0; i<=360; i++) { for(int i=0; i<=360; i++) {
curvepoint(hpxyz(vid.radius * cos(i * degree), vid.radius * sin(i * degree), 0)); curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * sin(i * degree), 0));
} }
queuecurve(lc, fc, p); queuecurve(lc, fc, p);
queuereset(pmodel, p); queuereset(pmodel, p);
@@ -1392,7 +1389,7 @@ void draw_boundary(int w) {
cld z = exp(cld(a, a * imag(sm) / real(sm) + M_PI)); cld z = exp(cld(a, a * imag(sm) / real(sm) + M_PI));
hyperpoint ret = hpxyz(real(z), imag(z), 0); hyperpoint ret = hpxyz(real(z), imag(z), 0);
ret = mobius(ret, vid.skiprope, 1); ret = mobius(ret, vid.skiprope, 1);
ret *= vid.radius; ret *= current_display->radius;
curvepoint(ret); curvepoint(ret);
} }
queuecurve(ringcolor, 0, p).flags |= POLY_ALWAYS_IN; queuecurve(ringcolor, 0, p).flags |= POLY_ALWAYS_IN;
@@ -1405,8 +1402,8 @@ void draw_boundary(int w) {
} }
if(sphere && pmodel == mdDisk && vid.alpha > 1) { if(sphere && pmodel == mdDisk && vid.alpha > 1) {
double rad = vid.radius / sqrt(vid.alpha*vid.alpha - 1); double rad = current_display->radius / sqrt(vid.alpha*vid.alpha - 1);
queuecircle(vid.xcenter, vid.ycenter, rad, lc, p, fc); queuecircle(current_display->xcenter, current_display->ycenter, rad, lc, p, fc);
return; return;
} }

View File

@@ -158,8 +158,8 @@ void handleclick(MOBPAR_FORMAL) {
} }
else if(getcstat != SDLK_F1 && getcstat != 'i' && getcstat != 't') { else if(getcstat != SDLK_F1 && getcstat != 'i' && getcstat != 't') {
int px = mousex < vid.xcenter ? 0 : 1; int px = mousex < current_display->xcenter ? 0 : 1;
int py = mousey < vid.ycenter ? 0 : 1; int py = mousey < current_display->ycenter ? 0 : 1;
if(isize(screens) == 1) { if(isize(screens) == 1) {
if(px == 0 && py == 1) { if(px == 0 && py == 1) {
@@ -296,7 +296,7 @@ void mobile_draw(MOBPAR_FORMAL) {
inmenu = isize(screens) > 1; inmenu = isize(screens) > 1;
if(!inmenu && stereo::mode == stereo::sLR && ors::mode) if(!inmenu && vid.stereo_mode == sLR && ors::mode)
mousex = vid.xres/2, mousey = vid.yres/2, mouseh = sphereflip * C0; mousex = vid.xres/2, mousey = vid.yres/2, mouseh = sphereflip * C0;
// if(debfile) fprintf(debfile, "d1\n"), fflush(debfile); // if(debfile) fprintf(debfile, "d1\n"), fflush(debfile);
@@ -341,7 +341,7 @@ void mobile_draw(MOBPAR_FORMAL) {
bool normal_reaction = !inmenu; bool normal_reaction = !inmenu;
if(normal_reaction && stereo::mode == stereo::sLR) { if(normal_reaction && vid.stereo_mode == sLR) {
normal_reaction = false; normal_reaction = false;
if(lclicked && !clicked) { if(lclicked && !clicked) {
if(rug::rugged) if(rug::rugged)

View File

@@ -475,8 +475,8 @@ namespace hr { namespace inv {
dialog::addSelItem(XLAT1(iinf[o].name), its(remaining[i]), c); dialog::addSelItem(XLAT1(iinf[o].name), its(remaining[i]), c);
else { else {
auto pos = orbcoord[oc++]; auto pos = orbcoord[oc++];
ld px = vid.xcenter + 2*rad*pos.first + rad*pos.second; ld px = current_display->xcenter + 2*rad*pos.first + rad*pos.second;
ld py = vid.ycenter + pos.second * rad3; ld py = current_display->ycenter + pos.second * rad3;
int icol = iinf[o].color; int icol = iinf[o].color;
if(!remaining[i]) icol = gradient(icol, 0, 0, .5, 1); if(!remaining[i]) icol = gradient(icol, 0, 0, .5, 1);
bool gg = graphglyph(); bool gg = graphglyph();

View File

@@ -23,12 +23,12 @@ namespace mapeditor {
// mx = xb + ssiz*xpos + mrx * scale // mx = xb + ssiz*xpos + mrx * scale
// mx = xb + ssiz*xpos' + mrx * scale' // mx = xb + ssiz*xpos' + mrx * scale'
ld mrx = (.0 + mousex - vid.xcenter) / vid.scale; ld mrx = (.0 + mousex - current_display->xcenter) / vid.scale;
ld mry = (.0 + mousey - vid.ycenter) / vid.scale; ld mry = (.0 + mousey - current_display->ycenter) / vid.scale;
if(vid.xres > vid.yres) { if(vid.xres > vid.yres) {
vid.xposition += (vid.scale - vid.scale*z) * mrx / vid.scrsize; vid.xposition += (vid.scale - vid.scale*z) * mrx / current_display->scrsize;
vid.yposition += (vid.scale - vid.scale*z) * mry / vid.scrsize; vid.yposition += (vid.scale - vid.scale*z) * mry / current_display->scrsize;
} }
vid.scale *= z; vid.scale *= z;

View File

@@ -222,7 +222,7 @@ void showMainMenu() {
else else
q = "game over screen"; q = "game over screen";
dialog::addItem(XLAT(q), SDLK_ESCAPE); dialog::addItem(XLAT(q), SDLK_ESCAPE);
dialog::addItem(XLAT("world overview"), 'o'); dialog::addItem(get_o_key().first, 'o');
if(inv::on) if(inv::on)
dialog::addItem(XLAT("inventory"), 'i'); dialog::addItem(XLAT("inventory"), 'i');
@@ -272,7 +272,7 @@ void showMainMenu() {
} }
else if(sym == 'o') { else if(sym == 'o') {
clearMessages(); clearMessages();
setAppropriateOverview(); get_o_key().second();
} }
#if CAP_INV #if CAP_INV
else if(sym == 'i') { else if(sym == 'i') {
@@ -813,29 +813,40 @@ void showStartMenu() {
// -- overview -- // -- overview --
void setAppropriateOverview() { hookset<named_functionality()> *hooks_o_key;
clearMessages();
if(daily::on) { named_functionality get_o_key() {
if(hooks_o_key) for(auto& h: *hooks_o_key) {
auto res = h.second();
if(res.first != "") return res;
}
#if CAP_DAILY #if CAP_DAILY
achievement_final(false); if(daily::on)
pushScreen(daily::showMenu); return named_functionality(XLAT("Strange Challenge"), [] () {
achievement_final(false);
pushScreen(daily::showMenu);
});
#endif #endif
}
else if(viewdists) if(viewdists)
runGeometryExperiments(); return named_functionality(XLAT("geometry experiments"), runGeometryExperiments);
else if(tactic::on)
pushScreen(tactic::showMenu); if(tactic::on)
else if(yendor::on) return named_dialog(XLAT("Pure Tactics mode"), tactic::showMenu);
pushScreen(yendor::showMenu);
else if(peace::on) if(yendor::on)
pushScreen(peace::showMenu); return named_dialog(XLAT("Yendor Challenge"), yendor::showMenu);
else if((geometry != gNormal || NONSTDVAR) && !chaosmode && !(geometry == gEuclid && isCrossroads(specialland)) && !(weirdhyperbolic && specialland == laCrossroads4)) {
runGeometryExperiments(); if(peace::on)
} return named_dialog(XLAT("peaceful mode"), peace::showMenu);
else {
dialog::infix = ""; if((geometry != gNormal || NONSTDVAR) && !chaosmode && !(geometry == gEuclid && isCrossroads(specialland)) && !(weirdhyperbolic && specialland == laCrossroads4))
pushScreen(showOverview); return named_functionality(XLAT("geometry experiments"), runGeometryExperiments);
}
dialog::infix = "";
return named_dialog(XLAT("world overview"), showOverview);
} }
int messagelogpos; int messagelogpos;

View File

@@ -238,12 +238,12 @@ void fixpoint(array<float, 3>& hscr, hyperpoint H) {
} }
hyperpoint Hscr; hyperpoint Hscr;
applymodel(good, Hscr); applymodel(good, Hscr);
hscr = make_array<GLfloat>(Hscr[0]*vid.radius, Hscr[1]*vid.radius*vid.stretch, Hscr[2]*vid.radius); hscr = make_array<GLfloat>(Hscr[0]*current_display->radius, Hscr[1]*current_display->radius*vid.stretch, Hscr[2]*current_display->radius);
} }
void addpoint(const hyperpoint& H) { void addpoint(const hyperpoint& H) {
if(true) { if(true) {
ld z = vid.radius; ld z = current_display->radius;
// if(vid.alpha + H[2] <= BEHIND_LIMIT && pmodel == mdDisk) poly_flags |= POLY_BEHIND; // if(vid.alpha + H[2] <= BEHIND_LIMIT && pmodel == mdDisk) poly_flags |= POLY_BEHIND;
if(spherespecial) { if(spherespecial) {
@@ -284,11 +284,11 @@ void coords_to_poly() {
polyi = isize(glcoords); polyi = isize(glcoords);
for(int i=0; i<polyi; i++) { for(int i=0; i<polyi; i++) {
// printf("%lf %lf\n", double(glcoords[i][0]), double(glcoords[i][1])); // printf("%lf %lf\n", double(glcoords[i][0]), double(glcoords[i][1]));
if(!stereo::active()) glcoords[i][2] = 0; if(!current_display->stereo_active()) glcoords[i][2] = 0;
polyx[i] = vid.xcenter + glcoords[i][0] - glcoords[i][2]; polyx[i] = current_display->xcenter + glcoords[i][0] - glcoords[i][2];
polyxr[i] = vid.xcenter + glcoords[i][0] + glcoords[i][2]; polyxr[i] = current_display->xcenter + glcoords[i][0] + glcoords[i][2];
polyy[i] = vid.ycenter + glcoords[i][1]; polyy[i] = current_display->ycenter + glcoords[i][1];
} }
} }
@@ -335,11 +335,11 @@ void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt
/* /*
hyperpoint Hscr; hyperpoint Hscr;
applymodel(goodpoint, Hscr); applymodel(goodpoint, Hscr);
glcoords.push_back(make_array<GLfloat>(Hscr[0]*vid.radius+10, Hscr[1]*vid.radius*vid.stretch, Hscr[2]*vid.radius)); glcoords.push_back(make_array<GLfloat>(Hscr[0]*current_display->radius+10, Hscr[1]*current_display->radius*vid.stretch, Hscr[2]*vid.radius));
glcoords.push_back(make_array<GLfloat>(Hscr[0]*vid.radius, Hscr[1]*vid.radius*vid.stretch+10, Hscr[2]*vid.radius)); glcoords.push_back(make_array<GLfloat>(Hscr[0]*current_display->radius, Hscr[1]*current_display->radius*vid.stretch+10, Hscr[2]*vid.radius));
glcoords.push_back(make_array<GLfloat>(Hscr[0]*vid.radius-10, Hscr[1]*vid.radius*vid.stretch, Hscr[2]*vid.radius)); glcoords.push_back(make_array<GLfloat>(Hscr[0]*current_display->radius-10, Hscr[1]*current_display->radius*vid.stretch, Hscr[2]*vid.radius));
glcoords.push_back(make_array<GLfloat>(Hscr[0]*vid.radius, Hscr[1]*vid.radius*vid.stretch-10, Hscr[2]*vid.radius)); glcoords.push_back(make_array<GLfloat>(Hscr[0]*current_display->radius, Hscr[1]*current_display->radius*vid.stretch-10, Hscr[2]*vid.radius));
glcoords.push_back(make_array<GLfloat>(Hscr[0]*vid.radius+10, Hscr[1]*vid.radius*vid.stretch, Hscr[2]*vid.radius)); */ glcoords.push_back(make_array<GLfloat>(Hscr[0]*current_display->radius+10, Hscr[1]*current_display->radius*vid.stretch, Hscr[2]*vid.radius)); */
} }
} }
@@ -439,17 +439,17 @@ void glflush() {
if(isize(text_vertices)) { if(isize(text_vertices)) {
// printf("%08X | %d texts, %d vertices\n", text_color, texts_merged, isize(text_vertices)); // printf("%08X | %d texts, %d vertices\n", text_color, texts_merged, isize(text_vertices));
stereo::set_projection(0, false); current_display->set_projection(0, false);
glhr::be_textured(); glhr::be_textured();
glBindTexture(GL_TEXTURE_2D, text_texture); glBindTexture(GL_TEXTURE_2D, text_texture);
glhr::color2(text_color); glhr::color2(text_color);
glhr::set_depthtest(false); glhr::set_depthtest(false);
for(int ed = (stereo::active() && text_shift)?-1:0; ed<2; ed+=2) { for(int ed = (current_display->stereo_active() && text_shift)?-1:0; ed<2; ed+=2) {
if(vid.scale < 0) if(vid.scale < 0)
glhr::set_modelview(glhr::translate(-ed*text_shift-vid.xcenter,-vid.ycenter, stereo::scrdist_text) * glhr::scale(-1,-1,-1)); glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text) * glhr::scale(-1,-1,-1));
else else
glhr::set_modelview(glhr::translate(-ed*text_shift-vid.xcenter,-vid.ycenter, stereo::scrdist_text)); glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text));
stereo::set_mask(ed); current_display->set_mask(ed);
glhr::current_vertices = NULL; glhr::current_vertices = NULL;
glhr::prepare(text_vertices); glhr::prepare(text_vertices);
@@ -458,7 +458,7 @@ void glflush() {
GLERR("print"); GLERR("print");
} }
if(stereo::active() && text_shift) stereo::set_mask(0); if(current_display->stereo_active() && text_shift) current_display->set_mask(0);
texts_merged = 0; texts_merged = 0;
text_vertices.clear(); text_vertices.clear();
@@ -491,7 +491,7 @@ void dqi_poly::gldraw() {
auto& v = *tab; auto& v = *tab;
#if MINIMIZE_GL_CALLS #if MINIMIZE_GL_CALLS
if(stereo::active() == 0 && !tinf && (color == 0 || ((flags & (POLY_VCONVEX | POLY_CCONVEX)) && !(flags & (POLY_INVERSE | POLY_FORCE_INVERTED))))) { if(current_display->stereo_active() == 0 && !tinf && (color == 0 || ((flags & (POLY_VCONVEX | POLY_CCONVEX)) && !(flags & (POLY_INVERSE | POLY_FORCE_INVERTED))))) {
if(color != triangle_color || outline != line_color || texts_merged) { if(color != triangle_color || outline != line_color || texts_merged) {
glflush(); glflush();
triangle_color = color; triangle_color = color;
@@ -539,8 +539,8 @@ void dqi_poly::gldraw() {
#endif #endif
} }
for(int ed = stereo::active() ? -1 : 0; ed<2; ed+=2) { for(int ed = current_display->stereo_active() ? -1 : 0; ed<2; ed+=2) {
if(ed) stereo::set_projection(ed, true), stereo::set_viewport(ed); if(ed) current_display->set_projection(ed, true), current_display->set_viewport(ed);
bool draw = color; bool draw = color;
if(shaderside_projection) { if(shaderside_projection) {
@@ -559,7 +559,7 @@ void dqi_poly::gldraw() {
glhr::color2(0xFFFFFFFF); glhr::color2(0xFFFFFFFF);
glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset, cnt); glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset, cnt);
stereo::set_mask(ed); current_display->set_mask(ed);
glhr::color2(color); glhr::color2(color);
glhr::set_depthtest(model_needs_depth()); glhr::set_depthtest(model_needs_depth());
@@ -568,7 +568,7 @@ void dqi_poly::gldraw() {
glStencilFunc( GL_NOTEQUAL, 1, 1); glStencilFunc( GL_NOTEQUAL, 1, 1);
GLfloat xx = vid.xres; GLfloat xx = vid.xres;
GLfloat yy = vid.yres; GLfloat yy = vid.yres;
GLfloat dist = shaderside_projection ? stereo::scrdist : 0; GLfloat dist = shaderside_projection ? current_display->scrdist : 0;
vector<glvertex> scr = { vector<glvertex> scr = {
make_array<GLfloat>(-xx, -yy, dist), make_array<GLfloat>(-xx, -yy, dist),
make_array<GLfloat>(+xx, -yy, dist), make_array<GLfloat>(+xx, -yy, dist),
@@ -603,7 +603,7 @@ void dqi_poly::gldraw() {
} }
} }
if(stereo::active()) stereo::set_projection(0, true), stereo::set_viewport(0), stereo::set_mask(0); if(current_display->stereo_active()) current_display->set_projection(0, true), current_display->set_viewport(0), current_display->set_mask(0);
} }
#endif #endif
@@ -620,7 +620,7 @@ double linewidthat(const hyperpoint& h) {
if(!(vid.antialias & AA_LINEWIDTH)) return 1; if(!(vid.antialias & AA_LINEWIDTH)) return 1;
else if(hyperbolic && pmodel == mdDisk && vid.alpha == 1) { else if(hyperbolic && pmodel == mdDisk && vid.alpha == 1) {
double dz = h[2]; double dz = h[2];
if(dz < 1 || abs(dz-stereo::scrdist) < 1e-6) return 1; if(dz < 1 || abs(dz-current_display->scrdist) < 1e-6) return 1;
else { else {
double dx = sqrt(dz * dz - 1); double dx = sqrt(dz * dz - 1);
double dfc = dx/(dz+1); double dfc = dx/(dz+1);
@@ -646,9 +646,9 @@ ld mercator_period;
void fixMercator(bool tinf) { void fixMercator(bool tinf) {
if(pmodel == mdBand) if(pmodel == mdBand)
mercator_period = 4 * vid.radius; mercator_period = 4 * current_display->radius;
else else
mercator_period = 2 * vid.radius; mercator_period = 2 * current_display->radius;
if(!conformal::model_straight) if(!conformal::model_straight)
for(auto& g: glcoords) for(auto& g: glcoords)
@@ -656,7 +656,7 @@ void fixMercator(bool tinf) {
if(pmodel == mdSinusoidal) if(pmodel == mdSinusoidal)
for(int i = 0; i<isize(glcoords); i++) for(int i = 0; i<isize(glcoords); i++)
glcoords[i][mercator_coord] /= cos(glcoords[i][1] / vid.radius / vid.stretch * M_PI); glcoords[i][mercator_coord] /= cos(glcoords[i][1] / current_display->radius / vid.stretch * M_PI);
ld hperiod = mercator_period / 2; ld hperiod = mercator_period / 2;
@@ -664,18 +664,18 @@ void fixMercator(bool tinf) {
auto dist = [] (ld a, ld b) { return max(b, a-b); }; auto dist = [] (ld a, ld b) { return max(b, a-b); };
ld chypot = hypot(dist(vid.xres, vid.xcenter), dist(vid.yres, vid.ycenter)); ld chypot = hypot(dist(vid.xres, current_display->xcenter), dist(vid.yres, current_display->ycenter));
ld cmin = -chypot/2, cmax = chypot/2, dmin = -chypot, dmax = chypot; ld cmin = -chypot/2, cmax = chypot/2, dmin = -chypot, dmax = chypot;
if(mercator_coord) if(mercator_coord)
swap(cmin, dmin), swap(cmax, dmax); swap(cmin, dmin), swap(cmax, dmax);
if(pmodel == mdSinusoidal) if(pmodel == mdSinusoidal)
dmin = -vid.stretch * vid.radius / 2, dmax = vid.stretch * vid.radius / 2; dmin = -vid.stretch * current_display->radius / 2, dmax = vid.stretch * current_display->radius / 2;
if(pmodel == mdBandEquidistant) if(pmodel == mdBandEquidistant)
dmin = -vid.stretch * vid.radius / 2, dmax = vid.stretch * vid.radius / 2; dmin = -vid.stretch * current_display->radius / 2, dmax = vid.stretch * current_display->radius / 2;
if(pmodel == mdBandEquiarea) if(pmodel == mdBandEquiarea)
dmin = -vid.stretch * vid.radius / M_PI, dmax = vid.stretch * vid.radius / M_PI; dmin = -vid.stretch * current_display->radius / M_PI, dmax = vid.stretch * current_display->radius / M_PI;
for(int i = 0; i<isize(glcoords); i++) { for(int i = 0; i<isize(glcoords); i++) {
while(glcoords[0][mercator_coord] < hperiod) glcoords[0][mercator_coord] += mercator_period; while(glcoords[0][mercator_coord] < hperiod) glcoords[0][mercator_coord] += mercator_period;
@@ -713,7 +713,7 @@ void fixMercator(bool tinf) {
mercator_loop_max++, maxcoord += mercator_period; mercator_loop_max++, maxcoord += mercator_period;
if(pmodel == mdSinusoidal) if(pmodel == mdSinusoidal)
for(int i = 0; i<isize(glcoords); i++) for(int i = 0; i<isize(glcoords); i++)
glcoords[i][mercator_coord] *= cos(glcoords[i][1] / vid.radius / vid.stretch * M_PI); glcoords[i][mercator_coord] *= cos(glcoords[i][1] / current_display->radius / vid.stretch * M_PI);
if(!conformal::model_straight) if(!conformal::model_straight)
for(auto& g: glcoords) for(auto& g: glcoords)
conformal::apply_orientation(g[1], g[0]); conformal::apply_orientation(g[1], g[0]);
@@ -743,7 +743,7 @@ void fixMercator(bool tinf) {
} }
if(pmodel == mdSinusoidal) if(pmodel == mdSinusoidal)
for(int i = 0; i<isize(glcoords); i++) for(int i = 0; i<isize(glcoords); i++)
glcoords[i][mercator_coord] *= cos(glcoords[i][1] / vid.radius / vid.stretch * M_PI); glcoords[i][mercator_coord] *= cos(glcoords[i][1] / current_display->radius / vid.stretch * M_PI);
glcoords.push_back(glcoords.back()); glcoords.push_back(glcoords.back());
glcoords.push_back(glcoords[0]); glcoords.push_back(glcoords[0]);
for(int u=1; u<=2; u++) { for(int u=1; u<=2; u++) {
@@ -783,7 +783,7 @@ void compute_side_by_centerin(dqi_poly *p, bool& nofill) {
else else
nofill = true; nofill = true;
} }
applymodel(h1, hscr); hscr[0] *= vid.radius; hscr[1] *= vid.radius * vid.stretch; applymodel(h1, hscr); hscr[0] *= current_display->radius; hscr[1] *= current_display->radius * vid.stretch;
for(int i=0; i<isize(glcoords)-1; i++) { for(int i=0; i<isize(glcoords)-1; i++) {
double x1 = glcoords[i][0] - hscr[0]; double x1 = glcoords[i][0] - hscr[0];
double y1 = glcoords[i][1] - hscr[1]; double y1 = glcoords[i][1] - hscr[1];
@@ -877,7 +877,7 @@ void dqi_poly::draw() {
twopoint_sphere_flips = j; twopoint_sphere_flips = j;
hyperpoint h2; applymodel(h1, h2); hyperpoint h2; applymodel(h1, h2);
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
glvertex h = glhr::pointtogl(h2 * vid.radius); h[1] *= vid.stretch; glvertex h = glhr::pointtogl(h2 * current_display->radius); h[1] *= vid.stretch;
if(i == 0) if(i == 0)
phases[j].push_back(h); phases[j].push_back(h);
else { else {
@@ -907,7 +907,7 @@ void dqi_poly::draw() {
hyperpoint h1 = V * glhr::gltopoint((*tab)[offset+i]); hyperpoint h1 = V * glhr::gltopoint((*tab)[offset+i]);
hyperpoint mh1; applymodel(h1, mh1); mh1[1] *= vid.stretch; hyperpoint mh1; applymodel(h1, mh1); mh1[1] *= vid.stretch;
phases[cpha].push_back(glhr::pointtogl(mh1 * vid.radius)); phases[cpha].push_back(glhr::pointtogl(mh1 * current_display->radius));
// check if the i-th edge intersects the boundary of the ellipse // check if the i-th edge intersects the boundary of the ellipse
// (which corresponds to the segment between the antipodes of foci) // (which corresponds to the segment between the antipodes of foci)
@@ -1056,7 +1056,7 @@ void dqi_poly::draw() {
if(pmodel == mdSinusoidal) { if(pmodel == mdSinusoidal) {
ld y = glcoords[i][1], x = glcoords[i][0]; ld y = glcoords[i][1], x = glcoords[i][0];
conformal::apply_orientation(x, y); conformal::apply_orientation(x, y);
mercator_period = 2 * vid.radius * cos(y / vid.radius / vid.stretch * M_PI); mercator_period = 2 * current_display->radius * cos(y / current_display->radius / vid.stretch * M_PI);
} }
glcoords[i][mercator_coord] += conformal::ocos * mercator_period * (l - lastl); glcoords[i][mercator_coord] += conformal::ocos * mercator_period * (l - lastl);
glcoords[i][1-mercator_coord] += conformal::osin * mercator_period * (l - lastl); glcoords[i][1-mercator_coord] += conformal::osin * mercator_period * (l - lastl);
@@ -1070,7 +1070,7 @@ void dqi_poly::draw() {
ld h = atan2(glcoords[0][0], glcoords[0][1]); ld h = atan2(glcoords[0][0], glcoords[0][1]);
for(int i=0; i<=360; i++) { for(int i=0; i<=360; i++) {
ld a = i * degree + h; ld a = i * degree + h;
glcoords.push_back(make_array<GLfloat>(vid.radius * sin(a), vid.radius * vid.stretch * cos(a), stereo::scrdist)); glcoords.push_back(make_array<GLfloat>(current_display->radius * sin(a), current_display->radius * vid.stretch * cos(a), current_display->scrdist));
} }
poly_flags ^= POLY_INVERSE; poly_flags ^= POLY_INVERSE;
} }
@@ -1084,7 +1084,7 @@ void dqi_poly::draw() {
#if CAP_GL #if CAP_GL
if(vid.usingGL) { if(vid.usingGL) {
poly_flags &= ~(POLY_VCONVEX | POLY_CCONVEX); poly_flags &= ~(POLY_VCONVEX | POLY_CCONVEX);
// if(pmodel == 0) for(int i=0; i<qglcoords; i++) glcoords[i][2] = stereo::scrdist; // if(pmodel == 0) for(int i=0; i<qglcoords; i++) glcoords[i][2] = current_display->scrdist;
if(tinf && (poly_flags & POLY_INVERSE)) { if(tinf && (poly_flags & POLY_INVERSE)) {
return; return;
} }
@@ -1149,10 +1149,10 @@ void dqi_poly::draw() {
else else
filledPolygonColorI(s, polyx, polyy, polyi, color); filledPolygonColorI(s, polyx, polyy, polyi, color);
if(stereo::active()) filledPolygonColorI(aux, polyxr, polyy, polyi, color); if(current_display->stereo_active()) filledPolygonColorI(aux, polyxr, polyy, polyi, color);
((vid.antialias & AA_NOGL) ?aapolylineColor:polylineColor)(s, polyx, polyy, polyi, outline); ((vid.antialias & AA_NOGL) ?aapolylineColor:polylineColor)(s, polyx, polyy, polyi, outline);
if(stereo::active()) aapolylineColor(aux, polyxr, polyy, polyi, outline); if(current_display->stereo_active()) aapolylineColor(aux, polyxr, polyy, polyi, outline);
if(vid.xres >= 2000 || fatborder) { if(vid.xres >= 2000 || fatborder) {
int xmi = 3000, xma = -3000; int xmi = 3000, xma = -3000;
@@ -1227,7 +1227,7 @@ int curvestart = 0;
bool keep_curvedata = false; bool keep_curvedata = false;
void queuereset(eModel m, PPR prio) { void queuereset(eModel m, PPR prio) {
queueaction(prio, [m] () { pmodel = m; stereo::set_projection(0, true); }); queueaction(prio, [m] () { pmodel = m; current_display->set_projection(0, true); });
} }
void dqi_line::draw() { void dqi_line::draw() {
@@ -1274,7 +1274,7 @@ void sortquickqueue() {
} }
void quickqueue() { void quickqueue() {
spherespecial = 0; stereo::set_projection(0, true); spherespecial = 0; current_display->set_projection(0, true);
int siz = isize(ptds); int siz = isize(ptds);
setcameraangle(false); setcameraangle(false);
for(int i=0; i<siz; i++) ptds[i]->draw(); for(int i=0; i<siz; i++) ptds[i]->draw();
@@ -1392,7 +1392,7 @@ void drawqueue() {
profile_stop(3); profile_stop(3);
#if CAP_SDL #if CAP_SDL
if(stereo::active() && !vid.usingGL) { if(current_display->stereo_active() && !vid.usingGL) {
if(aux && (aux->w != s->w || aux->h != s->h)) if(aux && (aux->w != s->w || aux->h != s->h))
SDL_FreeSurface(aux); SDL_FreeSurface(aux);
@@ -1410,7 +1410,7 @@ void drawqueue() {
spherespecial = 0; spherespecial = 0;
spherephase = 0; spherephase = 0;
stereo::set_projection(0, true); current_display->set_projection(0, true);
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE) for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE)
ptd->draw(); ptd->draw();
@@ -1426,7 +1426,7 @@ void drawqueue() {
} }
spherespecial = sphereflipped() ? 1 : -1; spherespecial = sphereflipped() ? 1 : -1;
stereo::set_projection(0, true); current_display->set_projection(0, true);
reverse_side_priorities(); reverse_side_priorities();
for(int i=ptds.size()-1; i>=0; i--) for(int i=ptds.size()-1; i>=0; i--)
@@ -1437,7 +1437,7 @@ void drawqueue() {
reverse_side_priorities(); reverse_side_priorities();
spherespecial *= -1; spherespecial *= -1;
spherephase = 1; spherephase = 1;
stereo::set_projection(0, true); current_display->set_projection(0, true);
} }
for(auto& ptd: ptds) if(ptd->prio != PPR::OUTCIRCLE) { for(auto& ptd: ptds) if(ptd->prio != PPR::OUTCIRCLE) {
@@ -1448,11 +1448,11 @@ void drawqueue() {
#if CAP_GL #if CAP_GL
if(vid.usingGL) if(vid.usingGL)
stereo::set_projection(0, true), stereo::set_mask(0), stereo::set_viewport(0); current_display->set_projection(0, true), current_display->set_mask(0), current_display->set_viewport(0);
#endif #endif
#if CAP_SDL #if CAP_SDL
if(stereo::mode == stereo::sAnaglyph && !vid.usingGL) { if(vid.stereo_mode == sAnaglyph && !vid.usingGL) {
int qty = s->w * s->h; int qty = s->w * s->h;
int *a = (int*) s->pixels; int *a = (int*) s->pixels;
int *b = (int*) aux->pixels; int *b = (int*) aux->pixels;
@@ -1464,7 +1464,7 @@ void drawqueue() {
SDL_UnlockSurface(aux); SDL_UnlockSurface(aux);
} }
if(stereo::mode == stereo::sLR && !vid.usingGL) { if(vid.stereo_mode == sLR && !vid.usingGL) {
SDL_LockSurface(aux); SDL_LockSurface(aux);
for(int y=0; y<vid.yres; y++) for(int y=0; y<vid.yres; y++)
for(int x=vid.xres/2; x<vid.xres; x++) for(int x=vid.xres/2; x<vid.xres; x++)
@@ -2779,10 +2779,10 @@ void queuecircle(int x, int y, int size, color_t color, PPR prio = PPR::CIRCLE,
void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) { void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) {
hyperpoint hscr; hyperpoint hscr;
applymodel(h, hscr); applymodel(h, hscr);
xc = vid.xcenter + vid.radius * hscr[0]; xc = current_display->xcenter + current_display->radius * hscr[0];
yc = vid.ycenter + vid.radius * vid.stretch * hscr[1]; yc = current_display->ycenter + current_display->radius * vid.stretch * hscr[1];
sc = 0; sc = 0;
// EYETODO sc = vid.eye * vid.radius * hscr[2]; // EYETODO sc = vid.eye * current_display->radius * hscr[2];
} }
void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) { void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) {

View File

@@ -114,7 +114,7 @@ hint hints[] = {
dialog::addItem(XLAT("world overview"), 'z'); dialog::addItem(XLAT("world overview"), 'z');
}, },
[]() { []() {
setAppropriateOverview(); pushScreen(showOverview);
}}, }},
{ {
0, 0,
@@ -468,7 +468,7 @@ void handleKeyQuit(int sym, int uni) {
else if(uni == 'z') hints[hinttoshow].action(); else if(uni == 'z') hints[hinttoshow].action();
else if(sym == SDLK_F3 || (sym == ' ' || sym == SDLK_HOME)) else if(sym == SDLK_F3 || (sym == ' ' || sym == SDLK_HOME))
fullcenter(); fullcenter();
else if(uni == 'o') setAppropriateOverview(); else if(uni == 'o') get_o_key().second();
#if CAP_INV #if CAP_INV
else if(uni == 'i' && inv::on) else if(uni == 'i' && inv::on)
pushScreen(inv::show); pushScreen(inv::show);

View File

@@ -301,7 +301,7 @@ void bantar_frame() {
cci.second.c->wparam = cci.second.gid; cci.second.c->wparam = cci.second.gid;
calcparam(); calcparam();
stereo::set_projection(0, true); current_display->set_projection(0, true);
vector<unique_ptr<drawqueueitem>> subscr[4]; vector<unique_ptr<drawqueueitem>> subscr[4];
@@ -407,7 +407,7 @@ void bantar_frame() {
vid.xposition = (!(i&2)) ? xdst : -xdst; vid.xposition = (!(i&2)) ? xdst : -xdst;
vid.yposition = (!(i&1)) ? ydst : -ydst; vid.yposition = (!(i&1)) ? ydst : -ydst;
calcparam(); calcparam();
stereo::set_projection(0, true); current_display->set_projection(0, true);
drawqueue(); drawqueue();
} }

View File

@@ -206,8 +206,8 @@ void create_model() {
int v = global_v; int v = global_v;
rug::clear_model(); rug::clear_model();
ld x = (mousex - vid.xcenter + .0) / vid.xres; ld x = (mousex - current_display->xcenter + .0) / vid.xres;
ld y = (mousey - vid.ycenter + .0) / vid.yres; ld y = (mousey - current_display->ycenter + .0) / vid.yres;
ld alpha = atan2(y, x); ld alpha = atan2(y, x);
ld h = hypot(x, y); ld h = hypot(x, y);

View File

@@ -200,8 +200,8 @@ void create_model() {
int v = global_v; int v = global_v;
rug::clear_model(); rug::clear_model();
ld x = (mousex - vid.xcenter + .0) / vid.xres; ld x = (mousex - current_display->xcenter + .0) / vid.xres;
ld y = (mousey - vid.ycenter + .0) / vid.yres; ld y = (mousey - current_display->ycenter + .0) / vid.yres;
ld alpha = atan2(y, x); ld alpha = atan2(y, x);
ld h = hypot(x, y); ld h = hypot(x, y);
@@ -299,7 +299,7 @@ bool frame() {
if(snubon && rug::rugged) { if(snubon && rug::rugged) {
create_model(); create_model();
nomenukey = true; nomenukey = true;
displaychr(vid.xcenter, vid.ycenter, 0, 10, 'X', 0xFFFFFF); displaychr(current_display->xcenter, current_display->ycenter, 0, 10, 'X', 0xFFFFFF);
clearMessages(); clearMessages();
nohelp = true; nohelp = true;
playerfound = true; playerfound = true;
@@ -325,8 +325,8 @@ bool handleKey(int sym, int uni) {
return true; return true;
} }
if(uni == 's' && rug::rugged) { if(uni == 's' && rug::rugged) {
stereo::fov += 30; vid.fov += 30;
if(stereo::fov >= 180) stereo::fov = 60; if(vid.fov >= 180) vid.fov = 60;
} }
if(uni == 'i' && rug::rugged) { if(uni == 'i' && rug::rugged) {
rug::invert_depth = !rug::invert_depth; rug::invert_depth = !rug::invert_depth;

View File

@@ -117,8 +117,8 @@ bool on;
void make_staircase() { void make_staircase() {
// stereo::mode = stereo::sODS; // vid.stereo_mode = current_display->sODS;
// stereo::set_viewport(0); // current_display->set_viewport(0);
rug::no_fog = true; rug::no_fog = true;
printf("scurvature = %lf progress = %lf strafe=%lf,%lf\n", scurvature, progress, strafex, strafey); printf("scurvature = %lf progress = %lf strafe=%lf,%lf\n", scurvature, progress, strafex, strafey);
@@ -137,7 +137,7 @@ void make_staircase() {
acurvature = scurvature; acurvature = scurvature;
} }
rug::ruggospeed = acurvature; rug::ruggospeed = acurvature;
stereo::ipd = 0.15 * acurvature; vid.ipd = 0.15 * acurvature;
if(!rug::rugged || !staircase::on) { if(!rug::rugged || !staircase::on) {
staircase::on = true; staircase::on = true;
rug::reopen(); rug::reopen();

View File

@@ -175,7 +175,7 @@ string its05(int i) { char buf[64]; sprintf(buf, "%05d", i); return buf; }
void staircase_video(int from, int num, int step) { void staircase_video(int from, int num, int step) {
resetbuffer rb; resetbuffer rb;
renderbuffer rbuf(TSIZE, TSIZE, true); renderbuffer rbuf(TSIZE, TSIZE, true);
stereo::mode = stereo::sODS; vid.stereo_mode = sODS;
for(int i=from; i<num; i+=step) { for(int i=from; i<num; i+=step) {
ld t = i * 1. / num; ld t = i * 1. / num;
@@ -191,9 +191,9 @@ void staircase_video(int from, int num, int step) {
rbuf.enable(); rbuf.enable();
dynamicval<int> vx(vid.xres, TSIZE); dynamicval<int> vx(vid.xres, TSIZE);
dynamicval<int> vy(vid.yres, TSIZE); dynamicval<int> vy(vid.yres, TSIZE);
dynamicval<int> vxc(vid.xcenter, TSIZE/2); dynamicval<int> vxc(current_display->xcenter, TSIZE/2);
dynamicval<int> vyc(vid.ycenter, TSIZE/2); dynamicval<int> vyc(current_display->ycenter, TSIZE/2);
stereo::set_viewport(0); current_display->set_viewport(0);
printf("draw scene\n"); printf("draw scene\n");
rug::drawRugScene(); rug::drawRugScene();
@@ -223,7 +223,7 @@ void bantar_record() {
rbuf.enable(); rbuf.enable();
vid.xres = vid.yres = TSIZE; vid.xres = vid.yres = TSIZE;
stereo::set_viewport(0); current_display->set_viewport(0);
banachtarski::bantar_frame(); banachtarski::bantar_frame();
IMAGESAVE(rbuf.render(), ("bantar/" + its05(fr) + IMAGEEXT).c_str()); IMAGESAVE(rbuf.render(), ("bantar/" + its05(fr) + IMAGEEXT).c_str());

View File

@@ -1393,16 +1393,16 @@ bool rogueviz_hud() {
initquickqueue(); initquickqueue();
int rad = vid.radius/10; int rad = current_display->radius/10;
ld x = vid.xres - rad; ld x = vid.xres - rad;
for(int i=0; i<isize(legend); i++) { for(int i=0; i<isize(legend); i++) {
int k = legend[i]; int k = legend[i];
vertexdata& vd = vdata[k]; vertexdata& vd = vdata[k];
ld y = (vid.radius * (i+.5)) / legit * 2 - vid.radius + vid.yres/2; ld y = (current_display->radius * (i+.5)) / legit * 2 - current_display->radius + vid.yres/2;
transmatrix V = atscreenpos(x, y, vid.radius/4); transmatrix V = atscreenpos(x, y, current_display->radius/4);
poly_outline = OUTLINE_NONE; poly_outline = OUTLINE_NONE;
queuedisk(V, vd.cp, true, NULL); queuedisk(V, vd.cp, true, NULL);
@@ -1413,9 +1413,9 @@ bool rogueviz_hud() {
for(int i=0; i<qet; i++) { for(int i=0; i<qet; i++) {
auto t = edgetypes[i]; auto t = edgetypes[i];
ld y = (vid.radius * (i+isize(legend)+.5)) / legit * 2 - vid.radius + vid.yres/2; ld y = (current_display->radius * (i+isize(legend)+.5)) / legit * 2 - current_display->radius + vid.yres/2;
transmatrix V = atscreenpos(x, y, vid.radius/8); transmatrix V = atscreenpos(x, y, current_display->radius/8);
poly_outline = t->color | 0xFF; poly_outline = t->color | 0xFF;
queuepolyat(V, shTriangle, 0, PPR::MONSTER_HEAD); queuepolyat(V, shTriangle, 0, PPR::MONSTER_HEAD);
@@ -1594,7 +1594,7 @@ void fixparam() {
if(!legend.empty() && !nohud) { if(!legend.empty() && !nohud) {
if((svg::in || inHighQual) && pngformat == 0) if((svg::in || inHighQual) && pngformat == 0)
vid.xres = vid.xres * 22/16; vid.xres = vid.xres * 22/16;
vid.xcenter = vid.ycenter; current_display->xcenter = current_display->ycenter;
} }
} }
@@ -2242,6 +2242,11 @@ bool default_help() {
return true; return true;
} }
named_functionality o_key() {
if(rogueviz::on) return named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu);
return named_functionality();
}
auto hooks = auto hooks =
addHook(hooks_frame, 0, drawExtra) + addHook(hooks_frame, 0, drawExtra) +
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
@@ -2257,6 +2262,7 @@ auto hooks =
addHook(shmup::hooks_describe, 100, describe_monster) + addHook(shmup::hooks_describe, 100, describe_monster) +
addHook(shmup::hooks_turn, 100, turn) + addHook(shmup::hooks_turn, 100, turn) +
addHook(shmup::hooks_kill, 100, activate) + addHook(shmup::hooks_kill, 100, activate) +
addHook(hooks_o_key, 100, o_key) +
addHook(hooks_mainmenu, 100, [] () { addHook(hooks_mainmenu, 100, [] () {
dialog::addItem(XLAT("rogueviz menu"), 'u'); dialog::addItem(XLAT("rogueviz menu"), 'u');
dialog::add_action([] () { pushScreen(rogueviz::showMenu); }); dialog::add_action([] () { pushScreen(rogueviz::showMenu); });

60
rug.cpp
View File

@@ -339,8 +339,8 @@ void calcLengths() {
void setVidParam() { void setVidParam() {
vid.xres = vid.yres = TEXTURESIZE; vid.xres = vid.yres = TEXTURESIZE;
vid.scrsize = HTEXTURESIZE; current_display->scrsize = HTEXTURESIZE;
vid.radius = vid.scrsize * vid.scale; vid.xcenter = HTEXTURESIZE; vid.ycenter = HTEXTURESIZE; current_display->radius = current_display->scrsize * vid.scale; current_display->xcenter = HTEXTURESIZE; current_display->ycenter = HTEXTURESIZE;
// vid.alpha = 1; // vid.alpha = 1;
} }
@@ -452,7 +452,7 @@ void buildTorusRug() {
applymodel(tC0(eumove(x, y)), onscreen); applymodel(tC0(eumove(x, y)), onscreen);
// take point (1,0) // take point (1,0)
// apply eumove(1,0) // apply eumove(1,0)
// multiply by vid.radius (= HTEXTURESIZE * rugzoom) // multiply by current_display->radius (= HTEXTURESIZE * rugzoom)
// add 1, divide by texturesize // add 1, divide by texturesize
r->x1 = onscreen[0]; r->x1 = onscreen[0];
r->y1 = onscreen[1]; r->y1 = onscreen[1];
@@ -523,13 +523,13 @@ void buildTorusRug() {
for(auto p: points) for(auto p: points)
maxz = max(maxz, max(abs(p->x1), abs(p->y1))); maxz = max(maxz, max(abs(p->x1), abs(p->y1)));
// maxz * rugzoom * vid.radius == vid.radius // maxz * rugzoom * current_display->radius == current_display->radius
vid.scale = 1 / maxz; vid.scale = 1 / maxz;
for(auto p: points) for(auto p: points)
p->x1 = (vid.xcenter + vid.radius * vid.scale * p->x1)/ vid.xres, p->x1 = (current_display->xcenter + current_display->radius * vid.scale * p->x1)/ vid.xres,
p->y1 = (vid.ycenter - vid.radius * vid.scale * p->y1)/ vid.yres; p->y1 = (current_display->ycenter - current_display->radius * vid.scale * p->y1)/ vid.yres;
qvalid = 0; qvalid = 0;
for(auto p: points) if(!p->glue) qvalid++; for(auto p: points) if(!p->glue) qvalid++;
@@ -1085,7 +1085,7 @@ ld raddif(ld a, ld b) {
bool project_ods(hyperpoint azeq, hyperpoint& h1, hyperpoint& h2, bool eye) { bool project_ods(hyperpoint azeq, hyperpoint& h1, hyperpoint& h2, bool eye) {
USING_NATIVE_GEOMETRY; USING_NATIVE_GEOMETRY;
ld tanalpha = tan_auto(stereo::ipd/2); ld tanalpha = tan_auto(vid.ipd/2);
if(eye) tanalpha = -tanalpha; if(eye) tanalpha = -tanalpha;
if(!sphere) tanalpha = -tanalpha; if(!sphere) tanalpha = -tanalpha;
@@ -1114,7 +1114,7 @@ bool project_ods(hyperpoint azeq, hyperpoint& h1, hyperpoint& h2, bool eye) {
ld phi = atan2(y, x) - atan2(y0, x0) + M_PI; ld phi = atan2(y, x) - atan2(y0, x0) + M_PI;
ld delta = euclid ? hypot(y0,z) : atan2_auto(z / sin(theta), t / cos_auto(stereo::ipd/2)); ld delta = euclid ? hypot(y0,z) : atan2_auto(z / sin(theta), t / cos_auto(vid.ipd/2));
if(euclid || hyperbolic) phi -= M_PI; if(euclid || hyperbolic) phi -= M_PI;
if(hyperbolic) delta = -delta; if(hyperbolic) delta = -delta;
@@ -1143,7 +1143,7 @@ void drawTriangle(triangle& t) {
dt++; dt++;
#if CAP_ODS #if CAP_ODS
if(stereo::mode == stereo::sODS) { if(vid.stereo_mode == current_display->sODS) {
hyperpoint pts[3]; hyperpoint pts[3];
for(int i=0; i<3; i++) for(int i=0; i<3; i++)
pts[i] = t.m[i]->getglue()->flat; pts[i] = t.m[i]->getglue()->flat;
@@ -1231,12 +1231,12 @@ void prepareTexture() {
videopar svid = vid; videopar svid = vid;
setVidParam(); setVidParam();
dynamicval<stereo::eStereo> d(stereo::mode, stereo::sOFF); dynamicval<eStereo> d(vid.stereo_mode, sOFF);
glbuf->enable(); glbuf->enable();
stereo::set_viewport(0); current_display->set_viewport(0);
stereo::set_projection(0, true); current_display->set_projection(0, true);
stereo::set_mask(0); current_display->set_mask(0);
glbuf->clear(0); glbuf->clear(0);
ptds.clear(); ptds.clear();
@@ -1287,23 +1287,23 @@ void drawRugScene() {
glhr::set_depthtest(true); glhr::set_depthtest(true);
glDepthFunc(invert_depth ? GL_GREATER : GL_LESS); glDepthFunc(invert_depth ? GL_GREATER : GL_LESS);
for(int ed=stereo::active() && stereo::mode != stereo::sODS ? -1 : 0; ed < 2; ed += 2) { for(int ed=current_display->stereo_active() && vid.stereo_mode != sODS ? -1 : 0; ed < 2; ed += 2) {
use_precompute = false; use_precompute = false;
ct_array.clear(); ct_array.clear();
stereo::set_mask(ed), stereo::set_viewport(ed); current_display->set_mask(ed), current_display->set_viewport(ed);
if(ed == 1 && stereo::mode == stereo::sAnaglyph) if(ed == 1 && vid.stereo_mode == sAnaglyph)
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
start_projection(ed, true); start_projection(ed, true);
eyewidth_translate(ed); eyewidth_translate(ed);
if(stereo::mode == stereo::sODS) { if(vid.stereo_mode == sODS) {
glhr::projection_multiply(glhr::ortho(M_PI, M_PI, 100)); // 2*M_PI)); glhr::projection_multiply(glhr::ortho(M_PI, M_PI, 100)); // 2*M_PI));
} }
else if(rug_perspective || stereo::active()) { else if(rug_perspective || current_display->stereo_active()) {
xview = stereo::tanfov; xview = current_display->tanfov;
yview = stereo::tanfov * vid.yres / vid.xres; yview = current_display->tanfov * vid.yres / vid.xres;
glhr::projection_multiply(glhr::frustum(xview, yview, lowrug, hirug)); glhr::projection_multiply(glhr::frustum(xview, yview, lowrug, hirug));
xview = -xview; yview = -yview; xview = -xview; yview = -yview;
@@ -1312,19 +1312,19 @@ void drawRugScene() {
glhr::projection_multiply(glhr::translate(0, 0, -model_distance)); glhr::projection_multiply(glhr::translate(0, 0, -model_distance));
if(ed) { if(ed) {
if(gwhere == gEuclid) if(gwhere == gEuclid)
glhr::projection_multiply(glhr::translate(stereo::ipd*ed/2, 0, 0)); glhr::projection_multiply(glhr::translate(vid.ipd*ed/2, 0, 0));
else { else {
use_precompute = true; use_precompute = true;
for(auto p: points) { for(auto p: points) {
p->precompute = p->flat; p->precompute = p->flat;
push_point(p->precompute, 0, stereo::ipd*ed/2); push_point(p->precompute, 0, vid.ipd*ed/2);
} }
} }
} }
} }
else { else {
xview = stereo::tanfov * model_distance; xview = current_display->tanfov * model_distance;
yview = stereo::tanfov * model_distance * vid.yres / vid.xres; yview = current_display->tanfov * model_distance * vid.yres / vid.xres;
// glOrtho(-xview, xview, yview, -yview, -1000, 1000); // glOrtho(-xview, xview, yview, -yview, -1000, 1000);
glhr::projection_multiply(glhr::ortho(xview, yview, -1000)); glhr::projection_multiply(glhr::ortho(xview, yview, -1000));
@@ -1345,13 +1345,13 @@ void drawRugScene() {
glhr::prepare(ct_array); glhr::prepare(ct_array);
glDrawArrays(GL_TRIANGLES, 0, isize(ct_array)); glDrawArrays(GL_TRIANGLES, 0, isize(ct_array));
stereo::set_mask(0); current_display->set_mask(0);
} }
glEnable(GL_BLEND); glEnable(GL_BLEND);
stereo::set_mask(0), stereo::set_viewport(0); current_display->set_mask(0), current_display->set_viewport(0);
stereo::set_projection(0, true); current_display->set_projection(0, true);
if(rug_failure) { if(rug_failure) {
rug::close(); rug::close();
@@ -1516,7 +1516,7 @@ void actDraw() {
} }
// do not display button // do not display button
else playerfound = true; else playerfound = true;
stereo::set_viewport(0); current_display->set_viewport(0);
physics(); physics();
drawRugScene(); drawRugScene();
@@ -1637,8 +1637,8 @@ static const ld RADAR_INF = 1e12;
ld radar_distance = RADAR_INF; ld radar_distance = RADAR_INF;
hyperpoint gethyper(ld x, ld y) { hyperpoint gethyper(ld x, ld y) {
double mx = (x - vid.xcenter)/vid.xres * 2 * xview; double mx = (x - current_display->xcenter)/vid.xres * 2 * xview;
double my = (vid.ycenter - y)/vid.yres * 2 * yview; double my = (current_display->ycenter - y)/vid.yres * 2 * yview;
radar_distance = RADAR_INF; radar_distance = RADAR_INF;
double rx1=0, ry1=0; double rx1=0, ry1=0;

View File

@@ -96,10 +96,10 @@ namespace svg {
void text(int x, int y, int size, const string& str, bool frame, color_t col, int align) { void text(int x, int y, int size, const string& str, bool frame, color_t col, int align) {
double dfc = (x - vid.xcenter) * (x - vid.xcenter) + double dfc = (x - current_display->xcenter) * (x - current_display->xcenter) +
(y - vid.ycenter) * (y - vid.ycenter); (y - current_display->ycenter) * (y - current_display->ycenter);
dfc /= vid.radius; dfc /= current_display->radius;
dfc /= vid.radius; dfc /= current_display->radius;
// 0 = center, 1 = edge // 0 = center, 1 = edge
dfc = 1 - dfc; dfc = 1 - dfc;
@@ -149,7 +149,7 @@ namespace svg {
fprintf(f, "%s %s", coord(polyx[i]), coord(polyy[i])); fprintf(f, "%s %s", coord(polyx[i]), coord(polyy[i]));
} }
fprintf(f, "\" %s/>", stylestr(col, outline, (hyperbolic ? vid.radius : vid.scrsize) * linewidth/256)); fprintf(f, "\" %s/>", stylestr(col, outline, (hyperbolic ? current_display->radius : current_display->scrsize) * linewidth/256));
stopstring(); stopstring();
fprintf(f, "\n"); fprintf(f, "\n");
} }
@@ -252,7 +252,7 @@ void saveHighQualityShot(const char *fname, const char *caption, int fade) {
renderbuffer glbuf(vid.xres, vid.yres, vid.usingGL); renderbuffer glbuf(vid.xres, vid.yres, vid.usingGL);
glbuf.enable(); glbuf.enable();
stereo::set_viewport(0); current_display->set_viewport(0);
// printf("format = %d, %d x %d\n", pngformat, vid.xres, vid.yres); // printf("format = %d, %d x %d\n", pngformat, vid.xres, vid.yres);

View File

@@ -16,9 +16,9 @@ namespace shmupballs {
void calc() { void calc() {
int rr = int(realradius()); int rr = int(realradius());
rad = int(rr * (vid.mobilecompasssize ? vid.mobilecompasssize : 14) / 100); rad = int(rr * (vid.mobilecompasssize ? vid.mobilecompasssize : 14) / 100);
xmove = max(vid.xcenter - rr - rad, rad); xmove = max(current_display->xcenter - rr - rad, rad);
xfire = min(vid.xcenter + rr + rad, vid.xres - rad); xfire = min(current_display->xcenter + rr + rad, vid.xres - rad);
yb = vid.ycenter + rr - rad; yb = current_display->ycenter + rr - rad;
} }
} }
@@ -675,7 +675,7 @@ void handleInput(int delta) {
if(actionspressed[54]) { centerplayer = -1, playermoved = true; centerpc(100); } if(actionspressed[54]) { centerplayer = -1, playermoved = true; centerpc(100); }
if(actionspressed[55] && !lactionpressed[55]) if(actionspressed[55] && !lactionpressed[55])
setAppropriateOverview(); get_o_key().second();
if(actionspressed[56] && !lactionpressed[56]) if(actionspressed[56] && !lactionpressed[56])
showMissionScreen(); showMissionScreen();

View File

@@ -1034,9 +1034,7 @@ namespace gamestack {
struct gamedata { struct gamedata {
hrmap *hmap; hrmap *hmap;
cellwalker cwt; cellwalker cwt;
cellwalker ctover; display_data d;
heptspin viewctr;
transmatrix View;
eGeometry geometry; eGeometry geometry;
eVariation variation; eVariation variation;
bool shmup; bool shmup;
@@ -1054,12 +1052,10 @@ namespace gamestack {
gamedata gdn; gamedata gdn;
gdn.hmap = currentmap; gdn.hmap = currentmap;
gdn.cwt = cwt; gdn.cwt = cwt;
gdn.viewctr = viewctr;
gdn.View = View;
gdn.geometry = geometry; gdn.geometry = geometry;
gdn.shmup = shmup::on; gdn.shmup = shmup::on;
gdn.variation = variation; gdn.variation = variation;
gdn.ctover = centerover; gdn.d = *current_display;
gd.push_back(gdn); gd.push_back(gdn);
} }
@@ -1067,15 +1063,13 @@ namespace gamestack {
gamedata& gdn = gd[isize(gd)-1]; gamedata& gdn = gd[isize(gd)-1];
currentmap = gdn.hmap; currentmap = gdn.hmap;
cwt = gdn.cwt; cwt = gdn.cwt;
viewctr = gdn.viewctr;
View = gdn.View;
geometry = gdn.geometry; geometry = gdn.geometry;
variation = gdn.variation; variation = gdn.variation;
if(shmup::on) shmup::clearMonsters(); if(shmup::on) shmup::clearMonsters();
shmup::on = gdn.shmup; shmup::on = gdn.shmup;
resetGeometry(); resetGeometry();
gd.pop_back(); gd.pop_back();
centerover = gdn.ctover; *current_display = gdn.d;
bfs(); bfs();
} }

View File

@@ -224,8 +224,8 @@ void texture_data::saveRawTexture(string tn) {
hyperpoint texture_config::texture_coordinates(hyperpoint h) { hyperpoint texture_config::texture_coordinates(hyperpoint h) {
hyperpoint inmodel; hyperpoint inmodel;
applymodel(h, inmodel); applymodel(h, inmodel);
inmodel[0] *= vid.radius * 1. / vid.scrsize; inmodel[0] *= current_display->radius * 1. / current_display->scrsize;
inmodel[1] *= vid.radius * vid.stretch / vid.scrsize; inmodel[1] *= current_display->radius * vid.stretch / current_display->scrsize;
inmodel[2] = 1; inmodel[2] = 1;
inmodel = itt * inmodel; inmodel = itt * inmodel;
inmodel[0] = (inmodel[0] + 1) / 2; inmodel[0] = (inmodel[0] + 1) / 2;
@@ -488,7 +488,7 @@ void texture_config::saveFullTexture(string tn) {
drawscreen(); drawscreen();
if(data.readtexture(tn) && data.loadTextureGL()) { if(data.readtexture(tn) && data.loadTextureGL()) {
itt = Id; // xyscale(Id, vid.scrsize * 1. / vid.radius); itt = Id; // xyscale(Id, current_display->scrsize * 1. / current_display->radius);
perform_mapping(); perform_mapping();
finish_mapping(); finish_mapping();
} }
@@ -511,10 +511,10 @@ void texture_config::drawRawTexture() {
inmodel = itt * inmodel; inmodel = itt * inmodel;
rtver[i].texture[0] = (inmodel[0]+1)/2; rtver[i].texture[0] = (inmodel[0]+1)/2;
rtver[i].texture[1] = (inmodel[1]+1)/2; rtver[i].texture[1] = (inmodel[1]+1)/2;
rtver[i].coords[0] = x * vid.scrsize; rtver[i].coords[0] = x * current_display->scrsize;
rtver[i].coords[1] = y * vid.scrsize; rtver[i].coords[1] = y * current_display->scrsize;
} }
glhr::set_modelview(glhr::translate(0, 0, stereo::scrdist)); glhr::set_modelview(glhr::translate(0, 0, current_display->scrdist));
glhr::prepare(rtver); glhr::prepare(rtver);
glhr::set_depthtest(false); glhr::set_depthtest(false);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -617,8 +617,8 @@ ld magic_quality() {
for(auto& p: amp) { for(auto& p: amp) {
hyperpoint inmodel; hyperpoint inmodel;
applymodel(ggmatrix(p.c) * p.cell_relative, inmodel); applymodel(ggmatrix(p.c) * p.cell_relative, inmodel);
inmodel[0] *= vid.radius * 1. / vid.scrsize; inmodel[0] *= current_display->radius * 1. / current_display->scrsize;
inmodel[1] *= vid.radius * 1. / vid.scrsize; inmodel[1] *= current_display->radius * 1. / current_display->scrsize;
q += intvalxy(inmodel, p.texture_coords); q += intvalxy(inmodel, p.texture_coords);
} }
return q; return q;
@@ -657,7 +657,7 @@ eTexturePanstate panstate;
void mousemovement() { void mousemovement() {
static hyperpoint lastmouse; static hyperpoint lastmouse;
hyperpoint mouseeu = hpxyz((mousex - vid.xcenter + .0) / vid.scrsize, (mousey - vid.ycenter + .0) / vid.scrsize, 1); hyperpoint mouseeu = hpxyz((mousex - current_display->xcenter + .0) / current_display->scrsize, (mousey - current_display->ycenter + .0) / current_display->scrsize, 1);
bool nonzero = mouseeu[0] || mouseeu[1]; bool nonzero = mouseeu[0] || mouseeu[1];
switch(panstate) { switch(panstate) {
@@ -986,7 +986,7 @@ void showMagicMenu() {
dialog::display(); dialog::display();
if(holdmouse) { if(holdmouse) {
hyperpoint mouseeu = hpxyz((mousex - vid.xcenter + .0) / vid.scrsize, (mousey - vid.ycenter + .0) / vid.scrsize, 1); hyperpoint mouseeu = hpxyz((mousex - current_display->xcenter + .0) / current_display->scrsize, (mousey - current_display->ycenter + .0) / current_display->scrsize, 1);
if(newmove) { if(newmove) {
magicmapper_point newpoint; magicmapper_point newpoint;
newpoint.c = mouseover; newpoint.c = mouseover;
@@ -1007,13 +1007,13 @@ void showMagicMenu() {
/* /*
hyperpoint inmodel; hyperpoint inmodel;
applymodel(h, inmodel); applymodel(h, inmodel);
inmodel[0] *= vid.radius * 1. / vid.scrsize; inmodel[0] *= current_display->radius * 1. / current_display->scrsize;
inmodel[1] *= vid.radius * 1. / vid.scrsize; inmodel[1] *= current_display->radius * 1. / current_display->scrsize;
*/ */
queuechr( queuechr(
vid.xcenter + vid.scrsize * am.texture_coords[0], current_display->xcenter + current_display->scrsize * am.texture_coords[0],
vid.ycenter + vid.scrsize * am.texture_coords[1], current_display->ycenter + current_display->scrsize * am.texture_coords[1],
0, vid.fsize, letter, 0x00C000, 1); 0, vid.fsize, letter, 0x00C000, 1);
letter++; letter++;

View File

@@ -208,7 +208,7 @@ cld exp_parser::parse(int prio) {
else if(number == "ms") res = ticks; else if(number == "ms") res = ticks;
else if(number == "mousex") res = mousex; else if(number == "mousex") res = mousex;
else if(number == "mousey") res = mousey; else if(number == "mousey") res = mousey;
else if(number == "mousez") res = cld(mousex - vid.xcenter, mousey - vid.ycenter) / cld(vid.radius, 0); else if(number == "mousez") res = cld(mousex - current_display->xcenter, mousey - current_display->ycenter) / cld(current_display->radius, 0);
else if(extra_params.count(number)) res = extra_params[number]; else if(extra_params.count(number)) res = extra_params[number];
else if(params.count(number)) res = params.at(number); else if(params.count(number)) res = params.at(number);
else if(number[0] >= 'a' && number[0] <= 'z') at = -1; else if(number[0] >= 'a' && number[0] <= 'z') at = -1;