I'm having a problem with my struct I believe.

struct GLPoint
{
  int x;
  int y;
};

int totalmarbles = 64;
GLPoint midhold[64];

double dist(GLPoint a, GLPoint b)
{
   double distance = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
   return distance;
}


void init(void) 
{
   glClearColor (1.0, 1.0, 1.0, 0.0);
   glShadeModel (GL_SMOOTH);
}



GLPoint mid(GLPoint A, GLPoint B)
{
   GLPoint midpt = ((A.x + B.x)/2, (A.y + B.y)/2);
   return midpt;
}

void storemids(int q, GLPoint A)
{ 
   midhold[q] = A;
}

void vertices()
{
  int total = 0;
  int x = 0; int y = 0;
  int x1, y1, x2, y2, x3, y3, x4, y4;
  x1 = x; y1 = y;
  x2 = x + 100; y2 = y;
  x3 = x + 100; y3 = y + 100;
  x4 = x; y4 = y + 100;
  GLPoint P = (x1, y1);
  GLPoint Q = (x2, y2);
  GLPoint R = (x3, y3);
  GLPoint S = (x4, y4);
  GLPoint vertices[totalmarbles];
  vertices[total] = P; vertices[total+1] = Q;
  vertices[total+2] = R; vertices[total+3] = S;
  total += 4;
  while(y < 600)
  {
    while(x <= 700)
    {
      x += 100;
      x1 = x; y1 = y;
      x2 = x + 100; y2 = y;
      x3 = x + 100; y3 = y + 100;
      x4 = x; y4 = y + 100;
      GLPoint P = (x1, y1);
      GLPoint Q = (x2, y2);
      GLPoint R = (x3, y3);
      GLPoint S = (x4, y4);
      vertices[i] = P; vertices[i+1] = Q;
      vertices[i+2] = R; vertices[i+3] = S;
      total += 4;
     }
    x = 0; y += 75;
    x1 = x; y1 = y;
    x2 = x + 100; y2 = y;
    x3 = x + 100; y3 = y + 100;
    x4 = x; y4 = y + 100;
    GLPoint P = (x1, y1);
    GLPoint Q = (x2, y2);
    GLPoint R = (x3, y3);
    GLPoint S = (x4, y4);
    vertices[i] = P; vertices[i+1] = Q;
    vertices[i+2] = R; vertices[i+3] = S;
    total += 4;
    
   }

  while(x <= 700)
   {
     x += 100; y = 700;
     x1 = x; y1 = y;
     x2 = x + 100; y2 = y;
     x3 = x + 100; y3 = y + 100;
     x4 = x; y4 = y + 100;
     GLPoint P = (x1, y1);
     GLPoint Q = (x2, y2);
     GLPoint R = (x3, y3);
     GLPoint S = (x4, y4);
     vertices[i] = P; vertices[i+1] = Q;
     vertices[i+2] = R; vertices[i+3] = S;
     total += 4;
   }

}

And here are my errors

project.cpp:34:49: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp: In function ‘void vertices()’:
project.cpp:52:22: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:53:22: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:54:22: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:55:22: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:69:26: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:70:26: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:71:26: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:72:26: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:73:16: error: ‘i’ was not declared in this scope
project.cpp:82:24: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:83:24: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:84:24: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:85:24: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:86:14: error: ‘i’ was not declared in this scope
project.cpp:99:25: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:100:25: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:101:25: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:102:25: error: conversion from ‘int’ to non-scalar type ‘GLPoint’ requested
project.cpp:103:15: error: ‘i’ was not declared in this scope
project.cpp: In function ‘void drawrectangles()’:
project.cpp:114:24: error: expected primary-expression before ‘int’

You're trying to set GLPoint P, Q, R, and S to just a set of numbers in parenthesis, and your compiler doesn't know what to do with that. You're going to have to make an intializer list of setting these, or if you want a quick and dirty method of fixing it, try this:

GLPoint P = (GLPoint){x1, y1};

And so on. Also, you need to declare the variable i at the beginning of your main function, otherwise it doesn't exist.

I'll try it.
Do you mind me asking how would I go about making an initializer list? Not sure if I heard of it.

This article has been dead for over six months. Start a new discussion instead.