d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C Program > Simply Array Structs Question
Add Reply New Topic New Poll
Member
Posts: 4,917
Joined: Mar 18 2003
Gold: 5,692.75
Sep 22 2012 02:24pm
Taking a course on openGL and am required to write them in C which i havn't used in years. I will pay very well (I will get fg) for help that saves me time learning what I need for the assignment. The assignment is to use openGL to provide a canvas for drawing shapes. The canvas has several modes, each enabling the user to draw and store a different shape by clicking up to three clicked vertices. The shape array is redrawn every time a new shape is stored to the array.
My issue is that my C is rusty and I can't figure out how to store these shapes to an array. So from what I understand I need a few things:

1. write a vertex struct that stores an x and y coordinate
2. Write a shape struct that stores 3 vertices and an int representing the type of shape
3. Allocate an array of shape structs with maxShapes being the maximum index.

Any help with this will be paid VERY VERY well. The more help the more fg. I cannot stress this enough. I am very busy with work this week and can not afford to waste time trying to learn this by trial and error. If you are nice, knowledgeable, and articulate I will likely use you again. PM or post if interested~ I am leaving for work atm and will check this in about 10 hours.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Sep 22 2012 02:39pm
Code
typedef struct
{
    int x;
    int y;
} vertex;

typedef struct
{
     vertex arrVertext[3];
     int shape;
} shape;

#define maxShapes = 10;

int main()
{
int i = 0, ii = 0;
shape arrShape[maxShapes];

srand(time(NULL));

for(i; i < maxShapes; i++)
{
    for(ii; ii < 3; ii++)
    {
         arrShape[i].arrVertex[ii].x = rand % 100;
         arrShape[i].arrVertex[ii].y = rand % 100;
     }

arrShape.shape = 1;
ii = 0;
}

return 0;
}


something like that

This post was edited by AbDuCt on Sep 22 2012 02:39pm
Member
Posts: 7,969
Joined: Jul 7 2008
Gold: 286.54
Sep 22 2012 03:55pm
Quote (AbDuCt @ Sep 22 2012 12:39pm)
Code
typedef struct
{
    int x;
    int y;
} vertex;

typedef struct
{
     vertex arrVertext[3];
     int shape;
} shape;

#define maxShapes = 10;

int main()
{
int i = 0, ii = 0;
shape arrShape[maxShapes];

srand(time(NULL));

for(i; i < maxShapes; i++)
{
    for(ii; ii < 3; ii++)
    {
         arrShape[i].arrVertex[ii].x = rand % 100;
         arrShape[i].arrVertex[ii].y = rand % 100;
     }

arrShape.shape = 1;
ii = 0;
}

return 0;
}


something like that


That's the reason I hated C. :\
Member
Posts: 4,917
Joined: Mar 18 2003
Gold: 5,692.75
Sep 24 2012 02:41pm
Appreciated, pming abduct now :)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll