Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Version: 1.0

Posted: 2003-10-27

Build Requirements: N/A

Runtime Requirements: Carbon (both 9 and X) ProjectBuilder and InterfaceBuilder.

View Source Code:

Download Sample (“Custom_Cocoa_OpenGL.zip”, 149.0K)
Download Sample (“Custom_Cocoa_OpenGL.dmg”, 208.8K)



Description

This sample build upon the Cocoa OpenGl sample which demonstrates a Cocoa OpenGL application which uses IB to create a window an then handles all the basic events needed for a normal Cocoa application. The difference is that this sample use a custom subclass of NSView that works very similarly to NSOpenGLView and thus can be used as teh basis for developers needing to customize NSOpenGLview beyond what a sub class can do. Also included is the same stringtexture class as Cocoa OpenGL has, showing how to use an NSImage to write a stirng into and then texture from for high quality font rendering. This sample goes on to show trackball integration. Version 1.1 - glCheck and other minor updates for Mac OS X v10.3 "Panther" Version 1.0 - This sample should present a reasonably complete correctly formed Cocoa application which can be used as a starting point for Cocoa OpenGL applications which need a custom version of NSOpenGLView - Like the related Carbon OpenGL and Carbon CGL samples this sample also has a well structured virtual track ball that has an updated event interface to deal with the issue of full screen contexts and multiple displays - Again, like Carbon OpenGL and Carbon CGL samples, this sample contains stand alone code for retrieving OpenGL capabilities and associating these with graphics device. Capabilities collected include; device identification from OpenGL, CoreGraphics and Carbon, device geometry and refresh rates, VRAM and texture RAM, texture units and texture limits, OpenGL version, and OpenGL functionality. The OpenGL functionality collected is set up to correct coalesce extension and version information into one capability flag allowing developers to quickly determine if a renderer has a specific capability, whether it is exposed via OpenGL extensions or in the core functionality. Furthermore this functional information represents the full set of functionality for OpenGL on Mac OS X at the time of the sample posting. Developers are free to add additional checks or remove unneeded ones to fit their intended OpenGL usage. A few usage notes are in order. The CheckOpenGLCaps (...) is set up like many CG routines allowing the developer to call it once to check the number of capabilities to be returned, then allocate just the required storage required prior to retrieving the actual capability information. Since Mac OS X can dynamically reconfigure it's displays, OpenGL capability information should be update whenever the display configuration is changed. If all the displays are captured one will have any display reconfiguration except explicitly called for by the client, thus notification are not used. Lastly, the sample application does not actually use the capabilities retrieved as it has extremely simple OpenGL content for illustration purposes. Comments and bugs are welcome at: <http://developer.apple.com/bugreporter> Requirements: ProjectBuilder and InterfaceBuilder. Keywords: OpenGL, Cocoa, NSOpenGLContext, NSOpenGLPixelFormat, NSOpenGLView, trackball, virtual trackball, capabilities

Document Revision History

Date Notes
2003-10-27Usable as a starting point for Cocoa OpenGL applications needing a custom version of NSOpenGLView.



Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.