1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

Fix colors for big endian architectures.

This commit is contained in:
Charlène 2019-01-16 23:15:40 +01:00 committed by Zeno Rogue
parent 87240cf990
commit 9cee52cf81
2 changed files with 13 additions and 4 deletions

View File

@ -766,7 +766,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;

View File

@ -341,9 +341,9 @@ void id_modelview() {
#endif
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++)
cols[i] = (color >> ((3-i) * 8) & 0xff) / 255.0 * part;
#if CAP_SHADER
// glUniform4fv(current->uFog, 4, cols);
if(!current) return;
@ -355,8 +355,12 @@ void color2(color_t color, ld part) {
void colorClear(color_t color) {
unsigned char *c = (unsigned char*) (&color);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
glClearColor(c[0] / 255.0, c[1] / 255.0, c[2]/255.0, c[3] / 255.0);
#else
glClearColor(c[3] / 255.0, c[2] / 255.0, c[1]/255.0, c[0] / 255.0);
}
#endif
}
void be_nontextured(shader_projection sp) { switch_mode(gmColored, sp); }
void be_textured(shader_projection sp) { switch_mode(gmTextured, sp); }