Hello fellow Cocoa developers,
I would like to check with some of the experts here to see if they might be able to help clarify an area where the docs are lacking. Right now we have a method that is meant to be testing the VRAM by getting the base address of the display and writing / reading a pattern of bytes starting at that address. This provides the effect that each pixel on the display is successively set to a specific color which is then read back to make sure it is the same as what is expected.
The original implementation used quickdraw functions to obtain this address, and I have been tasked with bringing it up to date for 10.4+. I am using CGDisplayCaptureWithOptions(kCGDirectMainDisplay, kCGCaptureNoFill)
and then getting the base address by calling CGDisplayBaseAddress(kCGDirectMainDisplay)
. This seems to do what I expect and the implementation is working just as well as the previous version.
The only question left for me to ask is if this is really writing to VRAM or is it just the display's buffer in RAM? Or should I use something like OpenGL to do this? Thank you all for any pointers and/or suggestions. I can provide a code sample if you think it is necessary.
From Apple's docs:
CGDisplayBaseAddress(), deprecated in Mac OS X 10.6
"Returns the base address in framebuffer memory of an online display. Instead of using the raw framebuffer to draw to the screen, you should instead use a supported drawing engine such as Quartz or OpenGL."
It sounds like a good recommendation. You should use OpenGL for both drawing and testing (I suppose, with glReadPixels()
).