我的Camera类构造函数有问题。我有许多变量,我正在构造函数中初始化,并为所有变量分配一些garbade值而不是我的。哪里可能是问题?例如printf("%d", yawSensitivity)
输出-1610612736
我尝试尽可能少地粘贴代码。也许你会发现一个概念错误并指出我正确的方向......
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 *cam = new Camera(WIN_WIDTH, WIN_HEIGHT);