From 86f1a4deadba12193afb1990f4ce5f01fc4e3c05 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 5 Jan 2018 19:05:41 +0100 Subject: [PATCH] More porting. --- init.cpp | 2 +- rug.cpp | 4 ++-- textures.cpp | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/init.cpp b/init.cpp index 6cbb6a72..27c45637 100644 --- a/init.cpp +++ b/init.cpp @@ -157,7 +157,7 @@ #define PSEUDOKEY_RELEASE 2503 #ifndef CAP_PNG -#define CAP_PNG (!ISMOBWEB && !ISMAC && CAP_SDLGFX) +#define CAP_PNG (!ISMOBWEB) #endif #ifndef CAP_COMMANDLINE diff --git a/rug.cpp b/rug.cpp index 96913687..045b6eda 100644 --- a/rug.cpp +++ b/rug.cpp @@ -751,7 +751,7 @@ void preset(rugpoint *m) { if(q>0) m->flat = h/q; // printf("preset (%d) -> %s\n", q, display(m->flat)); - if(isnan(m->flat[0]) || isnan(m->flat[1]) || isnan(m->flat[2])) + if(std::isnan(m->flat[0]) || std::isnan(m->flat[1]) || std::isnan(m->flat[2])) throw rug_exception(); } @@ -839,7 +839,7 @@ void subdivide() { rugpoint *m2 = m->edges[j].target; if(m2 < m) continue; rugpoint *mm = addRugpoint(mid(m->h, m2->h), (m->dist+m2->dist)/2); - halves[{m, m2}] = mm; + halves[make_pair(m, m2)] = mm; if(!good_shape || (torus && !keep_shape)) { using namespace hyperpoint_vec; normalizer n(m->flat, m2->flat); diff --git a/textures.cpp b/textures.cpp index 90a48ed8..4fab40a0 100644 --- a/textures.cpp +++ b/textures.cpp @@ -131,10 +131,13 @@ bool readtexture() { #elif CAP_PNG - FILE *f = fopen(texturename.c_str(), "r"); + FILE *f = fopen(texturename.c_str(), "rb"); png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!png) return false; - if(setjmp(png_jmpbuf(png))) return false; + if(setjmp(png_jmpbuf(png))) { + printf("failed to read\n"); + return false; + } png_init_io(png, f); // set the expected format @@ -237,17 +240,17 @@ int color_alpha = 128; int gsplits = 1; -template array make_array(T a, T b, T c) { array x = {a,b,c}; return x; } -template array make_array(T a, T b) { array x = {a,b}; return x; } +template array make_array(T a, T b, T c) { array x; x[0] = a; x[1] = b; x[2] = c; return x; } +template array make_array(T a, T b) { array x; x[0] = a; x[1] = b; return x; } void mapTextureTriangle(textureinfo &mi, array v, int splits = gsplits) { if(splits) { - array v2 = { mid(v[1], v[2]), mid(v[2], v[0]), mid(v[0], v[1]) }; + array v2 = make_array( mid(v[1], v[2]), mid(v[2], v[0]), mid(v[0], v[1]) ); mapTextureTriangle(mi, make_array(v[0], v2[2], v2[1]), splits-1); mapTextureTriangle(mi, make_array(v[1], v2[0], v2[2]), splits-1); mapTextureTriangle(mi, make_array(v[2], v2[1], v2[0]), splits-1); - mapTextureTriangle(mi, make_array(v[1], v2[0], v2[2]), splits-1); + mapTextureTriangle(mi, make_array(v2[0], v2[1], v2[2]), splits-1); return; } @@ -1147,7 +1150,7 @@ void fillcircle(hyperpoint h, int col) { ld step = M_PI * 2/3; - array mh = {A * xpush(penwidth) * C0, A * spin(step) * xpush(penwidth) * C0, A * spin(-step) * xpush(penwidth) * C0}; + array mh = make_array(A * xpush(penwidth) * C0, A * spin(step) * xpush(penwidth) * C0, A * spin(-step) * xpush(penwidth) * C0); auto mp = ptc(mh); filltriangle(mh, mp, col, 0);