aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-10-30 08:45:55 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-10-30 08:45:55 -0400
commita75a3b2d8f0848a05b09180d9517a8016cbafdde (patch)
tree7a70d92c90dab36deadef1e40a516c54231c116d /src/common.cpp
parent9ab6025a0cc3ab31c476f0b478ac69bfadd7f670 (diff)
day/night cycling
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index cd568ad..a8a964e 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -10,3 +10,25 @@ void DEBUG_prints(const char* file, int line, const char *s,...){
vprintf(s,args);
va_end(args);
}
+
+void safeSetColor(int r,int g,int b){ // safeSetColor() is an alternative to directly using glColor3ub() to set
+ if(r>255)r=255; // the color for OpenGL drawing. safeSetColor() checks for values that are
+ if(g>255)g=255; // outside the range of an unsigned character and sets them to a safer value.
+ if(b>255)b=255;
+ if(r<0)r=0;
+ if(g<0)g=0;
+ if(b<0)b=0;
+ glColor3ub(r,g,b);
+}
+
+void safeSetColorA(int r,int g,int b,int a){
+ if(r>255)r=255;
+ if(g>255)g=255;
+ if(b>255)b=255;
+ if(a>255)a=255;
+ if(r<0)r=0;
+ if(g<0)g=0;
+ if(b<0)b=0;
+ if(a<0)a=0;
+ glColor4ub(r,g,b,a);
+}