I just made a class called "matrix4" which has a pointer to float, called data.
class matrix4
{
public:
float * data;
The constructor, receives 16 floats, allocates space and inicializes every cell with the respective float:
matrix4::matrix4(float c0, float c1, float c2, float c3, float c4, float c5, float c6, float c7, float c8, float c9, float c10, float c11, float c12, float c13, float c14, float c15) {
data = new float[16];
float input_vector[16] = { c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15 };
for (int i = 0; i < 16; i++) {
data[i] = input_vector[i];
}
}
Now I'm doing a factory class that produces matrix4. This specific one,receives a vector of scale (I've created the vector3D class too) and returns a scale matrix:
matrix4 factory::createScaleMat4(vector3D v) {
matrix4 m = matrix4(v.get_x(), 0, 0, 0,
0, v.get_y(), 0, 0,
0, 0, v.get_z(), 0,
0, 0, 0, 1);
return m;
};
The problem is that it gives me this error: "Run-Time Check Failure #2 - Stack around the variable 'm' was corrupted", and I can't understand why...