PDA

View Full Version : OPENGL using up cpu memory loading almost 20m points and triangles



macsam
05-08-2017, 10:32 AM
Hi,

I have a windows 8.1 computer 16GB ram, using vs 2013.
I am loading nearly 20m points and triangles made from the points. I have allocated plenty of space for the ponts and triangles but when I come to compile them OpenGL is using up all the memory causing the program to crash.



do{
if (Triangles[uiI].cOK != 'n')
{

cdTrnsfrmd[0].dEast = cdCoords[Triangles[uiI].iCoordNo1].dEast - dMinEast;
cdTrnsfrmd[0].dNorth = cdCoords[Triangles[uiI].iCoordNo1].dNorth - dMinNorth;
cdTrnsfrmd[0].dElev = cdCoords[Triangles[uiI].iCoordNo1].dElev - dMinElev;

cdTrnsfrmd[1].dEast = cdCoords[Triangles[uiI].iCoordNo2].dEast - dMinEast;
cdTrnsfrmd[1].dNorth = cdCoords[Triangles[uiI].iCoordNo2].dNorth - dMinNorth;
cdTrnsfrmd[1].dElev = cdCoords[Triangles[uiI].iCoordNo2].dElev - dMinElev;

cdTrnsfrmd[2].dEast = cdCoords[Triangles[uiI].iCoordNo3].dEast - dMinEast;
cdTrnsfrmd[2].dNorth = cdCoords[Triangles[uiI].iCoordNo3].dNorth - dMinNorth;
cdTrnsfrmd[2].dElev = cdCoords[Triangles[uiI].iCoordNo3].dElev - dMinElev;

GetNormalEquationOfPlane(cdTrnsfrmd, &dXyz);

glfVertex1[0] = (GLfloat)cdTrnsfrmd[0].dEast;
glfVertex1[1] = (GLfloat)cdTrnsfrmd[0].dNorth;
glfVertex1[2] = (GLfloat)cdTrnsfrmd[0].dElev;



glfVertex2[0] = (GLfloat)cdTrnsfrmd[1].dEast;
glfVertex2[1] = (GLfloat)cdTrnsfrmd[1].dNorth;
glfVertex2[2] = (GLfloat)cdTrnsfrmd[1].dElev;

/*gldVertex3[0] = (GLdouble)cdTrnsfrmd[2].dEast;
gldVertex3[1] = (GLdouble)cdTrnsfrmd[2].dNorth;
gldVertex3[2] = (GLdouble)cdTrnsfrmd[2].dElev;*/


normcrossprodF(glfVertex1, glfVertex2, glfNorm);
//face stuff to be inserted in here



//glfColorPercent = (glfNorm[0] * 255.0f) / 255.0f;//dNorm[0] * dNorm[0] + dNorm[1] * dNorm[1] + dNorm[2] * dNorm[2];



//ok
glfColour3[0] = (125.0f - 60.0f * glfColorPercent) / 255.0f;
glfColour3[1] = (125.0f - 60.0f * glfColorPercent) / 255.0f;
glfColour3[2] = (125.0f - 60.0f * glfColorPercent) / 255.0f;

glColor4f(glfColour3[0], glfColour3[1], glfColour3[2], 1.0);
//glColor4ub((char)glfColour3[0], (char)glfColour3[1], (char)glfColour3[2], 255);


if (cIncludeTriangle == 'y')
{
glNormal3f(glfNorm[0], glfNorm[1], glfNorm[2]);//glNormal3fv(fNorm);

glVertex3f((GLfloat)cdTrnsfrmd[0].dEast - (GLfloat)((dMaxEast - dMinEast) / 2.0),
(GLfloat)cdTrnsfrmd[0].dNorth - (GLfloat)((dMaxNorth - dMinNorth) / 2.0),
(GLfloat)(cdTrnsfrmd[0].dElev - (dMaxElev - dMinElev) / 2.0));

glVertex3f((GLfloat)cdTrnsfrmd[1].dEast - (GLfloat)((dMaxEast - dMinEast) / 2.0),
(GLfloat)cdTrnsfrmd[1].dNorth - (GLfloat)((dMaxNorth - dMinNorth) / 2.0),
(GLfloat)(cdTrnsfrmd[1].dElev - (dMaxElev - dMinElev) / 2.0));


glVertex3f((GLfloat)cdTrnsfrmd[2].dEast - (GLfloat)((dMaxEast - dMinEast) / 2.0),
(GLfloat)cdTrnsfrmd[2].dNorth - (GLfloat)((dMaxNorth - dMinNorth) / 2.0),
(GLfloat)(cdTrnsfrmd[2].dElev - (dMaxElev - dMinElev) / 2.0));
}
}

uiI++;



} while (uiI < uiTo);//uiTriPointer);


I compile 30,000 triangles at a time

I did not expect that to happen. Any help gratefully appreciated.

Thanks

MacSam