使用 Visual Studio 和 C++/OpenGL 进行 cout 输出
如果我有这样的 main 函数:
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (800, 600);
glutInitWindowPosition (100, 100);
glutCreateWindow ("A");
init();
glutIdleFunc(update);
glutDisplayFunc(draw);
glutReshapeFunc(resize);
glutKeyboardFunc(keyboard);
glutSpecialFunc(specialKeyboard);
glutMouseFunc(mouse);
cout<<x<<" "<<"Printed out variable x"<<endl;
cout<<y<<" "<<"Printed out variable y"<<endl;
cout<<z<<" "<<"Printed out variable z"<<endl;
glutMainLoop();
return 0;
}
在哪里可以看到 cout 调用的结果?
If I have a main function like this:
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (800, 600);
glutInitWindowPosition (100, 100);
glutCreateWindow ("A");
init();
glutIdleFunc(update);
glutDisplayFunc(draw);
glutReshapeFunc(resize);
glutKeyboardFunc(keyboard);
glutSpecialFunc(specialKeyboard);
glutMouseFunc(mouse);
cout<<x<<" "<<"Printed out variable x"<<endl;
cout<<y<<" "<<"Printed out variable y"<<endl;
cout<<z<<" "<<"Printed out variable z"<<endl;
glutMainLoop();
return 0;
}
Where can I see the result of the cout calls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在控制台应用程序项目中工作,则输出应显示在控制台上(与 OpenGL 窗口一起打开的类似于命令提示符的窗口)。
如果您没有在控制台应用程序中工作,而是有一个 Win32 或空项目,那么您必须将子系统链接器标志设置为 CONSOLE,正如 mkaes 在他的评论中指出的那样。为此(在 Visual Studio 2010 中):
If you're working in a Console Application Project, then the output should appear on the console (the command prompt-like window that opens with the OpenGL window).
If you are not working in a Console Application, and you have a Win32 or Empty project instead, then you will have to set the subsystem linker flag to CONSOLE, as mkaes pointed out in his comment. To do so (in Visual Studio 2010):