aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
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);
+}