I found some tutorial code how to create a sphere using Opengl API's.

- Code: Select all
`typedef struct`

{

int X;

int Y;

int Z;

double U;

double V;

}VERTICES;

void CreateSphere (double R, double H, double K, double Z) {

int n;

double a;

double b;

n = 0;

for( b = 0; b <= 90 - space; b+=space){

for( a = 0; a <= 360 - space; a+=space){

VERTEX[n].X = R * sin((a) / 180 * PI) * sin((b) / 180 * PI) - H;

VERTEX[n].Y = R * cos((a) / 180 * PI) * sin((b) / 180 * PI) + K;

VERTEX[n].Z = R * cos((b) / 180 * PI) - Z;

VERTEX[n].V = (2 * b) / 360;

VERTEX[n].U = (a) / 360;

n++;

VERTEX[n].X = R * sin((a) / 180 * PI) * sin((b + space) / 180 * PI) - H;

VERTEX[n].Y = R * cos((a) / 180 * PI) * sin((b + space) / 180 * PI) + K;

VERTEX[n].Z = R * cos((b + space) / 180 * PI) - Z;

VERTEX[n].V = (2 * (b + space)) / 360;

VERTEX[n].U = (a) / 360;

n++;

VERTEX[n].X = R * sin((a + space) / 180 * PI) * sin((b) / 180 * PI) - H;

VERTEX[n].Y = R * cos((a + space) / 180 * PI) * sin((b) / 180 * PI) + K;

VERTEX[n].Z = R * cos((b) / 180 * PI) - Z;

VERTEX[n].V = (2 * b) / 360;

VERTEX[n].U = (a + space) / 360;

n++;

VERTEX[n].X = R * sin((a + space) / 180 * PI) * sin((b + space) / 180 * PI) - H;

VERTEX[n].Y = R * cos((a + space) / 180 * PI) * sin((b + space) / 180 * PI) + K;

VERTEX[n].Z = R * cos((b + space) / 180 * PI) - Z;

VERTEX[n].V = (2 * (b + space)) / 360;

VERTEX[n].U = (a + space) / 360;

n++;

}

}

}

The problem is that the calculated values of X, Y and Z are integers.

I would like to use glVertexPointer to be able do draw this sphere.

Could someone please help me here.

Do I need to do something with the calculated values to be able to use glVertexPointer and glDrawElements?

Thanks