ReachConnection ReachConnection - 2 months ago 16
Objective-C Question

How to load IOSurface in OpenGL for Mac OS X Snow Leopard application

Apple added the new IOSurface framework as part of the 10.6 Mac OS X firm update. Since this framework relatively new, I haven't found the much need documentation on how to properly use this.

I was wondering if there anyone on StackOverflow that can assist me with IOSurface usage.

Anyways, this is what I want to do. Right now my application is very simple so that I can become familiar with IOSurfaces. So essentially, I would want to load up an image into an IOSurface texture and display in a custom OpenGLView. That's all I am aiming for at this point.

To make this more simple, I just load one constant color in the IOSurface. My main objective at this point is to create an IOSurface reference and display in a custom OpenGL view.

Please help me with
-IOSurface declaration statements
-Loading data into the IOSurface
-and the syntax for drawing the IOSurface in OpenGL.

Much appreciated.


IOSurface is like a memory manager that passes graphic data between applications or something a long the line of that.

I have tried Google IOSurface. And the most helpful site is

However, when I tried compile the example code, I have a compiler error stating that QTVisualContextRef and other QuickTime variables undeclared. I have the latest version of Quick Time through the automatic update.

vt. vt.

The IOSurface API is quite similar to Core Video's CVPixelBuffer, which is documented, so you could start by looking at the CVPixelBuffer documentation and comparing with IOSurfaceAPI.h.

To bind an OpenGL texture to an IOSurface, see the CGLTexImageIOSurface2D function, which is defined in <OpenGL/CGLIOSurface.h>.