CGL vs AGL vs OpenGL vs NSOpenGL vs CoreAnimation(CALayer)
Asked Answered
A

1

5

I am trying to understand few things on Mac related to OpenGL framework integration in the form of layers. Well basically when I want to understand 3D technologies present in OS X and which layer is OpenGL's actual implentation layer.

From reading apple docs, below is what I have understood so far:

1.NSOpenGLContext object wraps a low-level, platform-specific Core OpenGL (CGL) context.

= This makes it clear that NSOpenGL makes use of CGL.

2.The AGL (Apple Graphics Library) API is part of the Apple implementation of OpenGL in Mac OS X.

= So, does AGL and CGL are related in any way?

3.CGL (Core OpenGL) is the lowest-level programming interface for the Apple implementation of OpenGL.

= Does it mean Standard OpenGL API's are just wrapper over CGL?

4.CoreAnimation seems to be combo of Core Graphics, Open-GL and Quick-time. But I am not sure what it uses underneath it, I mean actual implementation layer, is it again CGL?

Things are not completely clear to me. I am still reading though and I have asked somewhat related question in past but with incomplete knowledge.

I would really appreciate if someone can share his understanding on matter.

Ammonic answered 31/1, 2012 at 11:54 Comment(2)
My understanding is that AGL is deprecated (or at least not actively developed) in favour of CGL.Carisacarissa
That means, they are independent technologies?Ammonic
H
9

NSOpenGLContext, AGL and CGL are all APIs for setting up an OpenGL context you can draw into.

Use NSOpenGLContext unless you already know you have a reason not to.

Use AGL if you are writing a Carbon application or if you need compatibility with Mac OS 9 (As of 2012, that basically means: don't).

Both AGL and NSOpenGLContext are implemented on top of CGL. However, not all the necessary parts of CGL are actually public APIs. Last time I checked, the only public parts of the CGL API where the ones that allow you to create a fullscreen OpenGL context. If you want OpenGL in a window or you want the option of showing dialog boxes or some NSViews on top of your OpenGL, you probably can't use CGL.

CoreAnimation is a framework for (mostly UI) animations; you can use CoreAnimation without using OpenGL directly. I have never used it myself, but I assume it also allows you to create an OpenGL context for an animation layer. Use it if you already have other reasons to use CoreAnimation, or if you want to combine OpenGL graphics and Mac GUI widgets in creative ways.

Holmquist answered 31/1, 2012 at 13:27 Comment(3)
Thank you. I understood most of the things and I have to study core animation in order to understand your description on core animation. I still have Question about how OpenGL and CGL are interacting. Is CGL low level implementation of OpenGL for Mac? I mean in terms of layered hierarchy.Ammonic
"OpenGL" per se assumes that you already have an OpenGL context. To be able to do anything at all with OpenGL, you also need a (usually platform-specific) way to get such a context. NSOpenGLContext, AGL and CGL are such ways. Let's say CGL is an indispensable companion to OpenGL for Mac, and NSOpenGLContext and AGL build on top of CGL.Holmquist
To use OpenGL with CoreAnimation, you can use the CAOpenGLLayer.Peculiarize

© 2022 - 2024 — McMap. All rights reserved.