Posts

Showing posts from February, 2016

4.0.1: MVC OpenGL Part 2

Image
The Render Loop Copy the  OpenGLMVCPt1 target from the previous tutorial, and run the app to make sure everything still works.  From this starting point, we will continue by refactoring our CVDisplayLink code.  Create a new Swift file called SwiftOpenGLViewDelegates.swift.  Make sure to import CoreVideo.CVDisplayLink. import Foundation import CoreVideo.CVDisplayLink Define the DisplayLink  type. struct DisplayLink {      } With SwiftOpenGLView as our reference, we’ll start to define what this delegate should implement.  We know that we need a property to access the link and we need a callback function that calls our drawView() method. struct DisplayLink {     let id: CVDisplayLink      let callback: CVDisplayLinkOutputCallback = {(displayLink: CVDisplayLink , inNow:                       ➥ UnsafePointer < CVTimeStamp >, inOutputTime: UnsafePointer < CVTimeStamp >,                       ➥ flagsIn: CVOptionFlags , flagsOut: Unsa