0

ループ内の MEX ファイル (matlab) で次の関数を呼び出しました。glColor3f でメモリ リークが発生します。メモリは増え続けています。それを解決するアイデアはありますか?

static GLuint createDisplayListWithColor(double *fM, int fNum, double *vM, int vNum, GLfloat *ColorM, int colorNum)
{
    GLuint theShape;
    int i;
    double *fp;
    int vIndex, fNum2, vNum2;

    fNum2 = fNum * 2;
    vNum2 = vNum * 2;

    theShape = glGenLists (1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glNewList(theShape, GL_COMPILE);
    glBegin (GL_TRIANGLES);


        for (i = 1; i <= fNum; i++) {
            fp = fM + i-1;
            vIndex = (int)fp[0] - 1;
            glColor3f(ColorM[vIndex], ColorM[vIndex + vNum], ColorM[vIndex + vNum2]);
            glVertex3d(vM[vIndex], vM[vIndex + vNum], vM[vIndex + vNum2] );

            vIndex = (int)fp[fNum] - 1;
            glColor3f(ColorM[vIndex], ColorM[vIndex + vNum], ColorM[vIndex + vNum2]);
            glVertex3d(vM[vIndex], vM[vIndex + vNum], vM[vIndex + vNum2] );

            vIndex = (int)fp[fNum2] - 1;
            glColor3f(ColorM[vIndex], ColorM[vIndex + vNum], ColorM[vIndex + vNum2]);
            glVertex3d(vM[vIndex], vM[vIndex + vNum], vM[vIndex + vNum2] );
               }

    glEnd ();
    glutSwapBuffers();
    glEndList();
    return theShape;
}
4

1 に答える 1