input system setup, debug header started
[physics.git] / src / graphics.cpp
index 42c2e6d..0f84d20 100644 (file)
@@ -5,15 +5,12 @@
 #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();
 
@@ -30,23 +27,35 @@ void graphicsCleanUp()
 
 }
 
-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)
@@ -74,7 +83,7 @@ void glInit()
     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();