Reputation: 59
I have a problem with my Camera class contructor. I have lots of variables that I'm initializing in constructor and for all of them are assigned some garbade values instead of mine. Where might be the problem? For example printf("%d", yawSensitivity)
outputs -1610612736
I've tried to paste as little code as possible. Maybe you will spot a concept error and point me in the right direction...
Camera.h
class Camera
{
protected:
int windowMidX;
int windowMidY;
float pitchSensitivity;
float yawSensitivity;
public:
Camera(int windowWidth, int windowHeight);
~Camera();
};
Camera.cpp
Camera::Camera(int windowWidth, int windowHeight)
{
this->windowMidX = windowWidth / 2;
this->windowMidY = windowHeight / 2;
this->pitchSensitivity = 0.1f;
this->yawSensitivity = 0.1f;
}
Camera::~Camera() {}
Camera initialization
Camera *cam = new Camera(WIN_WIDTH, WIN_HEIGHT);
Upvotes: 0
Views: 99
Reputation: 52461
For example
printf("%d", yawSensitivity)
Your code exhibits undefined behavior. yawSensitivity
is of type float
. %d
format specifier expects a parameter of type int
. Use %f
instead.
Upvotes: 3