CGL vs OpenGL on Mac
Asked Answered
S

2

1

I am trying to figure out the relationship between CGL and OpenGL on Mac platform.

More specifically about the context. Do they share context? If yes, how? Please give me a link to some related examples.

If no, then are there two contexts working in Core Animation applications which make use of OpenGL?

I am very confused by the use of OpenGL by Mac. Can somebody clarify?

Saez answered 29/8, 2011 at 14:34 Comment(0)
H
3

CGL sets up device specific contexts suitable for OpenGL to render to. Compare to wgl and xgl on Windows and X respectively. CGL understands how to query the graphics hardware for its pixel format, and then how to set up and configure a context (e.g. double-buffered or single-buffered, what resolution depth, stencil, accumulation buffer, etc). But it doesn't provide functions to draw in that context. Once you have created the context with CGL, you make it current, and then you can call OpenGL to render in that context.

In Core Graphics (do not confuse it with CGL), both context initialization and drawing into the context are handled by the same framework. But because OpenGL is an open standard and designed to be cross-platform, the rendering functionality and the device context functionality have been abstracted into separate frameworks.

Halothane answered 13/11, 2012 at 5:20 Comment(0)
B
0

CGL is the low-level interface to OpenGL on a Mac. You probably don't want to be using it if you are writing an OpenGL Mac app. I am currently in the process of creating a intuitive OpenGL Mac application template for XCode 4, but in the mean time you can look at https://github.com/mk12/Pong-Ultimate, a pong clone I made using OpenGL. It uses NSOpenGL, a higher-level Cocoa interface to OpenGL.

You may also find the Apple docs helpful: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_intro/opengl_intro.html.

Bioscope answered 24/9, 2011 at 2:9 Comment(6)
I am working with the things where I need to have understanding of CGL & OpenGL interactions. So far, I have been able to understand that OpenGL & CGL are two different framework but they can share the context. Core Animation apps dont make use of OpenGL. They make use of CGL. If application directly uses OpenGL then only openGL framework is used, else CGL is used.Saez
@Rahul: So you're saying you want to know when frameworks use CGL to interface with OpenGL, and when they don't? Just wondering, why? If Core Animation uses CGL, then it obviously must be using OpenGL as well, as that is the sole purpose of CGL.Bioscope
Thats what I use to think. But it not the case. CGL does not use OpenGL. Then how are they related? Thats where I am stuck. In fact, I am having hard time to figure out what Dock & Finder do. They dont use CGL nor OpenGL. You can check there symbolic links by nm tool.Saez
@Rahul: "CGL (Core OpenGL) is the lowest-level programming interface for the Apple implementation of OpenGL." developer.apple.com/library/mac/#documentation/GraphicsImaging/….Bioscope
@MacGeek: Not sure what you mean about nm saying that Finder doesn't use OpenGL. If you use otool -L on the Finder's binary, you'll see that it links against OpenGL.Territerrible
Yes It makes use of OpenGL. I was wrong. It makes use of OpenGL for CoverFlow and Icon view within finder window.Saez

© 2022 - 2024 — McMap. All rights reserved.