I have global variables:
point4 * mypoints;
color4 * mycolors;
And a block of code thats part of a function drawPlyFiles
vector<point4> retpolys;
retpolys.resize(polynum * 3);
GLint polyx, polyy, polyz;
for (int i = 0; i < polynum; i++)
{
inStream >> polyx;
inStream >> polyx >> polyy >> polyz;
//cout << "x: " << polyx << " y: " << polyy << " z: " << polyz << "\n";
retpolys[i*3] = retVerts[polyx];
retpolys[(i*3) + 1] = retVerts[polyy];
retpolys[(i*3) + 2] = retVerts[polyz];
//retpolys[i] = point4( polyx, polyy, polyz, 1.0 );
}
mypoints = &retpolys[0];
return true;
The important part to take away from the code is that I set global mypoints(array) equal to retpolys(vector). Retpolys gets filled with data from the for loop. When I debug, all the data in retpolys is fine and proper. (retVerts is a vector of point4)
later on in my main init function this gets run:
drawPlyFile("ply_files/airplane.ply");
//colorcube();
point4 temp = mypoints[1];
int thissize = sizeof(mypoints)/sizeof(mypoints[0]);
for (int i = 0; i < thissize; i++)
{
mycolors[i] = color4( 0.0, 0.0, 0.0, 1.0 );
}
The code compiles fine but I have a runtime exception. I debug in order to find the problem. I check the value of mypoints after drawPlyFiles, and it looks like it just contains a pointer to where retpolys began. However, when I debug, it doesn't let me view other parts of the array, just that first pointer.(I can see all the separate values of retpolys when im in the function) I then check the value of this size and i get a number like -12894161, which doesn't make sense since it should be the size of mypoints.
I think the issue lies in the conversion from retpolys to mypoints but I have no idea how to fix it, or even if thats the actual reason for error. Any help?
p.s. I want mycolors to have the same number of elements as mypoints and for all of em to be color4( 0.0, 0.0, 0.0, 1.0 )