fixed some guards (in progress)

This commit is contained in:
Zeno Rogue 2020-07-03 14:42:33 +02:00
parent cbd0c1f934
commit 89585f004b
27 changed files with 169 additions and 65 deletions

View File

@ -110,6 +110,7 @@ void geometry_information::shift_shape_orthogonally(hpcshape& sh, ld z) {
extern renderbuffer *floor_textures; extern renderbuffer *floor_textures;
void geometry_information::add_texture(hpcshape& sh) { void geometry_information::add_texture(hpcshape& sh) {
#if CAP_GL
if(!floor_textures) return; if(!floor_textures) return;
auto& utt = models_texture; auto& utt = models_texture;
sh.tinf = &utt; sh.tinf = &utt;
@ -121,6 +122,7 @@ void geometry_information::add_texture(hpcshape& sh) {
ld factor = 0.50 + (0.17 * h[2] + 0.13 * h[1] + 0.15 * h[0]) / rad; ld factor = 0.50 + (0.17 * h[2] + 0.13 * h[1] + 0.15 * h[0]) / rad;
utt.tvertices.push_back(glhr::makevertex(0, factor, 0)); utt.tvertices.push_back(glhr::makevertex(0, factor, 0));
} }
#endif
} }
vector<hyperpoint> scaleshape(const vector<hyperpoint>& vh, ld s) { vector<hyperpoint> scaleshape(const vector<hyperpoint>& vh, ld s) {
@ -834,12 +836,14 @@ void geometry_information::make_3d_models() {
eyepos = WDIM == 2 ? 0.875 : 0.925; eyepos = WDIM == 2 ? 0.875 : 0.925;
DEBBI(DF_POLY, ("make_3d_models")); DEBBI(DF_POLY, ("make_3d_models"));
shcenter = C0; shcenter = C0;
#if CAP_GL
if(floor_textures) { if(floor_textures) {
auto& utt = models_texture; auto& utt = models_texture;
utt.tvertices.clear(); utt.tvertices.clear();
utt.texture_id = floor_textures->renderedTexture; utt.texture_id = floor_textures->renderedTexture;
} }
#endif
if(WDIM == 2) { if(WDIM == 2) {
DEBB(DF_POLY, ("shadows")); DEBB(DF_POLY, ("shadows"));

View File

@ -216,6 +216,12 @@ EX color_t darkena(color_t c, int lev, int a) {
void setcameraangle(bool b) { } void setcameraangle(bool b) { }
#endif #endif
#if !CAP_GL
EX void reset_projection() { }
EX void glflush() { }
EX bool model_needs_depth() { return false; }
#endif
#if CAP_GL #if CAP_GL
#if CAP_VR #if CAP_VR
@ -1034,7 +1040,7 @@ EX void do_setfsize() {
} }
EX void disable_vsync() { EX void disable_vsync() {
#if !ISMOBWEB #if CAP_SDL && CAP_GL && !ISMOBWEB
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 ); SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
#endif #endif
} }

View File

@ -154,7 +154,9 @@ int arg::readCommon() {
else if(argis("-rsrc")) { PHASE(1); shift(); rsrcdir = args(); } else if(argis("-rsrc")) { PHASE(1); shift(); rsrcdir = args(); }
else if(argis("-nogui")) { PHASE(1); noGUI = true; } else if(argis("-nogui")) { PHASE(1); noGUI = true; }
#ifndef EMSCRIPTEN #ifndef EMSCRIPTEN
#if CAP_SDL
else if(argis("-font")) { PHASE(1); shift(); fontpath = args(); } else if(argis("-font")) { PHASE(1); shift(); fontpath = args(); }
#endif
#endif #endif
else if(argis("-test")) else if(argis("-test"))

View File

@ -910,7 +910,9 @@ string solhelp() {
} }
EX void edit_sightrange() { EX void edit_sightrange() {
#if CAP_RUG
USING_NATIVE_GEOMETRY_IN_RUG; USING_NATIVE_GEOMETRY_IN_RUG;
#endif
if(vid.use_smart_range) { if(vid.use_smart_range) {
ld& det = WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3; ld& det = WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3;
dialog::editNumber(det, 1, 50, 1, WDIM == 2 ? 8 : 30, XLAT("minimum visible cell in pixels"), ""); dialog::editNumber(det, 1, 50, 1, WDIM == 2 ? 8 : 30, XLAT("minimum visible cell in pixels"), "");
@ -2403,8 +2405,10 @@ EX int read_config_args() {
// non-configurable options // non-configurable options
else if(argis("-vsync_off")) { else if(argis("-vsync_off")) {
#if CAP_SDL && CAP_GL
vsync_off = true; vsync_off = true;
if(curphase == 3) setvideomode(); if(curphase == 3) setvideomode();
#endif
} }
else if(argis("-aura")) { else if(argis("-aura")) {
PHASEFROM(2); PHASEFROM(2);

View File

@ -342,7 +342,7 @@ EX void full_rotate_camera(int dir, ld val) {
history::lvspeed += (dir?1:-1) * val / 2; history::lvspeed += (dir?1:-1) * val / 2;
else if(GDIM == 3 && rshiftclick) else if(GDIM == 3 && rshiftclick)
shift_view(ctangent(dir, -val)), didsomething = true, playermoved = false; /* -val because shift reverses */ shift_view(ctangent(dir, -val)), didsomething = true, playermoved = false; /* -val because shift reverses */
#if CAP_CRYSTAL #if CAP_CRYSTAL && CAP_RUG
else if(rug::rug_control() && rug::in_crystal()) else if(rug::rug_control() && rug::in_crystal())
crystal::apply_rotation(cspin(dir, 2, val)); crystal::apply_rotation(cspin(dir, 2, val));
#endif #endif
@ -385,7 +385,9 @@ EX void handlePanning(int sym, int uni) {
if(sym == PSEUDOKEY_WHEELDOWN) shift_view(ztangent(0.05*shiftmul)), didsomething = true, playermoved = false; if(sym == PSEUDOKEY_WHEELDOWN) shift_view(ztangent(0.05*shiftmul)), didsomething = true, playermoved = false;
} }
#if CAP_RUG
rug::using_rugview urv; rug::using_rugview urv;
#endif
#if !ISPANDORA #if !ISPANDORA
if(!smooth_scrolling) { if(!smooth_scrolling) {

View File

@ -1182,6 +1182,7 @@ EX void flip_z() {
crug_rotation[i][2] *= -1; crug_rotation[i][2] *= -1;
} }
#if CAP_RUG
hyperpoint coord_to_flat(ldcoord co, int dim = 3) { hyperpoint coord_to_flat(ldcoord co, int dim = 3) {
auto& cs = crystal_map()->cs; auto& cs = crystal_map()->cs;
hyperpoint res = Hypc; hyperpoint res = Hypc;
@ -1314,6 +1315,7 @@ EX void build_rugdata() {
println(hlog, "cut ", cut_level, "r ", crug_rotation); println(hlog, "cut ", cut_level, "r ", crug_rotation);
} }
#endif
EX void set_land(cell *c) { EX void set_land(cell *c) {
setland(c, specialland); setland(c, specialland);
@ -1481,6 +1483,7 @@ EX void show() {
dialog::editNumber(compass_probability, 0, 1, 0.1, 1, XLAT("compass probability"), compass_help()); dialog::editNumber(compass_probability, 0, 1, 0.1, 1, XLAT("compass probability"), compass_help());
dialog::bound_low(0); dialog::bound_low(0);
}); });
#if CAP_RUG
if(cryst && WDIM == 2) { if(cryst && WDIM == 2) {
dialog::addBoolItem(XLAT("3D display"), rug::rugged, 'r'); dialog::addBoolItem(XLAT("3D display"), rug::rugged, 'r');
dialog::add_action_push(rug::show); dialog::add_action_push(rug::show);
@ -1499,6 +1502,7 @@ EX void show() {
}); });
} }
else dialog::addBreak(100); else dialog::addBreak(100);
#endif
dialog::addSelItem(XLAT("Crystal torus"), its(crystal_period), 'C'); dialog::addSelItem(XLAT("Crystal torus"), its(crystal_period), 'C');
dialog::add_action([] { dialog::add_action([] {
dialog::editNumber(crystal_period, 0, 16, 2, 0, XLAT("Crystal torus"), dialog::editNumber(crystal_period, 0, 16, 2, 0, XLAT("Crystal torus"),

View File

@ -858,7 +858,9 @@ int read_cheat_args() {
shift(); steplimit = argi(); shift(); steplimit = argi();
} }
else if(argis("-dgl")) { else if(argis("-dgl")) {
#if CAP_GL
glhr::debug_gl = true; glhr::debug_gl = true;
#endif
} }
else if(argis("-mgen-off")) { else if(argis("-mgen-off")) {
PHASEFROM(3); PHASEFROM(3);

View File

@ -240,7 +240,7 @@ EX void glflush() {
} }
#endif #endif
#if !ISMOBILE #if CAP_SDL && !ISMOBILE
SDL_Surface *aux; SDL_Surface *aux;
#endif #endif
@ -743,7 +743,9 @@ EX void set_width(ld w) {
#if MINIMIZE_GL_CALLS #if MINIMIZE_GL_CALLS
if(w != glhr::current_linewidth) glflush(); if(w != glhr::current_linewidth) glflush();
#endif #endif
#if CAP_GL
glhr::set_linewidth(w); glhr::set_linewidth(w);
#endif
} }
// this part makes cylindrical projections on the sphere work // this part makes cylindrical projections on the sphere work
@ -1400,10 +1402,12 @@ void dqi_poly::draw() {
} }
#endif #endif
#if CAP_GL
if(in_s2xe() && vid.usingGL && pmodel == mdPerspective && (current_display->set_all(global_projection), (get_shader_flags() & SF_DIRECT))) { if(in_s2xe() && vid.usingGL && pmodel == mdPerspective && (current_display->set_all(global_projection), (get_shader_flags() & SF_DIRECT))) {
s2xe::draw_s2xe(this); s2xe::draw_s2xe(this);
return; return;
} }
#endif
dynamicval<ld> bs(hr::band_shift, band_shift); dynamicval<ld> bs(hr::band_shift, band_shift);
if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) {
@ -1990,6 +1994,7 @@ EX void draw_main() {
if(stretch::factor) return; if(stretch::factor) return;
} }
#if CAP_GL
for(int p: {1, 0, 2, 3}) { for(int p: {1, 0, 2, 3}) {
if(elliptic && p < 2) continue; if(elliptic && p < 2) continue;
glhr::set_depthwrite(true); glhr::set_depthwrite(true);
@ -2021,6 +2026,7 @@ EX void draw_main() {
} }
// glflush(); // glflush();
} }
#endif
} }
else { else {
DEBB(DF_GRAPH, ("draw_main1")); DEBB(DF_GRAPH, ("draw_main1"));
@ -2043,6 +2049,7 @@ EX void draw_main() {
} }
glflush(); glflush();
#if CAP_RAY
if(ray::in_use && ray::comparison_mode) { if(ray::in_use && ray::comparison_mode) {
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
#ifdef GLES_ONLY #ifdef GLES_ONLY
@ -2053,6 +2060,7 @@ EX void draw_main() {
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
ray::cast(); ray::cast();
} }
#endif
} }
} }
@ -2136,15 +2144,20 @@ EX void drawqueue() {
#if CAP_VR #if CAP_VR
if(callhandlers(false, hooks_vr)) {} else if(callhandlers(false, hooks_vr)) {} else
#endif #endif
#if CAP_GL
if(model_needs_depth() && current_display->stereo_active()) { if(model_needs_depth() && current_display->stereo_active()) {
global_projection = -1; global_projection = -1;
draw_main(); draw_main();
#if CAP_GL
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
#endif
global_projection = +1; global_projection = +1;
draw_main(); draw_main();
global_projection = 0; global_projection = 0;
} }
else { else
#endif
{
draw_main(); draw_main();
} }

View File

@ -1012,7 +1012,13 @@ auto floor_hook =
#endif #endif
#endif #endif
#if MAXMDIM >= 4 #if MAXMDIM < 4 || !CAP_GL
EX void ensure_vertex_number(basic_textureinfo& bti, int qty) {}
EX void ensure_vertex_number(hpcshape& sh) {}
EX void bind_floor_texture(hpcshape& li, int id) {}
#endif
#if MAXMDIM >= 4 && CAP_GL
EX ld floor_texture_square_size; EX ld floor_texture_square_size;

View File

@ -902,7 +902,9 @@ EX void apply_always3() {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
EX void switch_always3() { EX void switch_always3() {
if(dual::split(switch_always3)) return; if(dual::split(switch_always3)) return;
#if CAP_GL
if(rug::rugged) rug::close(); if(rug::rugged) rug::close();
#endif
vid.always3 = !vid.always3; vid.always3 = !vid.always3;
apply_always3(); apply_always3();
swapmatrix(View); swapmatrix(View);
@ -933,7 +935,9 @@ EX void switch_always3() {
EX void switch_fpp() { EX void switch_fpp() {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
#if CAP_GL
if(rug::rugged) rug::close(); if(rug::rugged) rug::close();
#endif
if(dual::split(switch_fpp)) return; if(dual::split(switch_fpp)) return;
check_cgi(); cgi.require_basics(); check_cgi(); cgi.require_basics();
View = inverse(models::rotmatrix()) * View; View = inverse(models::rotmatrix()) * View;

View File

@ -11,6 +11,41 @@
#include "hyper.h" #include "hyper.h"
namespace hr { namespace hr {
EX namespace glhr {
EX glvertex pointtogl(const hyperpoint& t) {
glvertex h;
h[0] = t[0]; h[1] = t[1]; h[2] = t[2];
if(SHDIM == 4) h[3] = (MDIM == 4) ? t[3] : 1;
return h;
}
EX hyperpoint gltopoint(const glvertex& t) {
hyperpoint h;
h[0] = t[0]; h[1] = t[1]; h[2] = t[2];
if(SHDIM == 4 && MAXMDIM == 4) h[3] = t[3];
return h;
}
#if CAP_SHADER
EX bool noshaders = false;
#endif
#if !CAP_SHADER
EX bool noshaders = true;
#endif
#if HDR
inline glvertex makevertex(GLfloat x, GLfloat y, GLfloat z) {
#if SHDIM == 3
return make_array(x, y, z);
#else
return make_array<GLfloat>(x, y, z, 1);
#endif
}
#endif
EX }
#if CAP_GL
#ifndef DEBUG_GL #ifndef DEBUG_GL
#define DEBUG_GL 0 #define DEBUG_GL 0
#endif #endif
@ -55,16 +90,6 @@ struct glmatrix {
const array<float, 16>& as_stdarray() const { return *(array<float, 16>*)this; } const array<float, 16>& as_stdarray() const { return *(array<float, 16>*)this; }
}; };
glvertex pointtogl(const hyperpoint& t);
inline glvertex makevertex(GLfloat x, GLfloat y, GLfloat z) {
#if SHDIM == 3
return make_array(x, y, z);
#else
return make_array<GLfloat>(x, y, z, 1);
#endif
}
struct colored_vertex { struct colored_vertex {
glvertex coords; glvertex coords;
glvec4 color; glvec4 color;
@ -105,12 +130,6 @@ glvertex pointtogl(const hyperpoint& t);
#endif #endif
#if CAP_SHADER
EX bool noshaders = false;
#else
EX bool noshaders = true;
#endif
bool glew = false; bool glew = false;
bool current_depthtest, current_depthwrite; bool current_depthtest, current_depthwrite;
@ -647,20 +666,6 @@ void init() {
#endif #endif
} }
EX hyperpoint gltopoint(const glvertex& t) {
hyperpoint h;
h[0] = t[0]; h[1] = t[1]; h[2] = t[2];
if(SHDIM == 4 && MAXMDIM == 4) h[3] = t[3];
return h;
}
EX glvertex pointtogl(const hyperpoint& t) {
glvertex h;
h[0] = t[0]; h[1] = t[1]; h[2] = t[2];
if(SHDIM == 4) h[3] = (MDIM == 4) ? t[3] : 1;
return h;
}
#if CAP_VERTEXBUFFER #if CAP_VERTEXBUFFER
template<class T> void bindbuffer(T& v) { template<class T> void bindbuffer(T& v) {
if(current_vertices == buffered_vertices || current_vertices == nullptr) { if(current_vertices == buffered_vertices || current_vertices == nullptr) {
@ -839,7 +844,7 @@ EX void oldvertices(GLfloat *f, int qty) {
) )
} }
#endif
} }
#define glMatrixMode DISABLED #define glMatrixMode DISABLED

View File

@ -2943,9 +2943,11 @@ void sumaura(int v) {
aurac[AURA][v] = aurac[0][v]; aurac[AURA][v] = aurac[0][v];
} }
#if CAP_GL
vector<glhr::colored_vertex> auravertices; vector<glhr::colored_vertex> auravertices;
#endif
void drawaura() { EX void drawaura() {
DEBBI(DF_GRAPH, ("draw aura")); DEBBI(DF_GRAPH, ("draw aura"));
if(!haveaura()) return; if(!haveaura()) return;
if(vid.stereo_mode) return; if(vid.stereo_mode) return;

View File

@ -227,7 +227,7 @@ template<class... T> void print(hstream& hs, const tuple<T...> & t) {
inline void special_log(char c) { if(debugfile) fputc(c, debugfile); putchar(c); } inline void special_log(char c) { if(debugfile) fputc(c, debugfile); putchar(c); }
#endif #endif
#if !CAP_SDL && !ISFAKEMOBILE #if !CAP_SDL && CAP_TIMEOFDAY
int SDL_GetTicks(); int SDL_GetTicks();
#endif #endif

View File

@ -687,7 +687,11 @@ enum orbAction { roMouse, roKeyboard, roCheck, roMouseForce, roMultiCheck, roMul
#define MODELCOUNT ((int) mdGUARD) #define MODELCOUNT ((int) mdGUARD)
#define pconf vid.projection_config #define pconf vid.projection_config
#if CAP_RUG
#define vpconf (rug::rugged ? vid.rug_config : vid.projection_config) #define vpconf (rug::rugged ? vid.rug_config : vid.projection_config)
#else
#define vpconf pconf
#endif
#define pmodel (pconf.model) #define pmodel (pconf.model)
color_t darkena(color_t c, int lev, int a); color_t darkena(color_t c, int lev, int a);

View File

@ -33,7 +33,11 @@ EX bool non_spatial_model() {
return true; return true;
if(pmodel == mdSpiral && euclid) if(pmodel == mdSpiral && euclid)
return true; return true;
#if CAP_GL
return pmodel && vid.consider_shader_projection && (get_shader_flags() & SF_DIRECT); return pmodel && vid.consider_shader_projection && (get_shader_flags() & SF_DIRECT);
#else
return false;
#endif
} }
EX hyperpoint perspective_to_space(hyperpoint h, ld alpha IS(pconf.alpha), eGeometryClass gc IS(ginf[geometry].cclass)) { EX hyperpoint perspective_to_space(hyperpoint h, ld alpha IS(pconf.alpha), eGeometryClass gc IS(ginf[geometry].cclass)) {
@ -1345,7 +1349,7 @@ EX void centerpc(ld aspd) {
if(subscreens::split([=] () {centerpc(aspd);})) return; if(subscreens::split([=] () {centerpc(aspd);})) return;
if(dual::split([=] () { centerpc(aspd); })) return; if(dual::split([=] () { centerpc(aspd); })) return;
#if CAP_CRYSTAL #if CAP_CRYSTAL && CAP_RUG
if(cryst) if(cryst)
crystal::centerrug(aspd); crystal::centerrug(aspd);
#endif #endif
@ -1555,7 +1559,9 @@ EX eModel flat_model() { return MDIM == 4 ? mdPixel : mdDisk; }
/** \brief enable the 'flat' model for drawing HUD. See hr::flat_model_enabler */ /** \brief enable the 'flat' model for drawing HUD. See hr::flat_model_enabler */
EX void enable_flat_model() { EX void enable_flat_model() {
#if CAP_GL
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
#endif
pmodel = flat_model(); pmodel = flat_model();
pconf.alpha = 1; pconf.alpha = 1;
pconf.scale = 1; pconf.scale = 1;

View File

@ -1607,7 +1607,6 @@ namespace mapeditor {
void drawHandleKey(int sym, int uni); void drawHandleKey(int sym, int uni);
#if CAP_TEXTURE
static ld brush_sizes[10] = { static ld brush_sizes[10] = {
0.001, 0.002, 0.005, 0.0075, 0.01, 0.015, 0.02, 0.05, 0.075, 0.1}; 0.001, 0.002, 0.005, 0.0075, 0.01, 0.015, 0.02, 0.05, 0.075, 0.1};
@ -1626,7 +1625,6 @@ namespace mapeditor {
0x404040FF, 0x404040FF,
0x804000FF 0x804000FF
}; };
#endif
bool area_in_pi = false; bool area_in_pi = false;
@ -2367,11 +2365,13 @@ namespace mapeditor {
else if(mousekey == 'l' || mousekey == 'c') { else if(mousekey == 'l' || mousekey == 'c') {
if(!holdmouse) lstart = mouseh, lstartcell = mouseover, holdmouse = true; if(!holdmouse) lstart = mouseh, lstartcell = mouseover, holdmouse = true;
} }
#if CAP_TEXTURE
else if(intexture) { else if(intexture) {
if(!holdmouse) texture::config.data.undoLock(); if(!holdmouse) texture::config.data.undoLock();
texture::drawPixel(mouseover, mouseh, tcolor); texture::drawPixel(mouseover, mouseh, tcolor);
holdmouse = true; lstartcell = NULL; holdmouse = true; lstartcell = NULL;
} }
#endif
else { else {
dt_add_free(mouseh); dt_add_free(mouseh);
holdmouse = true; holdmouse = true;
@ -2380,6 +2380,7 @@ namespace mapeditor {
if(sym == PSEUDOKEY_RELEASE) { if(sym == PSEUDOKEY_RELEASE) {
printf("release\n"); printf("release\n");
#if CAP_TEXTURE
if(mousekey == 'l' && intexture) { if(mousekey == 'l' && intexture) {
texture::config.data.undoLock(); texture::config.data.undoLock();
texture::where = mouseover; texture::where = mouseover;
@ -2387,10 +2388,13 @@ namespace mapeditor {
texture::drawLine(mouseh, lstart, tcolor); texture::drawLine(mouseh, lstart, tcolor);
lstartcell = NULL; lstartcell = NULL;
} }
else if(mousekey == 'l') { else
#endif
if(mousekey == 'l') {
dt_add_line(mouseh, lstart, 10); dt_add_line(mouseh, lstart, 10);
lstartcell = NULL; lstartcell = NULL;
} }
#if CAP_TEXTURE
else if(mousekey == 'c' && intexture) { else if(mousekey == 'c' && intexture) {
texture::config.data.undoLock(); texture::config.data.undoLock();
ld rad = hdist(lstart, mouseh); ld rad = hdist(lstart, mouseh);
@ -2402,6 +2406,7 @@ namespace mapeditor {
texture::drawPixel(T * xspinpush0(2 * M_PI * i / circp, rad), tcolor); texture::drawPixel(T * xspinpush0(2 * M_PI * i / circp, rad), tcolor);
lstartcell = NULL; lstartcell = NULL;
} }
#endif
else if(mousekey == 'c') { else if(mousekey == 'c') {
dt_add_circle(lstart, mouseh); dt_add_circle(lstart, mouseh);
lstartcell = NULL; lstartcell = NULL;
@ -2418,12 +2423,14 @@ namespace mapeditor {
if(uni >= 2000 && uni < 2010) if(uni >= 2000 && uni < 2010)
dtwidth = brush_sizes[uni - 2000]; dtwidth = brush_sizes[uni - 2000];
#if CAP_TEXTURE
if(uni == '0') if(uni == '0')
texture::texturesym = !texture::texturesym; texture::texturesym = !texture::texturesym;
if(uni == 'u') { if(uni == 'u') {
texture::config.data.undo(); texture::config.data.undo();
} }
#endif
if(uni == 'p') { if(uni == 'p') {
if(!clickused) if(!clickused)

View File

@ -343,7 +343,9 @@ EX namespace models {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
gamescreen(0); gamescreen(0);
dialog::init(XLAT("models & projections")); dialog::init(XLAT("models & projections"));
#if CAP_RUG
USING_NATIVE_GEOMETRY_IN_RUG; USING_NATIVE_GEOMETRY_IN_RUG;
#endif
for(int i=0; i<mdGUARD; i++) { for(int i=0; i<mdGUARD; i++) {
eModel m = eModel(i); eModel m = eModel(i);
@ -399,7 +401,9 @@ EX namespace models {
EX void model_menu() { EX void model_menu() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
gamescreen(0); gamescreen(0);
#if CAP_RUG
USING_NATIVE_GEOMETRY_IN_RUG; USING_NATIVE_GEOMETRY_IN_RUG;
#endif
dialog::init(XLAT("models & projections")); dialog::init(XLAT("models & projections"));
auto vpmodel = vpconf.model; auto vpmodel = vpconf.model;
@ -660,6 +664,7 @@ EX namespace models {
}); });
} }
#if CAP_GL
dialog::addBoolItem(XLAT("use GPU to compute projections"), vid.consider_shader_projection, 'G'); dialog::addBoolItem(XLAT("use GPU to compute projections"), vid.consider_shader_projection, 'G');
bool shaderside_projection = get_shader_flags() & SF_DIRECT; bool shaderside_projection = get_shader_flags() & SF_DIRECT;
if(vid.consider_shader_projection && !shaderside_projection) if(vid.consider_shader_projection && !shaderside_projection)
@ -667,6 +672,7 @@ EX namespace models {
if(vid.consider_shader_projection && shaderside_projection && vpmodel) if(vid.consider_shader_projection && shaderside_projection && vpmodel)
dialog::lastItem().value += XLAT(" (2D only)"); dialog::lastItem().value += XLAT(" (2D only)");
dialog::add_action([] { vid.consider_shader_projection = !vid.consider_shader_projection; }); dialog::add_action([] { vid.consider_shader_projection = !vid.consider_shader_projection; });
#endif
menuitem_sightrange('R'); menuitem_sightrange('R');

View File

@ -209,7 +209,7 @@ EX namespace netgen {
void blackline(vec v1, vec v2, color_t col = 0x000000FF) { void blackline(vec v1, vec v2, color_t col = 0x000000FF) {
#if CAP_SDLGFX #if CAP_SDLGFX
aalineColor(s, int(v1.x), int(v1.y), int(v2.x), int(v2.y), col); aalineColor(s, int(v1.x), int(v1.y), int(v2.x), int(v2.y), col);
#else #elseif CAP_SDL
SDL_LockSurface(s); SDL_LockSurface(s);
int len = abs(v1.x-v2.x) + abs(v1.y-v2.y); int len = abs(v1.x-v2.x) + abs(v1.y-v2.y);
for(int i=0; i<=len; i++) for(int i=0; i<=len; i++)
@ -227,7 +227,7 @@ EX namespace netgen {
polyy[1] = int(v2.y); polyy[1] = int(v2.y);
polyy[2] = int(v3.y); polyy[2] = int(v3.y);
filledPolygonColorI(s, polyx, polyy, 3, col); filledPolygonColorI(s, polyx, polyy, 3, col);
#else #elseif CAP_SDL
SDL_LockSurface(s); SDL_LockSurface(s);
int len = abs(v1.x-v2.x) + abs(v1.y-v2.y); int len = abs(v1.x-v2.x) + abs(v1.y-v2.y);
for(int i=0; i<=len; i++) for(int j=0; j<=len; j++) if(i+j <= len) for(int i=0; i<=len; i++) for(int j=0; j<=len; j++) if(i+j <= len)

View File

@ -70,21 +70,24 @@ void geometry_information::shift(hpcshape& sh, double dx, double dy, double dz)
} }
void geometry_information::initPolyForGL() { void geometry_information::initPolyForGL() {
#if CAP_GL
ourshape.clear(); ourshape.clear();
for(auto& h: hpc) for(auto& h: hpc)
ourshape.push_back(glhr::pointtogl(h)); ourshape.push_back(glhr::pointtogl(h));
glhr::store_in_buffer(ourshape); glhr::store_in_buffer(ourshape);
#endif
} }
void geometry_information::extra_vertices() { void geometry_information::extra_vertices() {
#if CAP_GL
while(isize(ourshape) < isize(hpc)) while(isize(ourshape) < isize(hpc))
ourshape.push_back(glhr::pointtogl(hpc[isize(ourshape)])); ourshape.push_back(glhr::pointtogl(hpc[isize(ourshape)]));
glhr::store_in_buffer(ourshape); glhr::store_in_buffer(ourshape);
glhr::current_vertices = NULL; glhr::current_vertices = NULL;
prehpc = isize(hpc); prehpc = isize(hpc);
#endif
} }
transmatrix geometry_information::ddi(int a, ld x) { return xspinpush(a * M_PI / S42, x); } transmatrix geometry_information::ddi(int a, ld x) { return xspinpush(a * M_PI / S42, x); }

21
rug.cpp
View File

@ -1838,16 +1838,21 @@ auto rug_hook =
EX } EX }
#else #endif
#if !CAP_RUG
// fake for mobile // fake for mobile
namespace rug { EX namespace rug {
bool rugged = false; EX bool rugged = false;
bool renderonce = false; EX bool renderonce = false;
bool rendernogl = true; EX bool rendernogl = true;
int texturesize = 512; EX int texturesize = 512;
ld scale = 1.0f; EX ld scale = 1.0f;
} EX bool rug_control() { return false; }
EX bool in_crystal() { return false; }
EX void reset_view() { }
EX }
#endif #endif
} }

View File

@ -455,6 +455,7 @@ EX always_false in;
for(auto& d: tdata) d[0] = x; for(auto& d: tdata) d[0] = x;
} }
#if CAP_GL
if(tt == 3) { if(tt == 3) {
int tp = texture_position[texid(p)]; int tp = texture_position[texid(p)];
auto xy = make_array<int>(tp % fts_row, tp / fts_row); auto xy = make_array<int>(tp % fts_row, tp / fts_row);
@ -465,6 +466,7 @@ EX always_false in;
d[c] = ((d[c] - zero[c])*sca + xy[c] + .5) * fts_int / fts; d[c] = ((d[c] - zero[c])*sca + xy[c] + .5) * fts_int / fts;
} }
#endif #endif
#endif
for(auto& d: tdata) ad.second.push_back(d); for(auto& d: tdata) ad.second.push_back(d);
} }
@ -482,6 +484,7 @@ EX always_false in;
int gps = 0; int gps = 0;
for(auto& p: gradient_position) p.second = gps++; for(auto& p: gradient_position) p.second = gps++;
#if CAP_TEXTURE
fts_int = floor_texture_square_size * FLOORTEXTURESIZE + 4; fts_int = floor_texture_square_size * FLOORTEXTURESIZE + 4;
fts = 64; fts = 64;
@ -490,6 +493,7 @@ EX always_false in;
fts_row = (fts-gps)/fts_int; fts_row = (fts-gps)/fts_int;
#endif #endif
#endif
for(auto& p: ptds) { for(auto& p: ptds) {
auto p2 = dynamic_cast<dqi_poly*>(&*p); auto p2 = dynamic_cast<dqi_poly*>(&*p);
@ -642,9 +646,7 @@ void set_shotx() {
} }
} }
#if CAP_SDL
EX int shot_aa = 1; EX int shot_aa = 1;
#endif
EX void default_screenshot_content() { EX void default_screenshot_content() {
#if CAP_RUG #if CAP_RUG
@ -664,9 +666,11 @@ EX void default_screenshot_content() {
drawStats(); drawStats();
} }
#if CAP_SDL
EX SDL_Surface *empty_surface(int x, int y, bool alpha) { EX SDL_Surface *empty_surface(int x, int y, bool alpha) {
return SDL_CreateRGBSurface(SDL_SWSURFACE,x,y,32,0xFF<<16,0xFF<<8,0xFF, (alpha) ? (0xFF<<24) : 0); return SDL_CreateRGBSurface(SDL_SWSURFACE,x,y,32,0xFF<<16,0xFF<<8,0xFF, (alpha) ? (0xFF<<24) : 0);
} }
#endif
#if CAP_PNG #if CAP_PNG
@ -957,12 +961,18 @@ EX void menu() {
#if CAP_WRL #if CAP_WRL
if(!models::is_3d(vpconf) && !rug::rugged) { if(!models::is_3d(vpconf) && !rug::rugged) {
dialog::addInfo("this format is for 3D projections", 0xFF0000); dialog::addInfo("this format is for 3D projections", 0xFF0000);
#if CAP_RUG
if(GDIM == 2) { if(GDIM == 2) {
dialog::addItem(XLAT("hypersian rug mode"), 'u'); dialog::addItem(XLAT("hypersian rug mode"), 'u');
dialog::add_action_push(rug::show); dialog::add_action_push(rug::show);
} }
#endif
} }
#if CAP_RUG
else if(rug::rugged ? rug::perspective() : models::is_perspective(vpconf.model)) { else if(rug::rugged ? rug::perspective() : models::is_perspective(vpconf.model)) {
#else
else if(models::is_perspective(vpconf.model)) {
#endif
dialog::addInfo("this does not work well in perspective projections", 0xFF8000); dialog::addInfo("this does not work well in perspective projections", 0xFF8000);
dialog::addSelItem(XLAT("projection"), current_proj_name(), '1'); dialog::addSelItem(XLAT("projection"), current_proj_name(), '1');
dialog::add_action_push(models::model_menu); dialog::add_action_push(models::model_menu);
@ -1825,12 +1835,14 @@ startanim rug { "Hypersian Rug", [] {
pick(); pick();
#endif #endif
}, [] { }, [] {
#if CAP_RUG
dynamicval<bool> b(rug::rugged, true); dynamicval<bool> b(rug::rugged, true);
rug::physics(); rug::physics();
dynamicval<transmatrix> t(rug::rugView, cspin(1, 2, ticks / 3000.) * rug::rugView); dynamicval<transmatrix> t(rug::rugView, cspin(1, 2, ticks / 3000.) * rug::rugView);
gamescreen(2); gamescreen(2);
if(!rug::rugged) current = &null_animation; if(!rug::rugged) current = &null_animation;
explorable([] { rug::rugged = true; pushScreen(rug::show); }); explorable([] { rug::rugged = true; pushScreen(rug::show); });
#endif
}}; }};
startanim spin_around { "spinning around", no_init, [] { startanim spin_around { "spinning around", no_init, [] {

View File

@ -11,6 +11,7 @@ namespace hr {
EX ld levellines; EX ld levellines;
EX bool disable_texture; EX bool disable_texture;
#if CAP_GL
#if HDR #if HDR
constexpr flagtype GF_TEXTURE = 1; constexpr flagtype GF_TEXTURE = 1;
constexpr flagtype GF_VARCOLOR = 2; constexpr flagtype GF_VARCOLOR = 2;
@ -546,5 +547,5 @@ EX void glapplymatrix(const transmatrix& V) {
glhr::set_modelview(glhr::as_glmatrix(mat)); glhr::set_modelview(glhr::as_glmatrix(mat));
} }
#endif
} }

View File

@ -2,7 +2,7 @@
namespace hr { namespace hr {
#if MAXMDIM >= 4 #if MAXMDIM >= 4 && CAP_GL
EX ld camera_level; EX ld camera_level;
EX int get_skybrightness(int mul IS(1)) { EX int get_skybrightness(int mul IS(1)) {

View File

@ -8,9 +8,9 @@
*/ */
#include "hyper.h" #include "hyper.h"
#if CAP_SURFACE
namespace hr { namespace hr {
#if CAP_SURFACE
EX namespace surface { EX namespace surface {
ld sech(ld d) { return 1 / cosh(d); } ld sech(ld d) { return 1 / cosh(d); }
@ -841,9 +841,9 @@ int surface_args() {
else return 1; else return 1;
return 0; return 0;
} }
#endif
auto surface_hook = addHook(hooks_args, 100, surface_args); auto surface_hook = addHook(hooks_args, 100, surface_args);
#endif
void display_coverage() { void display_coverage() {
@ -860,5 +860,6 @@ void display_coverage() {
auto surface_hook2 = addHook(hooks_frame, 0, display_coverage); auto surface_hook2 = addHook(hooks_frame, 0, display_coverage);
}} EX }
#endif #endif
}

View File

@ -186,7 +186,7 @@
#endif #endif
#ifndef CAP_MODEL #ifndef CAP_MODEL
#define CAP_MODEL (!ISMOBWEB && !ISMINI) #define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDL)
#endif #endif
#ifndef CAP_SAVE #ifndef CAP_SAVE
@ -399,6 +399,7 @@ extern "C" {
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB) #define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB)
#endif #endif
#if CAP_GL
#if CAP_GLEW #if CAP_GLEW
#include <GL/glew.h> #include <GL/glew.h>
#else #else
@ -422,6 +423,10 @@ extern "C" {
#include <GL/glext.h> #include <GL/glext.h>
#endif #endif
#endif #endif
#else
typedef int GLint;
typedef unsigned GLuint;
#endif
#include <functional> #include <functional>
#include <memory> #include <memory>
@ -560,7 +565,7 @@ union SDL_Event;
#endif #endif
#ifndef CAP_RAY #ifndef CAP_RAY
#define CAP_RAY (MAXMDIM >= 4 && !ISWEB && !ISMOBILE) #define CAP_RAY (MAXMDIM >= 4 && !ISWEB && !ISMOBILE && CAP_GL)
#endif #endif
#ifndef CAP_MEMORY_RESERVE #ifndef CAP_MEMORY_RESERVE

View File

@ -57,7 +57,7 @@ void geometry_information::pushShape(usershapelayer& ds) {
if(GDIM == 2) hpcpush(T * ds.list[0]); if(GDIM == 2) hpcpush(T * ds.list[0]);
#if MAXMDIM >= 4 #if MAXMDIM >= 4 && CAP_GL
if(GDIM == 3) { if(GDIM == 3) {
auto& utt = user_triangles_texture; auto& utt = user_triangles_texture;
utt.texture_id = floor_textures->renderedTexture; utt.texture_id = floor_textures->renderedTexture;

View File

@ -13,7 +13,7 @@ namespace hr {
int lastusec; int lastusec;
int uticks; int uticks;
int SDL_GetTicks() { EX int SDL_GetTicks() {
struct timeval tim; struct timeval tim;
gettimeofday(&tim, NULL); gettimeofday(&tim, NULL);
int newusec = tim.tv_usec; int newusec = tim.tv_usec;