gpt4 book ai didi

c++ - 有没有办法让SFML中的窗口出现而不显示cmd?

转载 作者:行者123 更新时间:2023-12-03 12:50:56 26 4
gpt4 key购买 nike

我是一名初学者,正在使用 C++/SFML 2.1 开发游戏。我看到了 SFML 文件夹附带的 pong 游戏等示例。就像在这个游戏中,cmd窗口没有和游戏窗口一起出现。我们如何在SFML中做到这一点?

最佳答案

来自SFML FAQ:

In Code::Blocks, open the project options (Project Menu -> Properties). In the Build targets tab, select the build target you wish to change on the left (most of the time only Debug and Release exist) and change its type option in the drop-down list on the right side from "Console application" to "GUI application".

In Visual Studio, go to the project options (Project Menu -> Properties). In the tree on the left, expand the "Configuration properties" tree and expand the "Linker" sub-tree. Select "System" from the sub-tree, and in the SubSystem field on the right side change "Console (/SUBSYSTEM:CONSOLE)" to "Windows (/SUBSYSTEM:WINDOWS)" by clicking on the field and using the drop-down list.

To maintain a portable entry point (int main() function), you can link your program against the small sfml-main.lib library in the case of Visual Studio or libsfml-main.a in the case of Code::Blocks/MinGW.

Alternatively to hide the console, you can also define your own Windows entry point for graphical applications.

int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
> LPSTR lpszArgument, int nCmdShow)

Replace your int main() or int main(int argc, char** argv) with this function and it will be called by the operating system when your program is executed just like the classical int main() function.

关于c++ - 有没有办法让SFML中的窗口出现而不显示cmd?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21181748/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com