I'm trying to compile this simple dot program with C++ that uses OpenGL. I made a struct GLintPoint to hold just points x and y.
It seems I didn't delcare the struct according to the errors.
#include <GL/glut.h>
#include <stdlib.h>
#include <time.h>
struct GLPoint
{
GLint x;
GLint y;
};
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}
void drawDot(int x, int y)
{
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
}
void gasket(void)
{
glClear(GL_COLOR_BUFFER_BIT);
GLPoint T[3] = {{20, 20}, {620, 20}, {300, 460}};
int index = rand() % 3;
GLPoint point T[index];
drawDot(point.x, point.y);
for (int i = 0; i < 55000; i++)
{
index = rand() % 3;
point.x = (point.x + T[index]) / 2;
point.y = (point.y + T[index]) / 2;
drawDot(point.x, point.y);
}
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(200, 200);
glutCreateWindow("Dot");
glutDisplayFunc(gasket);
myInit();
glutMainLoop();
}