About OpenGL for Os X

OpenGL is an open up, cross-platform graphics standard with broad industry back up. OpenGL greatly eases the task of writing real-time 2d or 3D graphics applications by providing a mature, well-documented graphics processing pipeline that supports the abstraction of current and future hardware accelerators.

../art/cpu_gpu.jpg

At a Glance

OpenGL is an excellent choice for graphics development on the Macintosh platform because it offers the following advantages:

  • Reliable Implementation. The OpenGL customer-server model abstracts hardware details and guarantees consistent presentation on any compliant hardware and software configuration. Every implementation of OpenGL adheres to the OpenGL specification and must pass a set of conformance tests.

  • Performance. Applications tin can harness the considerable power of the graphics hardware to improve rendering speeds and quality.

  • Industry acceptance. The specification for OpenGL is controlled by the Khronos Grouping, an industry consortium whose members include many of the major companies in the computer graphics manufacture, including Apple tree. In addition to OpenGL for OS X, there are OpenGL implementations for Windows, Linux, Irix, Solaris, and many game consoles.

OpenGL Is a C-based, Platform-Neutral API

Considering OpenGL is a C-based API, it is extremely portable and widely supported. As a C API, it integrates seamlessly with Objective-C based Cocoa applications. OpenGL provides functions your awarding uses to generate second or 3D images. Your application presents the rendered images to the screen or copies them back to its own memory.

The OpenGL specification does not provide a windowing layer of its ain. It relies on functions defined by OS 10 to integrate OpenGL cartoon with the windowing system. Your application creates an OS 10 OpenGL rendering context and attaches a rendering target to it (known as a drawable object). The rendering context manages OpenGL state changes and objects created by calls to the OpenGL API. The drawable object is the final destination for OpenGL drawing commands and is typically associated with a Cocoa window or view.

Different Rendering Destinations Crave Different Setup Commands

Depending on whether your application intends to depict OpenGL content to a window, to draw to the entire screen, or to perform offscreen image processing, it takes unlike steps to create the rendering context and associate it with a drawable object.

OpenGL on Macs Exists in a Heterogenous Surroundings

Macs support different types of graphics processors, each with dissimilar rendering capabilities, supporting versions of OpenGL from 1.10 through OpenGL iii.two. When creating a rendering context, your application tin can accept a broad range of renderers or it tin can restrict itself to devices with specific capabilities. Once y'all take a context, you can configure how that context executes OpenGL commands.

OpenGL on the Mac is not only a heterogenous environs, just it is also a dynamic environment. Users can add together or remove displays, or have a laptop running on bombardment power and plug it into a wall. When the graphics surround on the Mac changes, the renderer associated with the context may alter. Your application must handle these changes and arrange how it uses OpenGL.

OpenGL Helps Applications Harness the Power of Graphics Processors

Graphics processors are massively parallelized devices optimized for graphics operations. To access that computing ability adds boosted overhead because data must move from your application to the GPU over slower internal buses. Accessing the same information simultaneously from both your application and OpenGL is usually restricted. To become great performance in your application, you must carefully blueprint your application to feed data and commands to OpenGL so that the graphics hardware runs in parallel with your application. A poorly tuned application may stall either on the CPU or the GPU waiting for the other to cease processing.

When you are gear up to optimize your awarding's performance, Apple provides both full general-purpose and OpenGL-specific profiling tools that make information technology easy to learn where your application spends its time.

Concurrency in OpenGL Applications Requires Additional Effort

Many Macs send with multiple processors or multiple cores, and futurity hardware is expected to add more of each. Designing applications to take advantage of multiprocessing is critical. OpenGL places additional restrictions on multithreaded applications. If yous intend to add together concurrency to an OpenGL application, you lot must ensure that the awarding does not admission the aforementioned context from 2 different threads at the aforementioned time.

Operation Tuning Allows Your Awarding to Provide an Infrequent User Experience

Once you've improved the performance of your OpenGL application and taken reward of concurrency, put some of the freed processing ability to piece of work for you. College resolution textures, detailed models, and more circuitous lighting and shading algorithms can better image quality. Full-scene antialiasing on modern graphics hardware tin eliminate many of the "jaggies" common on lower resolution images.

How to Utilize This Document

If you have never programmed in OpenGL on the Mac, you should read this volume in its entirety, starting with OpenGL on the Mac Platform . Critical Mac terminology is defined in that chapter as well as in the Glossary .

If yous already have an OpenGL application running on the Mac, but have not yet updated it for OS Ten v10.seven, read Choosing Renderer and Buffer Attributes to learn how to choose an OpenGL profile for your application.

To find out how to update an existing OpenGL app for high resolution, see Optimizing OpenGL for High Resolution .

In one case you have OpenGL content in your application, read OpenGL Application Design Strategies to learn key patterns for implementing high-performance OpenGL applications, and the chapters that follow to learn how to apply those patterns to specific OpenGL problems.

Prerequisites

This guide assumes that you have some experience with OpenGL programming, but desire to learn how to apply that knowledge to create software for the Mac. Although this guide provides communication on optimizing OpenGL code, it does not provide entry-level information on how to utilise the OpenGL API. If y'all are unfamiliar with OpenGL, you should read OpenGL on the Mac Platform to get an overview of OpenGL on the Mac platform, then read the following OpenGL programming guide and reference documents:

  • OpenGL Programming Guide , by Dave Shreiner and the Khronos OpenGL Working Group; otherwise known as "The Carmine volume."

  • OpenGL Shading Language, by Randi J. Rost, is an excellent guide for those who want to write programs that compute surface properties (likewise known as shaders).

  • OpenGL Reference Pages .

Before reading this document, you should be familiar with Cocoa windows and views as introduced in Window Programming Guide and View Programming Guide .

See Also

Go on these reference documents handy equally you develop your OpenGL plan for Os X:

The OpenGL Foundation website, http://www.opengl.org , provides data on OpenGL commands, the Khronos OpenGL Working Group, logo requirements, OpenGL news, and many other topics. It's a site that you lot'll want to visit regularly. Among the many resources information technology provides, the following are important reference documents for OpenGL developers:

  • OpenGL Specification provides detailed information on how an OpenGL implementation is expected to handle each OpenGL command.

  • OpenGL Reference describes the main OpenGL library.

  • OpenGL GLU Reference describes the OpenGL Utility Library, which contains convenience functions implemented on height of the OpenGL API.

  • OpenGL Overabundance Reference describes the OpenGL Utility Toolkit, a cross-platform windowing API.

  • OpenGL API Code and Tutorial Listings provides lawmaking examples for fundamental tasks, such as modeling and texture mapping, as well equally for avant-garde techniques, such as high dynamic range rendering (HDRR).