On Mon, 14 Jan 2019 23:20:46 +0100 Christian Weisgerber wrote: > Charlene Wendling: > > > + 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 > > My poor brain. I think this is correct but confusing. It's the > ordering of c[] that is affected by endianness, not the ordering > of cols[]. Also, I think you want { } for clarity. > > for(int i=0; i<4; i++) { > #if SDL_BYTEORDER == SDL_BIG_ENDIAN > cols[i] = c[i] / 255.0 * part; > #else > cols[i] = c[3-i] / 255.0 * part; > #endif > } > > Or maybe just extract the color channels with arithmetic? > > void color2(color_t color, ld part) { > GLfloat cols[4]; > for(int i=0; i<4; i++) > cols[0] = (color >> ((3-i) * 8) & 0xff) / 255.0 * part; > ... > > The next function in shaders.cpp, colorClear(), is also wrong.
Using arithmetic also solves the issue, and in any case is less confusing. colorClear() has been fixed as well. All colors are the same on macppc and amd64(from packages and the patched ports). I'm joining the diff as an attachement this time, due to different line endings used in the code as George said. Charlène. > -- > Christian "naddy" Weisgerber > na...@mips.inka.de >
hyperrogue.diff
Description: Binary data