O'Reilly logo

COCOA PROGRAMMING FOR MAC OS X SECOND EDITION by Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 29. Cocoa and OpenGL

This chapter is not designed to teach you OpenGL. If you want to learn OpenGL, read The OpenGL Programming Guide. This chapter is intended to show you how to do drawing with OpenGL in an application that is written using Cocoa. Like all other drawing in Cocoa, OpenGL rendering will be done in a view. Until now, all of your views have used an NSGraphicsContext to do drawing with Quartz (via NSImage, NSBezierPath, and NSAttributedString).

NSOpenGLView is a subclass of NSView that has an OpenGL drawing context. Just as you needed the focus locked on a view to do drawing with Quartz, so the OpenGL drawing context must be active for any OpenGL drawing commands to have an effect.

Here are some important methods in NSOpenGLView ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required