mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-12 10:20:32 +00:00
More porting.
This commit is contained in:
parent
3fc196e0c0
commit
86f1a4dead
2
init.cpp
2
init.cpp
@ -157,7 +157,7 @@
|
|||||||
#define PSEUDOKEY_RELEASE 2503
|
#define PSEUDOKEY_RELEASE 2503
|
||||||
|
|
||||||
#ifndef CAP_PNG
|
#ifndef CAP_PNG
|
||||||
#define CAP_PNG (!ISMOBWEB && !ISMAC && CAP_SDLGFX)
|
#define CAP_PNG (!ISMOBWEB)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CAP_COMMANDLINE
|
#ifndef CAP_COMMANDLINE
|
||||||
|
4
rug.cpp
4
rug.cpp
@ -751,7 +751,7 @@ void preset(rugpoint *m) {
|
|||||||
|
|
||||||
if(q>0) m->flat = h/q;
|
if(q>0) m->flat = h/q;
|
||||||
// printf("preset (%d) -> %s\n", q, display(m->flat));
|
// 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();
|
throw rug_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ void subdivide() {
|
|||||||
rugpoint *m2 = m->edges[j].target;
|
rugpoint *m2 = m->edges[j].target;
|
||||||
if(m2 < m) continue;
|
if(m2 < m) continue;
|
||||||
rugpoint *mm = addRugpoint(mid(m->h, m2->h), (m->dist+m2->dist)/2);
|
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)) {
|
if(!good_shape || (torus && !keep_shape)) {
|
||||||
using namespace hyperpoint_vec;
|
using namespace hyperpoint_vec;
|
||||||
normalizer n(m->flat, m2->flat);
|
normalizer n(m->flat, m2->flat);
|
||||||
|
17
textures.cpp
17
textures.cpp
@ -131,10 +131,13 @@ bool readtexture() {
|
|||||||
|
|
||||||
#elif CAP_PNG
|
#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);
|
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if(!png) return false;
|
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);
|
png_init_io(png, f);
|
||||||
|
|
||||||
// set the expected format
|
// set the expected format
|
||||||
@ -237,17 +240,17 @@ int color_alpha = 128;
|
|||||||
|
|
||||||
int gsplits = 1;
|
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, 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 = {a,b}; 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) {
|
void mapTextureTriangle(textureinfo &mi, array<hyperpoint, 3> v, int splits = gsplits) {
|
||||||
|
|
||||||
if(splits) {
|
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[0], v2[2], v2[1]), splits-1);
|
||||||
mapTextureTriangle(mi, make_array(v[1], v2[0], v2[2]), 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[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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,7 +1150,7 @@ void fillcircle(hyperpoint h, int col) {
|
|||||||
|
|
||||||
ld step = M_PI * 2/3;
|
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);
|
auto mp = ptc(mh);
|
||||||
|
|
||||||
filltriangle(mh, mp, col, 0);
|
filltriangle(mh, mp, col, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user