1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

More porting.

This commit is contained in:
Zeno Rogue 2018-01-05 19:05:41 +01:00
parent 3fc196e0c0
commit 86f1a4dead
3 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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);

View File

@ -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<class T> array<T, 3> make_array(T a, T b, T c) { array<T,3> x = {a,b,c}; return x; }
template<class T> array<T, 2> make_array(T a, T b) { array<T,2> x = {a,b}; return x; }
template<class T> array<T, 3> make_array(T a, T b, T c) { array<T,3> x; x[0] = a; x[1] = b; x[2] = c; return x; }
template<class T> array<T, 2> make_array(T a, T b) { array<T,2> x; x[0] = a; x[1] = b; return x; }
void mapTextureTriangle(textureinfo &mi, array<hyperpoint, 3> v, int splits = gsplits) {
if(splits) {
array<hyperpoint, 3> v2 = { mid(v[1], v[2]), mid(v[2], v[0]), mid(v[0], v[1]) };
array<hyperpoint, 3> 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<hyperpoint, 3> mh = {A * xpush(penwidth) * C0, A * spin(step) * xpush(penwidth) * C0, A * spin(-step) * xpush(penwidth) * C0};
array<hyperpoint, 3> 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);