On Mon, 14 Jan 2019 13:18:47 +0100
Christian Weisgerber wrote:

> George Koehler:
> 
> > -  unsigned char* c = (unsigned char*) &col; return c[i];
> > +  unsigned char* c = (unsigned char*) &col;
> > +#ifdef __BIG_ENDIAN__
> > +  return c[sizeof(col) - i];
> > +#else
> > +  return c[i];
> > +#endif
> >    }
> 
> Off by one:
>   return c[sizeof(col) - 1 - i];
> 
> __BIG_ENDIAN__ is nonstandard.  Normally, I'd suggest an
> endian.h-based check, but elsewhere in this code base there's
> already...
> 
>   #if SDL_BYTEORDER == SDL_BIG_ENDIAN
> 
> ... so let's use that idiom.
> 
> -- 
> Christian "naddy" Weisgerber
> na...@mips.inka.de
> 

Hi, 

Thanks to you two. It has fixed the textured mode, but not the OpenGL
one. I've found how to fix it as well, so there is an extra patch.
I tried to keep the #ifdef styling the same as upstream. 

It builds and runs fine on macppc and amd64 [1].

Charlène.

[1] https://bsd.network/@julianaito/101416387255881269


Index: Makefile
===================================================================
RCS file: /cvs/ports/games/hyperrogue/Makefile,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 Makefile
--- Makefile    21 Nov 2018 01:58:38 -0000      1.8
+++ Makefile    14 Jan 2019 18:15:53 -0000
@@ -2,6 +2,7 @@
 
 COMMENT =      roguelike game in a non-Euclidean world
 CATEGORIES =   games x11
+REVISION =     0
 
 GH_ACCOUNT =   zenorogue
 GH_PROJECT =   hyperrogue
@@ -17,7 +18,7 @@ WANTLIB += ${COMPILER_LIBCXX} GL GLEW SD
 WANTLIB += c m png
 
 # C++11
-COMPILER =     base-clang ports-clang ports-gcc
+COMPILER =     base-clang ports-gcc
 
 BUILD_DEPENDS =        ${MODGNU_AUTOCONF_DEPENDS} \
                ${MODGNU_AUTOMAKE_DEPENDS}
Index: patches/patch-polygons_cpp
===================================================================
RCS file: patches/patch-polygons_cpp
diff -N patches/patch-polygons_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-polygons_cpp  14 Jan 2019 18:15:53 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+Fix colors on big-endian machines in non-OpenGL mode.
+Index: polygons.cpp
+--- polygons.cpp.orig
++++ polygons.cpp
+@@ -762,7 +762,12 @@ void fixMercator(bool tinf) {
+   }
+   
+ unsigned char& part(color_t& col, int i) {
+-  unsigned char* c = (unsigned char*) &col; return c[i];
++  unsigned char* c = (unsigned char*) &col;
++#if SDL_BYTEORDER == SDL_BIG_ENDIAN
++  return c[sizeof(col) - 1 - i];
++#else
++  return c[i];
++#endif
+   }
+ 
+ bool in_twopoint = false;
Index: patches/patch-shaders_cpp
===================================================================
RCS file: patches/patch-shaders_cpp
diff -N patches/patch-shaders_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-shaders_cpp   14 Jan 2019 18:15:53 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+Fix colors on big-endian machines in OpenGL mode.
+Index: shaders.cpp
+--- shaders.cpp.orig
++++ shaders.cpp
+@@ -341,7 +341,12 @@ void id_modelview() {
+ void color2(color_t color, ld part) {
+   unsigned char *c = (unsigned char*) (&color);
+   GLfloat cols[4];
+-  for(int i=0; i<4; i++) cols[i] = c[3-i] / 255.0 * part;
++  for(int i=0; i<4; i++) 
++    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
++    cols[3-i] = c[3-i] / 255.0 * part;
++    #else
++    cols[i] = c[3-i] / 255.0 * part;
++    #endif
+   #if CAP_SHADER
+   // glUniform4fv(current->uFog, 4, cols);
+   glUniform4f(current->uColor, cols[0], cols[1], cols[2], cols[3]);




Reply via email to