简体   繁体   中英

Xcode Non-terminal C++ project

I am an amateur mac user and I'm trying to make a c++ project in Xcode. Everywhere I go I am told to make a Command Line tool project in Xcode.

This is frustrating because I intend to make an OpenGL app and so I don't want it to be a console app.

This may be a very amateur question but I'm not familiar with Mac's. How can I make a non-console (terminal), C++ app in Xcode that I can make my OpenGL application in?

EDIT: Could I use SDL for windowing rather than cocoa?

On this case you probably do want a command line project.

The Xcode templates are to include a Cocoa nib if you are doing all the GUI with call to another library the it is a pure C++ project and no need for these templates.

You might need to do more if you are making it appear to be an OSX app that is an .app bundle that can be run directly from Finder or dock. In this case choose a Cocoa application and remove main.m (replacing by a main.cc) and the nibs.

You'll have to make a Cocoa application, and change the extensions of your files from .m to .mm . This tells the compiler you will also be using C++ with Objective-C.

The way Mac handles windowing pretty much requires the use of Objective-C, so you need the base Cocoa to make the window and the GL view, and then you will be able to write the rest in C++ as you would normally.

If you really want to be entirely C++, you could use a framework like GLUT that handles windowing itself.

You can make a Cocoa application and set up the OpenGL context using the native APIs, and then integrate your C++ code into that, or you can create a command line application that uses the GLUT library to set up OpenGL. Those are the two main ways.

Note: OpenGL 3+ isn't supported by GLUT on OS X yet, I don't think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM