Make the OpenGL display look good on retina displays. #318
nico wants to merge 3 commits into openscad:master from nico:retina_gl
Commits on Mar 23, 2013
Qt doesn't support an official API for opting in to retina mode for GL views yet. Behind the scenes, a QGLView uses an NSOpenGLView, which needs a call to -setWantsBestResolutionOpenGLSurface:YES to opt in to this mode. This CL pokes at Qt internals to do this call -- due to QGLView.cc only allowing C++ code, this is done by explicitly calling out to the Objective-C runtime. The reason this mode needs an explicit opt-in is because it requires expicit code to support retina mode in OpenGL. OpenGL is pixel-based, while Cocoa (and possibly Qt) use logical view coordinates, where one coordinate corresponds to two physical pixels on retina displays. Because of this, several parameters passed to OpenGL need to explicitly be scaled by the view scale factor. I did this in the visually obvious places in this patch, but I fairly certainly missed a few places. I also didn't test image saving, which might be broken to. (I also didn't test with a 32 bit build, which has to use a slightly different Obj-C API, but that part has a chance of being correct.) Another thing this patch doesn't handle is dynamic scale factor changes, which happen when dragging an OpenSCAD window from a retina display to an external display. It's possible that it happens to work, but I haven't tested it.