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();
}

The issue lies within your function gasket().

On line 34 you are missing an equals sign between point and T, so it should look like

GLPoint point = T[index];

Then when you are adding point.x and t[index] then dividing by 2 you really want to add each component then divide by two. So line 42 and 43 should look like

point.x = (point.x + T[index].x) / 2;
point.y = (point.y + T[index].y) / 2;

Also I'm not sure about you but when I try to compile it gives me a bunch of undefined reference errors about all the OpenGL functions, so at the top I had to put

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

Wow thanks, I did forget an equal sign. All this time I thought I had an error at line 32 so that's why I didn't even look there.
I'm using my school's computer so I believe we have our libraries referenced in the Makefile which makes it where I only need the glut.h to be called when I need it.
Once again, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.