diff --git a/3d-models.cpp b/3d-models.cpp index 085927aa..e0c0e8e9 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -110,6 +110,7 @@ void geometry_information::shift_shape_orthogonally(hpcshape& sh, ld z) { extern renderbuffer *floor_textures; void geometry_information::add_texture(hpcshape& sh) { +#if CAP_GL if(!floor_textures) return; auto& utt = models_texture; 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; utt.tvertices.push_back(glhr::makevertex(0, factor, 0)); } +#endif } vector scaleshape(const vector& vh, ld s) { @@ -834,12 +836,14 @@ void geometry_information::make_3d_models() { eyepos = WDIM == 2 ? 0.875 : 0.925; DEBBI(DF_POLY, ("make_3d_models")); shcenter = C0; - + +#if CAP_GL if(floor_textures) { auto& utt = models_texture; utt.tvertices.clear(); utt.texture_id = floor_textures->renderedTexture; } +#endif if(WDIM == 2) { DEBB(DF_POLY, ("shadows")); diff --git a/basegraph.cpp b/basegraph.cpp index 7ff50cf4..b1d80884 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -216,6 +216,12 @@ EX color_t darkena(color_t c, int lev, int a) { void setcameraangle(bool b) { } #endif +#if !CAP_GL +EX void reset_projection() { } +EX void glflush() { } +EX bool model_needs_depth() { return false; } +#endif + #if CAP_GL #if CAP_VR @@ -1034,7 +1040,7 @@ EX void do_setfsize() { } EX void disable_vsync() { -#if !ISMOBWEB +#if CAP_SDL && CAP_GL && !ISMOBWEB SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 ); #endif } diff --git a/commandline.cpp b/commandline.cpp index b53f9267..c78d5f81 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -154,7 +154,9 @@ int arg::readCommon() { else if(argis("-rsrc")) { PHASE(1); shift(); rsrcdir = args(); } else if(argis("-nogui")) { PHASE(1); noGUI = true; } #ifndef EMSCRIPTEN +#if CAP_SDL else if(argis("-font")) { PHASE(1); shift(); fontpath = args(); } +#endif #endif else if(argis("-test")) diff --git a/config.cpp b/config.cpp index 3e4e2818..3127cb35 100644 --- a/config.cpp +++ b/config.cpp @@ -910,7 +910,9 @@ string solhelp() { } EX void edit_sightrange() { + #if CAP_RUG USING_NATIVE_GEOMETRY_IN_RUG; + #endif if(vid.use_smart_range) { 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"), ""); @@ -2403,8 +2405,10 @@ EX int read_config_args() { // non-configurable options else if(argis("-vsync_off")) { + #if CAP_SDL && CAP_GL vsync_off = true; if(curphase == 3) setvideomode(); + #endif } else if(argis("-aura")) { PHASEFROM(2); diff --git a/control.cpp b/control.cpp index 7978944d..0d3f490b 100644 --- a/control.cpp +++ b/control.cpp @@ -342,7 +342,7 @@ EX void full_rotate_camera(int dir, ld val) { history::lvspeed += (dir?1:-1) * val / 2; else if(GDIM == 3 && rshiftclick) 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()) crystal::apply_rotation(cspin(dir, 2, val)); #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 CAP_RUG rug::using_rugview urv; + #endif #if !ISPANDORA if(!smooth_scrolling) { diff --git a/crystal.cpp b/crystal.cpp index 16a58d97..171f672c 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -1182,6 +1182,7 @@ EX void flip_z() { crug_rotation[i][2] *= -1; } +#if CAP_RUG hyperpoint coord_to_flat(ldcoord co, int dim = 3) { auto& cs = crystal_map()->cs; hyperpoint res = Hypc; @@ -1314,6 +1315,7 @@ EX void build_rugdata() { println(hlog, "cut ", cut_level, "r ", crug_rotation); } +#endif EX void set_land(cell *c) { 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::bound_low(0); }); +#if CAP_RUG if(cryst && WDIM == 2) { dialog::addBoolItem(XLAT("3D display"), rug::rugged, 'r'); dialog::add_action_push(rug::show); @@ -1499,6 +1502,7 @@ EX void show() { }); } else dialog::addBreak(100); +#endif dialog::addSelItem(XLAT("Crystal torus"), its(crystal_period), 'C'); dialog::add_action([] { dialog::editNumber(crystal_period, 0, 16, 2, 0, XLAT("Crystal torus"), diff --git a/debug.cpp b/debug.cpp index 53ee3134..4671af83 100644 --- a/debug.cpp +++ b/debug.cpp @@ -858,7 +858,9 @@ int read_cheat_args() { shift(); steplimit = argi(); } else if(argis("-dgl")) { + #if CAP_GL glhr::debug_gl = true; + #endif } else if(argis("-mgen-off")) { PHASEFROM(3); diff --git a/drawing.cpp b/drawing.cpp index cf885301..32071044 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -240,7 +240,7 @@ EX void glflush() { } #endif -#if !ISMOBILE +#if CAP_SDL && !ISMOBILE SDL_Surface *aux; #endif @@ -743,7 +743,9 @@ EX void set_width(ld w) { #if MINIMIZE_GL_CALLS if(w != glhr::current_linewidth) glflush(); #endif + #if CAP_GL glhr::set_linewidth(w); + #endif } // this part makes cylindrical projections on the sphere work @@ -1400,10 +1402,12 @@ void dqi_poly::draw() { } #endif + #if CAP_GL if(in_s2xe() && vid.usingGL && pmodel == mdPerspective && (current_display->set_all(global_projection), (get_shader_flags() & SF_DIRECT))) { s2xe::draw_s2xe(this); return; } + #endif dynamicval bs(hr::band_shift, band_shift); if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { @@ -1990,6 +1994,7 @@ EX void draw_main() { if(stretch::factor) return; } + #if CAP_GL for(int p: {1, 0, 2, 3}) { if(elliptic && p < 2) continue; glhr::set_depthwrite(true); @@ -2021,6 +2026,7 @@ EX void draw_main() { } // glflush(); } + #endif } else { DEBB(DF_GRAPH, ("draw_main1")); @@ -2043,6 +2049,7 @@ EX void draw_main() { } glflush(); +#if CAP_RAY if(ray::in_use && ray::comparison_mode) { glDepthFunc(GL_LEQUAL); #ifdef GLES_ONLY @@ -2053,6 +2060,7 @@ EX void draw_main() { glClear(GL_DEPTH_BUFFER_BIT); ray::cast(); } +#endif } } @@ -2136,15 +2144,20 @@ EX void drawqueue() { #if CAP_VR if(callhandlers(false, hooks_vr)) {} else #endif + #if CAP_GL if(model_needs_depth() && current_display->stereo_active()) { global_projection = -1; draw_main(); + #if CAP_GL glClear(GL_DEPTH_BUFFER_BIT); + #endif global_projection = +1; draw_main(); global_projection = 0; } - else { + else +#endif + { draw_main(); } diff --git a/floorshapes.cpp b/floorshapes.cpp index 8be330a4..425dd4d5 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -1012,7 +1012,13 @@ auto floor_hook = #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; diff --git a/geometry.cpp b/geometry.cpp index f4f5afd5..cb3964ac 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -902,7 +902,9 @@ EX void apply_always3() { #if MAXMDIM >= 4 EX void switch_always3() { if(dual::split(switch_always3)) return; + #if CAP_GL if(rug::rugged) rug::close(); + #endif vid.always3 = !vid.always3; apply_always3(); swapmatrix(View); @@ -933,7 +935,9 @@ EX void switch_always3() { EX void switch_fpp() { #if MAXMDIM >= 4 + #if CAP_GL if(rug::rugged) rug::close(); + #endif if(dual::split(switch_fpp)) return; check_cgi(); cgi.require_basics(); View = inverse(models::rotmatrix()) * View; diff --git a/glhr.cpp b/glhr.cpp index a8a9f9fa..65a162cc 100644 --- a/glhr.cpp +++ b/glhr.cpp @@ -11,6 +11,41 @@ #include "hyper.h" 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(x, y, z, 1); + #endif + } +#endif + +EX } + +#if CAP_GL #ifndef DEBUG_GL #define DEBUG_GL 0 #endif @@ -55,16 +90,6 @@ struct glmatrix { const array& as_stdarray() const { return *(array*)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(x, y, z, 1); - #endif - } - struct colored_vertex { glvertex coords; glvec4 color; @@ -105,12 +130,6 @@ glvertex pointtogl(const hyperpoint& t); #endif -#if CAP_SHADER -EX bool noshaders = false; -#else -EX bool noshaders = true; -#endif - bool glew = false; bool current_depthtest, current_depthwrite; @@ -647,20 +666,6 @@ void init() { #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 template void bindbuffer(T& v) { if(current_vertices == buffered_vertices || current_vertices == nullptr) { @@ -839,7 +844,7 @@ EX void oldvertices(GLfloat *f, int qty) { ) } - +#endif } #define glMatrixMode DISABLED diff --git a/graph.cpp b/graph.cpp index decb34f7..4ec77a31 100644 --- a/graph.cpp +++ b/graph.cpp @@ -2943,9 +2943,11 @@ void sumaura(int v) { aurac[AURA][v] = aurac[0][v]; } +#if CAP_GL vector auravertices; +#endif -void drawaura() { +EX void drawaura() { DEBBI(DF_GRAPH, ("draw aura")); if(!haveaura()) return; if(vid.stereo_mode) return; diff --git a/hprint.cpp b/hprint.cpp index 2b7de854..5afcc922 100644 --- a/hprint.cpp +++ b/hprint.cpp @@ -227,7 +227,7 @@ template void print(hstream& hs, const tuple & t) { inline void special_log(char c) { if(debugfile) fputc(c, debugfile); putchar(c); } #endif -#if !CAP_SDL && !ISFAKEMOBILE +#if !CAP_SDL && CAP_TIMEOFDAY int SDL_GetTicks(); #endif diff --git a/hyper.h b/hyper.h index 5457a62b..d0729caf 100644 --- a/hyper.h +++ b/hyper.h @@ -687,7 +687,11 @@ enum orbAction { roMouse, roKeyboard, roCheck, roMouseForce, roMultiCheck, roMul #define MODELCOUNT ((int) mdGUARD) #define pconf vid.projection_config +#if CAP_RUG #define vpconf (rug::rugged ? vid.rug_config : vid.projection_config) +#else +#define vpconf pconf +#endif #define pmodel (pconf.model) color_t darkena(color_t c, int lev, int a); diff --git a/hypgraph.cpp b/hypgraph.cpp index caafb0f0..8054db8a 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -33,7 +33,11 @@ EX bool non_spatial_model() { return true; if(pmodel == mdSpiral && euclid) return true; + #if CAP_GL 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)) { @@ -1345,7 +1349,7 @@ EX void centerpc(ld aspd) { if(subscreens::split([=] () {centerpc(aspd);})) return; if(dual::split([=] () { centerpc(aspd); })) return; - #if CAP_CRYSTAL + #if CAP_CRYSTAL && CAP_RUG if(cryst) crystal::centerrug(aspd); #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 */ EX void enable_flat_model() { + #if CAP_GL glClear(GL_DEPTH_BUFFER_BIT); + #endif pmodel = flat_model(); pconf.alpha = 1; pconf.scale = 1; diff --git a/mapeditor.cpp b/mapeditor.cpp index 5cf21b2e..a225ecea 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1607,7 +1607,6 @@ namespace mapeditor { void drawHandleKey(int sym, int uni); -#if CAP_TEXTURE 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}; @@ -1626,7 +1625,6 @@ namespace mapeditor { 0x404040FF, 0x804000FF }; -#endif bool area_in_pi = false; @@ -2367,11 +2365,13 @@ namespace mapeditor { else if(mousekey == 'l' || mousekey == 'c') { if(!holdmouse) lstart = mouseh, lstartcell = mouseover, holdmouse = true; } +#if CAP_TEXTURE else if(intexture) { if(!holdmouse) texture::config.data.undoLock(); texture::drawPixel(mouseover, mouseh, tcolor); holdmouse = true; lstartcell = NULL; } +#endif else { dt_add_free(mouseh); holdmouse = true; @@ -2380,6 +2380,7 @@ namespace mapeditor { if(sym == PSEUDOKEY_RELEASE) { printf("release\n"); +#if CAP_TEXTURE if(mousekey == 'l' && intexture) { texture::config.data.undoLock(); texture::where = mouseover; @@ -2387,10 +2388,13 @@ namespace mapeditor { texture::drawLine(mouseh, lstart, tcolor); lstartcell = NULL; } - else if(mousekey == 'l') { + else +#endif + if(mousekey == 'l') { dt_add_line(mouseh, lstart, 10); lstartcell = NULL; } +#if CAP_TEXTURE else if(mousekey == 'c' && intexture) { texture::config.data.undoLock(); ld rad = hdist(lstart, mouseh); @@ -2402,6 +2406,7 @@ namespace mapeditor { texture::drawPixel(T * xspinpush0(2 * M_PI * i / circp, rad), tcolor); lstartcell = NULL; } +#endif else if(mousekey == 'c') { dt_add_circle(lstart, mouseh); lstartcell = NULL; @@ -2418,12 +2423,14 @@ namespace mapeditor { if(uni >= 2000 && uni < 2010) dtwidth = brush_sizes[uni - 2000]; +#if CAP_TEXTURE if(uni == '0') texture::texturesym = !texture::texturesym; if(uni == 'u') { texture::config.data.undo(); } +#endif if(uni == 'p') { if(!clickused) diff --git a/models.cpp b/models.cpp index 3974d4f2..0c7c5f32 100644 --- a/models.cpp +++ b/models.cpp @@ -343,7 +343,9 @@ EX namespace models { cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; gamescreen(0); dialog::init(XLAT("models & projections")); + #if CAP_RUG USING_NATIVE_GEOMETRY_IN_RUG; + #endif for(int i=0; i(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; } #endif + #endif for(auto& d: tdata) ad.second.push_back(d); } @@ -482,6 +484,7 @@ EX always_false in; int gps = 0; for(auto& p: gradient_position) p.second = gps++; + #if CAP_TEXTURE fts_int = floor_texture_square_size * FLOORTEXTURESIZE + 4; fts = 64; @@ -490,6 +493,7 @@ EX always_false in; fts_row = (fts-gps)/fts_int; #endif + #endif for(auto& p: ptds) { auto p2 = dynamic_cast(&*p); @@ -642,9 +646,7 @@ void set_shotx() { } } -#if CAP_SDL EX int shot_aa = 1; -#endif EX void default_screenshot_content() { #if CAP_RUG @@ -664,9 +666,11 @@ EX void default_screenshot_content() { drawStats(); } +#if CAP_SDL 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); } +#endif #if CAP_PNG @@ -957,12 +961,18 @@ EX void menu() { #if CAP_WRL if(!models::is_3d(vpconf) && !rug::rugged) { dialog::addInfo("this format is for 3D projections", 0xFF0000); + #if CAP_RUG if(GDIM == 2) { dialog::addItem(XLAT("hypersian rug mode"), 'u'); dialog::add_action_push(rug::show); } + #endif } + #if CAP_RUG 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::addSelItem(XLAT("projection"), current_proj_name(), '1'); dialog::add_action_push(models::model_menu); @@ -1825,12 +1835,14 @@ startanim rug { "Hypersian Rug", [] { pick(); #endif }, [] { + #if CAP_RUG dynamicval b(rug::rugged, true); rug::physics(); dynamicval t(rug::rugView, cspin(1, 2, ticks / 3000.) * rug::rugView); gamescreen(2); if(!rug::rugged) current = &null_animation; explorable([] { rug::rugged = true; pushScreen(rug::show); }); + #endif }}; startanim spin_around { "spinning around", no_init, [] { diff --git a/shaders.cpp b/shaders.cpp index df43f377..4cce19ef 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -11,6 +11,7 @@ namespace hr { EX ld levellines; EX bool disable_texture; +#if CAP_GL #if HDR constexpr flagtype GF_TEXTURE = 1; constexpr flagtype GF_VARCOLOR = 2; @@ -546,5 +547,5 @@ EX void glapplymatrix(const transmatrix& V) { glhr::set_modelview(glhr::as_glmatrix(mat)); } - +#endif } diff --git a/sky.cpp b/sky.cpp index cc2496fc..49b8bd82 100644 --- a/sky.cpp +++ b/sky.cpp @@ -2,7 +2,7 @@ namespace hr { -#if MAXMDIM >= 4 +#if MAXMDIM >= 4 && CAP_GL EX ld camera_level; EX int get_skybrightness(int mul IS(1)) { diff --git a/surface.cpp b/surface.cpp index 50d1769e..41067070 100644 --- a/surface.cpp +++ b/surface.cpp @@ -8,9 +8,9 @@ */ #include "hyper.h" -#if CAP_SURFACE namespace hr { +#if CAP_SURFACE EX namespace surface { ld sech(ld d) { return 1 / cosh(d); } @@ -841,9 +841,9 @@ int surface_args() { else return 1; return 0; } +#endif auto surface_hook = addHook(hooks_args, 100, surface_args); -#endif void display_coverage() { @@ -860,5 +860,6 @@ void display_coverage() { auto surface_hook2 = addHook(hooks_frame, 0, display_coverage); -}} +EX } #endif +} diff --git a/sysconfig.h b/sysconfig.h index aa5d6352..e81cc648 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -186,7 +186,7 @@ #endif #ifndef CAP_MODEL -#define CAP_MODEL (!ISMOBWEB && !ISMINI) +#define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDL) #endif #ifndef CAP_SAVE @@ -399,6 +399,7 @@ extern "C" { #define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB) #endif +#if CAP_GL #if CAP_GLEW #include #else @@ -422,6 +423,10 @@ extern "C" { #include #endif #endif +#else +typedef int GLint; +typedef unsigned GLuint; +#endif #include #include @@ -560,7 +565,7 @@ union SDL_Event; #endif #ifndef CAP_RAY -#define CAP_RAY (MAXMDIM >= 4 && !ISWEB && !ISMOBILE) +#define CAP_RAY (MAXMDIM >= 4 && !ISWEB && !ISMOBILE && CAP_GL) #endif #ifndef CAP_MEMORY_RESERVE diff --git a/usershapes.cpp b/usershapes.cpp index e0eb08ca..0aeb2954 100644 --- a/usershapes.cpp +++ b/usershapes.cpp @@ -57,7 +57,7 @@ void geometry_information::pushShape(usershapelayer& ds) { if(GDIM == 2) hpcpush(T * ds.list[0]); - #if MAXMDIM >= 4 + #if MAXMDIM >= 4 && CAP_GL if(GDIM == 3) { auto& utt = user_triangles_texture; utt.texture_id = floor_textures->renderedTexture; diff --git a/util.cpp b/util.cpp index 91225a46..c7eae10d 100644 --- a/util.cpp +++ b/util.cpp @@ -13,7 +13,7 @@ namespace hr { int lastusec; int uticks; -int SDL_GetTicks() { +EX int SDL_GetTicks() { struct timeval tim; gettimeofday(&tim, NULL); int newusec = tim.tv_usec;