Hey guys I have come up with a solution for the problem I have but I would like to know how I could do this the way I initially had it set up but without the leak of course.
vec3f.h
class vec3f
{
public:
GLfloat _x, _y, _z;
vec3f(){};
vec3f( GLfloat x, GLfloat y, GLfloat z )
{
_x = x;
_y = y;
_z = z;
}
*operator GLfloat()
{
GLfloat *_r = new GLfloat[3]; //the problem
_r[0] = _x;
_r[1] = _y;
_r[2] = _z;
return _r;
}
}
Now I know I am calling the new operator without calling the delete operator but if I put in a deconstructor that frees _r (when declared as part of the class) it crashes because it is pointing to something that was freed.
Anyways I am trying to use this in the OpenGL function glVertex3fv( const GLfloat *v )
.
I don't know if there is an operator that will do exactly what I want since I do not know all of them.
Any help would be great. Thanks.