, , , " ", dataOut, -, malloc, , WILL , , , -, , vertex gluptr - . , gluptr vertex coords 'GLDouble', vertex ... , , dataOut... , , ...
, , , NULL...
GLdouble *gluptr = NULL;
void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],
GLfloat weight[4], GLdouble **dataOut)
{
if((*dataOut) == NULL)
{
(*dataOut) = (GLdouble *) malloc(6 * sizeof(GLdouble));
}
if (*dataOut != NULL){
/* PASSED MEMORY ALLOC! */
(*dataOut)[0] = coords[0];
(*dataOut)[1] = coords[1];
(*dataOut)[2] = coords[2];
for (int i = 3; i < 6; i++)
{
(*dataOut)[i] = weight[0] * vertex_data[0][i] +
weight[1] * vertex_data[0][i] +
weight[2] * vertex_data[0][i] +
weight[3] * vertex_data[0][i];
}
}
}
The last parameter when calling this function combineCallbackis the parameter for calling by reference, therefore, a double asterisk is used.
Should I ask this, dataOutspecifically a fixed size of 6 elements? if so, then the parameter will need to be adjusted ... so that it looks like *(*dataOut[6])... looking at it from above my head (it's late and past my sleep ...)
source
share