S
someone
Hi all
Noob question:
-----------------------------------------------------------------------------
typedef float GLfloat; // float = GLfloat
void setBezierPoint(const double &x, const double &y, const double &z,
const int &P, GLfloat bezierCTRpts[][3])
{
bezierCTRpts[P][0] = (GLfloat)x;
bezierCTRpts[P][1] = (GLfloat)y;
bezierCTRpts[P][2] = (GLfloat)z;
}
void FindBezierControlPointsND(const int *N_kontur,
const double *cpp_X, const double *cpp_Y, GLfloat bezierData[]
[3])
{
// calculations...
// set xyz for point P=0 using 4th input parameter:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 0, bezierData);
// set xyz for point P=3 using 4th input parameter:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 3, bezierData);
}
int main(int argc, char** argv)
{
cout << "hi" << endl;
GLfloat bezierData[4][3] = {0};
// something
FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
}
-----------------------------------------------------------------------------
Explanation:
I have a static 2D array: bezierData[4][3], 4 points * xyz-coordinates
and I pass it to FindBezierControlPointsND with this call:
FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
and the function takes: GLfloat bezierData[][3] as input.
All is ok - the code works, however what I really wanted was to omit
the 4th input parameter (const int &P) so it looks like:
void setBezierPoint(const double &x, const double &y, const double &z,
GLfloat bezierCTRpts[][3]) // 4th input is GONE !
{
bezierCTRpts[0][0] = (GLfloat)x;
bezierCTRpts[0][1] = (GLfloat)y;
bezierCTRpts[0][2] = (GLfloat)z;
}
Then I wanted to set the xyz-values by a function call like:
- for P=0:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[0][0]);
- for P=3:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[3][0]);
This however doesn't work! I also tried to add "&" in front of
bezierData[3][0] etc... Error message is something like:
error: cannot convert ‘GLfloat* {aka float*}’ to ‘GLfloat* (*)[3] {aka
float* (*)[3]}’ for argument ‘4’ to ‘void setBezierPoint(const
double&, const double&, const double&, GLfloat* (*)[3])’
If you like/ask for it, perhaps I can make a minimal working example.
However, I hope one of you geniuses out there can spot my mistake
right on
THANKS!
Noob question:
-----------------------------------------------------------------------------
typedef float GLfloat; // float = GLfloat
void setBezierPoint(const double &x, const double &y, const double &z,
const int &P, GLfloat bezierCTRpts[][3])
{
bezierCTRpts[P][0] = (GLfloat)x;
bezierCTRpts[P][1] = (GLfloat)y;
bezierCTRpts[P][2] = (GLfloat)z;
}
void FindBezierControlPointsND(const int *N_kontur,
const double *cpp_X, const double *cpp_Y, GLfloat bezierData[]
[3])
{
// calculations...
// set xyz for point P=0 using 4th input parameter:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 0, bezierData);
// set xyz for point P=3 using 4th input parameter:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 3, bezierData);
}
int main(int argc, char** argv)
{
cout << "hi" << endl;
GLfloat bezierData[4][3] = {0};
// something
FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
}
-----------------------------------------------------------------------------
Explanation:
I have a static 2D array: bezierData[4][3], 4 points * xyz-coordinates
and I pass it to FindBezierControlPointsND with this call:
FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
and the function takes: GLfloat bezierData[][3] as input.
All is ok - the code works, however what I really wanted was to omit
the 4th input parameter (const int &P) so it looks like:
void setBezierPoint(const double &x, const double &y, const double &z,
GLfloat bezierCTRpts[][3]) // 4th input is GONE !
{
bezierCTRpts[0][0] = (GLfloat)x;
bezierCTRpts[0][1] = (GLfloat)y;
bezierCTRpts[0][2] = (GLfloat)z;
}
Then I wanted to set the xyz-values by a function call like:
- for P=0:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[0][0]);
- for P=3:
setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[3][0]);
This however doesn't work! I also tried to add "&" in front of
bezierData[3][0] etc... Error message is something like:
error: cannot convert ‘GLfloat* {aka float*}’ to ‘GLfloat* (*)[3] {aka
float* (*)[3]}’ for argument ‘4’ to ‘void setBezierPoint(const
double&, const double&, const double&, GLfloat* (*)[3])’
If you like/ask for it, perhaps I can make a minimal working example.
However, I hope one of you geniuses out there can spot my mistake
right on
THANKS!