我的 Camera 类构造函数有问题。我有很多在构造函数中初始化的变量,并且为所有变量分配了一些垃圾值而不是我的。问题可能出在哪里?例如printf("%d", yawSensitivity)
输出-1610612736
我试图粘贴尽可能少的代码。也许你会发现一个概念错误并指出我正确的方向......
相机.h
class Camera
{
protected:
int windowMidX;
int windowMidY;
float pitchSensitivity;
float yawSensitivity;
public:
Camera(int windowWidth, int windowHeight);
~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);