简体   繁体   English

将Open GL ES与iOS混合

[英]Mixing Open GL ES with iOS

I want to learn Open GL ES for iOS. 我想学习适用于iOS的Open GL ES。 I heard Open GL ES is mainly programmed in C++ or C. And iOS apps are done in Objective-C or Swift. 我听说Open GL ES主要是用C ++或C编写的。iOS应用是用Objective-C或Swift完成的。 Is it possible for me to render images and objects with Open GL ES in C++ and combine it with the iOS part in Objective-C. 我是否可以使用C ++中的Open GL ES渲染图像和对象,并将其与Objective-C中的iOS部分结合在一起。

Also if that is is possible, would I do the Open GL ES part in Xcode with C++ or use another IDE? 另外,如果有可能,我是否会在Xcode中使用C ++做Open GL ES部分,还是使用另一个IDE? And then obviously use Xcode for the iOS part. 然后显然将Xcode用于iOS部分。

It makes no difference for you what language is "OpenGL ES mainly programmed in". 对于“ OpenGL ES主要编程语言”是什么语言,这对您没有影响。 What matters is what the API is like. 重要的是API是什么样的。 The API differs on iOS depending on the language you are using. 根据使用的语言,iOS上的API有所不同。 ObjectiveC will have almost all of the API in C (Not C++) where the rest is in ObjectiveC (context wrapping and hooking to UIView ). ObjectiveC将使用C(不是C ++)中的几乎所有API,其余的均使用ObjectiveC(上下文包装和挂接到UIView )。 Swift on the other hand uses Swift wrapper around the API which is generally a complete pain and with a combination of data and buffer structuring in Swift I would (for now) discourage you on using Swift. 另一方面,Swift在API周围使用Swift包装器,这通常是一件很麻烦的事,并且结合了Swift中的数据和缓冲区结构,我会(现在)不鼓励您使用Swift。 Your application may still be in Swift but I suggest at least the openGL part is in ObjectiveC and then bridged to Swift for usage. 您的应用程序可能仍在Swift中,但我建议至少openGL部分在ObjectiveC中,然后桥接到Swift以供使用。

When using ObjectiveC you may use all of the functionality of standard C out of the box. 使用ObjectiveC时,您可以立即使用标准C的所有功能。 If you want to use the C++ you need to set the certain flags but there is a very simple way to make the Xcode do that for you by simply renaming the ".m" files to ".mm". 如果要使用C ++,则需要设置某些标志,但是有一种非常简单的方法可以使Xcode通过将“ .m”文件重命名为“ .mm”来为您执行此操作。 These will use C++ by default. 这些将默认使用C ++。

No matter the language I suggest you to use Xcode for the openGL part. 无论使用哪种语言,我都建议您将Xcode用于openGL部分。 Next to the friendly autocompletion you have a variety of nice tools to debug and analyze your product. 在友好的自动补全功能旁边,您可以使用各种不错的工具来调试和分析产品。

You have some libraries designed by Apple as well mostly in GLKit. 您也有一些由Apple设计的库,而且大多数都是在GLKit中设计的。 Some of them are useful such as working with matrices but more or less everything else boils down to "Don't use it" once you get to a certain point of development. 它们中的一些非常有用,例如处理矩阵,但是一旦达到特定的开发点,其他所有东西或多或少都会归结为“不要使用它”。

But since you say you are starting to only learn I suggest you to simply see some examples from tutorials and documentation. 但是,既然您说您只是开始学习,我建议您简单地从教程和文档中查看一些示例。 The Apple raw openGL ES documentation is actually quite impressive with all the snippets and explanations (comparing to the rest of the documentation). 实际上,Apple原始的openGL ES文档中的所有代码片段和说明都给人留下了深刻的印象(与其余文档相比)。 So you may use any of these and probably some StackOverflow and you should be on your way in no time. 因此,您可以使用其中的任何一种,也可以使用某些StackOverflow,并且您应该立即上路。

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

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