Instead, you have to use MTKView inside the UIViewController. In Metal, there’s no such thing as MetalViewController. Open ViewController.swift, and change ViewController to be a subclass of UIViewController instead of GLKViewController. And get rid of all those pesky warnings! Integrating Metal Now you’re going to draw the same square but with Metal. You can see these in Xcode in the Issue navigator. However, since the deployment target for this project is iOS 12, there are several OpenGL deprecation warnings. You should see a colorful square spinning. Then, open OpenGLKit.xcodeproj in the Starter folder. Time to explore the differences on your own! Getting StartedĪs a reminder, download the files you need using the Download Materials button at the top or bottom of this tutorial. This makes it much more efficient than OpenGL which can’t do the same due to architecture restrictions. This approach means that when using Metal, you don’t need to do a lot of setup operations on the render loop. The creation and compilation are both expensive operations, so the idea is to do them as rarely as possible, and later to operate with compiled-state objects. The compiled-state object is a GPU-optimized resource. You create a descriptor object and compile it. The biggest difference between OpenGL and Metal is that in Metal, you usually operate with two types of objects: But don’t worry – it’s not too complicated! There’s no such API for Metal, so you need to write shaders yourself. In OpenGL projects, there is a GLKBaseEffect, which is an abstraction on top of shaders. In both, you set up buffers with data to pass to the GPU and specify vertex and fragment shaders. Understanding Conceptual Differencesįrom a development perspective, OpenGL and Metal are similar. The effects are amazing - you may remember them from the Zen Garden example in the WWDC 2014 keynote. The result is Metal, which can provide up to 10✕ the number of draw calls for your app compared to OpenGL ES. The goal was to have low overhead and high performance while supporting the latest and greatest features. So, it took a clean-room approach and designed a graphics API specifically for Apple hardware. The cross-platform support of OpenGL ES is nice, but Apple realized it was missing the signature integration of the operating system, hardware, and software that all good Apple products have. That means, with a few small modifications, you can run C++ OpenGL ES code on other platforms, such as Android. OpenGL ES is designed to be a cross-platform framework. To complete this tutorial, you’ll need an A7 device or newer. They require a device with an Apple A7 chip or later. Note: Metal apps don’t run on the iOS simulator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |