#include <SDL/SDL.h>
#include <cmath>
-#include <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
-
+#include "debug.h"
static const float PI = 3.1415926535897;
/// ***** Private Method Headers *****
+void drawCircle(int);
void sdlInit();
void glInit();
}
-void glDrawCircle()
+void glDrawCircle(float radius, float x, float y, const float* color)
{
- int num = 32;
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(x, y, -1);
+ glScalef(radius, radius, radius);
+
+ if(color != NULL)
+ glColor3fv(color);
+
+ drawCircle(32);
+}
+
+/// ***** Private Methods *****
+void drawCircle(int pieces)
+{
glBegin(GL_POLYGON);
- for(int n = 0; n < num; n++)
+ for(int n = 0; n < pieces; n++)
{
- float angle = 2 * PI * n / num;
- float x = cos(angle);
- float y = sin(angle);
+ float angle = 2 * PI * n / pieces;
+ float ix = cos(angle);
+ float iy = sin(angle);
- glVertex3f(x, y, -1);
+ glVertex3f(ix, iy, 0);
}
glEnd();
}
-/// ***** Private Methods *****
void sdlInit()
{
if(SDL_Init(SDL_INIT_VIDEO) < 0)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(-20.0, 20.0, -15.0, 15.0, -0.01, 1.01);
+ glOrtho(0, 800.0, 600.0, 0.0, -0.01, 1.01);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();