使用 Visual Studio 和 C++/OpenGL 进行 cout 输出

发布于 2024-12-26 05:31:40 字数 743 浏览 1 评论 0原文

如果我有这样的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2025-01-02 05:31:40

如果您正在控制台应用程序项目中工作,则输出应显示在控制台上(与 OpenGL 窗口一起打开的类似于命令提示符的窗口)。

如果您没有在控制台应用程序中工作,而是有一个 Win32 或空项目,那么您必须将子系统链接器标志设置为 CONSOLE,正如 mkaes 在他的评论中指出的那样。为此(在 Visual Studio 2010 中):

  • 在解决方案资源管理器中右键单击您的项目。
  • 单击弹出列表底部的“属性”。
  • 在左侧的导航列表中,展开“链接器”并单击“系统”。
  • 列表中的第一个变量应标记为“SubSystem”。
  • 单击此变量的下拉列表,然后选择“控制台 (/SUBSYSTEM:CONSOLE)”
  • 应用设置并再次运行项目。

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):

  • Right click on your Project in the Solution Explorer.
  • Click 'Properties' at the bottom of the list that pops up.
  • In the navigation list on the left, expand 'Linker' and click on 'System'.
  • The first variable in the list should be labeled 'SubSystem'.
  • Click on the dropdown for this variable, and select 'Console (/SUBSYSTEM:CONSOLE)'
  • Apply the settings and run your project again.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文