简体   繁体   English

Xcode非终端C ++项目

[英]Xcode Non-terminal C++ project

I am an amateur mac user and I'm trying to make a c++ project in Xcode. 我是一个业余Mac用户,我正在尝试在Xcode中创建一个C ++项目。 Everywhere I go I am told to make a Command Line tool project in Xcode. 到处都是我被告知要在Xcode中创建一个命令行工具项目。

This is frustrating because I intend to make an OpenGL app and so I don't want it to be a console app. 这令人沮丧,因为我打算制作一个OpenGL应用程序,因此我不希望它成为控制台应用程序。

This may be a very amateur question but I'm not familiar with Mac's. 这可能是一个非常业余的问题,但我对Mac并不熟悉。 How can I make a non-console (terminal), C++ app in Xcode that I can make my OpenGL application in? 如何在Xcode中制作可以在其中创建OpenGL应用程序的非控制台(终端)C ++应用程序?

EDIT: Could I use SDL for windowing rather than cocoa? 编辑:我可以使用SDL而不是可可用于窗口吗?

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. 如果您通过调用另一个库来完成所有GUI,则Xcode模板将包含一个可可笔尖,因为它是纯C ++项目,不需要这些模板。

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. 如果要使其看起来像是OSX应用程序,它是一个.app捆绑包,可以直接从Finder或对接运行,则可能需要做更多的事情。 In this case choose a Cocoa application and remove main.m (replacing by a main.cc) and the nibs. 在这种情况下,请选择可可应用程序,然后删除main.m(由main.cc替换)和笔尖。

You'll have to make a Cocoa application, and change the extensions of your files from .m to .mm . 您必须制作一个Cocoa应用程序,并将文件的扩展名从.m更改为.mm This tells the compiler you will also be using C++ with Objective-C. 这告诉编译器,您还将在Objective-C中使用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. Mac处理窗口的方式几乎需要使用Objective-C,因此您需要基本的Cocoa来制作窗口和GL视图,然后您就可以像往常一样用C ++编写其余代码。

If you really want to be entirely C++, you could use a framework like GLUT that handles windowing itself. 如果您真的想完全使用C ++,则可以使用类似GLUT的框架来处理窗口本身。

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. 您可以制作一个Cocoa应用程序并使用本机API设置OpenGL上下文,然后将C ++代码集成到其中,也可以创建一个使用GLUT库设置OpenGL的命令行应用程序。 Those are the two main ways. 这是两种主要方法。

Note: OpenGL 3+ isn't supported by GLUT on OS X yet, I don't think. 注意:OS X尚不支持GLUT OpenGL 3+。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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