minor fixes to color handling

This commit is contained in:
Zeno Rogue 2019-02-06 18:39:53 +01:00
parent 9cee52cf81
commit 952f1c44fe
4 changed files with 6 additions and 12 deletions

View File

@ -306,8 +306,7 @@ void setGLProjection(color_t col) {
DEBB(DF_GRAPH, (debugfile,"setGLProjection\n"));
GLERR("pre_setGLProjection");
unsigned char *c = (unsigned char*) (&col);
glClearColor(c[2] / 255.0, c[1] / 255.0, c[0]/255.0, 1);
glClearColor(part(col, 2) / 255.0, part(col, 1) / 255.0, part(col, 0) / 255.0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLERR("setGLProjection #1");

View File

@ -3716,7 +3716,7 @@ namespace glhr {
void set_depthtest(bool b);
glmatrix translate(ld x, ld y, ld z);
void color2(color_t color, ld part = 1);
void color2(color_t color, ld scale = 1);
void be_nontextured(shader_projection sp = new_shader_projection);
void be_textured(shader_projection sp = new_shader_projection);
void set_modelview(const glmatrix& m);

View File

@ -53,7 +53,7 @@ namespace svg {
}
}
char* stylestr(unsigned int fill, unsigned int stroke, ld width=1) {
char* stylestr(color_t fill, color_t stroke, ld width=1) {
fixgamma(fill);
fixgamma(stroke);
static char buf[600];

View File

@ -340,10 +340,10 @@ void id_modelview() {
#endif
void color2(color_t color, ld part) {
void color2(color_t color, ld scale) {
GLfloat cols[4];
for(int i=0; i<4; i++)
cols[i] = (color >> ((3-i) * 8) & 0xff) / 255.0 * part;
cols[i] = part(color, 3-i) / 255.0 * scale;
#if CAP_SHADER
// glUniform4fv(current->uFog, 4, cols);
if(!current) return;
@ -354,12 +354,7 @@ 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
glClearColor(part(color, 3) / 255.0, part(color, 2) / 255.0, part(color, 1) / 255.0, part(color, 0) / 255.0);
}
void be_nontextured(shader_projection sp) { switch_mode(gmColored, sp); }