Download OpenGL Programming on Mac OS X
Transcript
rendering into textures. Though many other choices are possible, we faced a difficult decision when writing this book—either to cover them all or to cover only a subset. To free up some weekends, we chose the latter option. To be fair, since we began this project, the FBO extension has really come of age, and we would recommend it without hesitation for those cases when you need intermediate rendering. The other techniques that we do not cover here are all genealogical predecessors to the FBO extension and, in many ways, are inferior to it. Specifically, off-screen render areas, regardless of the interface (CGL, AGL, or Cocoa) are software renderers and so have only nominal performance. They should be avoided for interactive or real-time applications. Pbuffers are complex and unwieldy to implement. Although they often perform at native hardware speeds, the complexity of managing the interface is not worth the headache if you can write to a modern render target like an FBO instead. The pure simplicity, flexibility and generality, and raw performance of what can be accomplished via FBO are unmatched by these alternative techniques. If you’ve got older code that uses one of these approaches, a move to FBOs will likely both simplify and accelerate your code. Take the leap. Summary In this chapter, we explored how to create and configure Cocoa-based OpenGL rendering areas for on-screen windows and for various intermediate render targets. We saw how to create custom pixel formats, examined some of the flags that these pixel formats take, and demonstrated how to configure and initialize pixel formats. We also saw how to customize NSViews and NSOpenGLViews to use custom pixel formats and create contexts. We considered how to share data among multiple contexts, and we learned how to configure full-screen surfaces. Now that you know the fundamentals of OpenGL and Cocoa setup, you have a solid foundation from which to begin building your own Cocoa OpenGL applications. 162 Chapter 8: The Cocoa API for OpenGL Configuration