Removing console window for Glut/FreeGlut/GLFW?

后端 未结 8 687
醉话见心
醉话见心 2021-02-03 13:42

Under Visual C++, I have played around with Glut/FreeGlut/GLFW. It seems that everyone of these projects adds a CMD window by default. I tried removing it going under:

相关标签:
8条回答
  • 2021-02-03 13:56

    When I've gotten an error like that I was able to fix it by entering that following text in the linker, section Advance, option Entry Point the following:

    main

    0 讨论(0)
  • 2021-02-03 13:57

    To get rid of the console using cmake, the link flags can be set as follows:

    set_target_properties(exe_name PROPERTIES 
        LINK_FLAGS "/ENTRY:mainCRTStartup /SUBSYSTEM:WINDOWS")
    
    0 讨论(0)
  • 2021-02-03 13:59

    If you create a new project as a console application, it will always run as such. You have to create a new GUI project if you want to run it in an actual window, otherwise the correct headers and libraries will not be included.

    Also the WinMain function that's required will be included for you in the resulting template files.

    0 讨论(0)
  • 2021-02-03 14:02

    Non-console Windows applications use the WinMain() entry point convention. Your Glut examples probably use the standard C main() convention.

    If you want a quick fix just for the demo app, the WinAPI function FreeConsole() might help.

    MSDN: http://msdn.microsoft.com/en-us/library/ms683150(v=vs.85).aspx

    0 讨论(0)
  • 2021-02-03 14:06

    You need to write a WinMain entry point and copy your existing code (from main):

    int CALLBACK WinMain(
      __in  HINSTANCE hInstance,
      __in  HINSTANCE hPrevInstance,
      __in  LPSTR lpCmdLine,
      __in  int nCmdShow
    ){
        // ...
    }
    
    0 讨论(0)
  • 2021-02-03 14:08

    Under the linker options, set your entry point to mainCRTStartup . This function does the necessary setup of the MS libc and then calls main.

    0 讨论(0)
提交回复
热议问题