我很难弄清楚我的代码出了什么问题而我找不到任何东西。
如果我运行它,一切正常,并创建一个窗口:
int main()
{
GLFWwindow* win=glfwCreateWindow(640,480,"Window, NULL, NULL);
if(!win)
std::cerr << "Failed to create a window" << std::endl;
}
但是,当我通过窗口类运行它时,我创建它并不是:
main.cpp中:
int main()
{
Window win(640, 480, "Window");
//etc...
}
window.h中:
class Window
{
public:
Window();
Window(int x, int y, std::string t);
Window(Vector2i xy, std::string t);
//...
private:
Vector2i size;
std::string title;
GLFWwindow*win;
void create();
};
Window.cpp:
Window::Window(int x, int y, std::string t)
:size(x, y), title(t), win(nullptr)
{
create();
}
void Window::create()
{
win=glfwCreateWindow(size.x, size.y, "hello", NULL, NULL);
if (!win)
std::cerr << "Failed to create a window" << std::endl;
//...
}
//...etc
窗口创建返回NULL并打印错误日志... 到底是怎么回事?