In order to correctly execute the resolution you need, you will need to use NSView and then indicate that the view should use the best resolution (this also means that you should no longer use GLUT). Since this is outside the scope of OpenGL, and you want to use Python, you will need to use a package that will access these types of objects along with py2app (but full py2app build not required).
To access NSView or, more specifically, NSOpenGLView , NSOpenGLView for your needs. The following code imports Cocoa (provided by pyobjc ) for clarity only, the same objects can be accessed through AppKit . The code creates an NSWindow , and then a view that defines the drawRect to call if necessary. The only line that solves the permission problem: view.setWantsBestResolutionOpenGLSurface_(True) .
import Cocoa from OpenGL.GL import * from OpenGL.GLU import * class GLView(Cocoa.NSOpenGLView): def initWithFrame_(self, frame): format = Cocoa.NSOpenGLPixelFormat.alloc().initWithAttributes_((0, )) view = super(GLView, self).initWithFrame_pixelFormat_(frame, format) view.setWantsBestResolutionOpenGLSurface_(True) view.openGLContext().makeCurrentContext() glDisable(GL_DEPTH_TEST) glClearColor(0.0, 0.0, 0.0, 0.0) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluOrtho2D(0.0, 1.0, 0.0, 1.0) return view def drawRect_(self, bounds): glClear(GL_COLOR_BUFFER_BIT) glColor3f(1.0, 1.0, 1.0) glBegin(GL_TRIANGLES) glVertex2f(0.1, 0.1) glVertex2f(0.1, 0.9) glVertex2f(0.9, 0.9) glEnd() glFlush() class AppDelegate(Cocoa.NSObject): def windowWillClose_(self, notification): app.terminate_(self) app = Cocoa.NSApplication.sharedApplication() rect = Cocoa.NSMakeRect(0, 0, 300, 300) winflags = Cocoa.NSTitledWindowMask | Cocoa.NSClosableWindowMask win = Cocoa.NSWindow.alloc().initWithContentRect_styleMask_backing_defer_( rect, winflags, Cocoa.NSBackingStoreBuffered, False) delegate = AppDelegate.alloc().init() win.setDelegate_(delegate) view = GLView.alloc().initWithFrame_(rect) win.setContentView_(view) win.makeKeyAndOrderFront_(None) app.run()
If you try to run this code, it will work fine, but you will not notice any difference in the resolution problem. To solve this problem, you need to build a simple setup.py , assuming that the above code was saved in a file called test1.py :
from distutils.core import setup import py2app setup(app=["test1.py"])
Then run mypythonexecutable setup.py py2app -A (where, of course, mypythonexecutable is replaced with something that makes sense, like python or python2.7 for example). Now you run open dist/test1.app and the problem is resolved ( dist/test1.app will be created after running the earlier command).