Hi,
I am trying to write a program to draw the Serpinski Gasket. The code compiles fine but then when I run the program all I get is an empty, see-through window (not a pretty fractal).
Why is this?
Here is my code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <gl/gl.h>
#include <gl/glut.h>
class GLintPoint{
public:
GLint x, y;
};
void myInit(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}
void drawDot(GLint x , GLint y)
{
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
}
void Sierpinski(void)
{
GLintPoint T[3]= {(10,10), (300,30), (200, 300)};
int index = random(3);
GLintPoint point = T[index];
drawDot(point.x, point.y);
for(int i = 0; i < 1000; i++)
{
index = random(3);
point.x = (point.x + T[index].x) / 2;
point.y = (point.y = T[index].y) / 2;
drawDot(point.x, point.y);
}
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 150);
glutCreateWindow(“The Sierpinski Gasket”);
glutDisplayFunc(Sierpinski);
myInit();
glutMainLoop();
}
Its my first proper OpenGL program so its probably something really simple.
Phil