Hey all, I am currently trying (desperately trying if I might add) learning how to use GLUT for school.
Our professor gave us an assignment to make a 2d tube of some sort, but I only managed to make a circle. The tube will be only displayed on its front so it is basically like a donut, a circle within a circle.
Anyways, so I tried running my code and all, but when I run it I just get a white screen on my newly created window where my object should be, why this happens I do not know.
I have followed a basic tutorial on the internet on how to render a simple shape, but still it won't render properly. I also tried using NeHe's tutorials but I get a bunch of errors with it (errors that I cannot solve unless I erase that template of his that enables a full size window)so I gave studying that one up.
Anyways, I'm getting off topic, here is my code:
#include <windows.h>
#include <gl\gl.h>
#include <gl\glut.h>
#include <math.h>
using namespace std;
typedef struct
{
float x;
float y;
}CIRCLE;
CIRCLE circle;
void DrawCircle(void)
{
int k = 5, r = 5, h = 5;
glBegin(GL_LINES);
for (int i = 0; i < 180; i++)
{
circle.x = r*cos(i) - h;
circle.y = r*sin(i) + k;
glVertex3f((circle.x +k), (circle.y - h), 0);
circle.x = r*cos(i + 0.1) - h;
circle.y = r*sin(i + 0.1) + k;
glVertex3f((circle.x +k), (circle.y - h), 0);
}
glEnd();
}
int main(int argc, char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (800, 600);
glutCreateWindow ("Simple Circle");
glutDisplayFunc(DrawCircle);
glutMainLoop();
}
Please tell me where did I mess up, I just can't display it..I am using Windows 7 professional btw, if that informations is useful.
Thanks!