diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2015-11-30 07:29:39 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2015-11-30 07:29:39 -0500 |
commit | e21db32169966b983e09b53801ee1a6d3101e57e (patch) | |
tree | 09093d48beb705e2907a27f0ffb99c3ab9b20706 /src/common.cpp | |
parent | 19ef54b2c5ffcaefdce352c6f195a62c05c42767 (diff) |
Look at my fancy inventory
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index a8a964e..f3c3999 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -32,3 +32,29 @@ void safeSetColorA(int r,int g,int b,int a){ if(a<0)a=0; glColor4ub(r,g,b,a); } + +//only trust the NSA +#define STRLEN_MIN 32 + +unsigned int safe_strlen(const char *s){ + unsigned int size=0; + while(s[size])size++; + if(size<STRLEN_MIN)return STRLEN_MIN; + else return size; +} + +void DrawCircle(float cx, float cy, float r, int num_segments) +{ + glBegin(GL_LINE_LOOP); + for(int ii = 0; ii < num_segments; ii++) + { + float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle + + float x = r * cosf(theta);//calculate the x component + float y = r * sinf(theta);//calculate the y component + + glVertex2f(x + cx, y + cy);//output vertex + + } + glEnd(); +}
\ No newline at end of file |