I have some code that displays graphics using PyOpenGL in a glut window. On a retina Macbook Pro this window appears in a low-resolution mode, with one OpenGL pixel being represented by four physical pixels. It would be much nicer if it would display in the full native resolution.
My Question
Is there any way to obtain a native resolution OpenGL context in Python on Retina displays, using glut or otherwise?
Example of the issue
Below is a minimal working example of a PyOpenGL program. There is nothing special about it - this issue will be exhibited by any working PyOpenGL code. Here is a zoomed-in detail of a screenshot. Notice that the pixels making up the white triangle are four times the size of the pixels of the OS X widgets. This is the default for programs that aren't specifically designed for Retina devices. I want to know how to turn it off for PyOpenGL programs.
Here is the code:
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
import os
def initFunc():
glDisable(GL_DEPTH_TEST)
glClearColor(0.0, 0.0, 0.0, 0.0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0.0, 400.0, 0.0, 400.0)
def displayFunc():
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.0, 1.0, 1.0)
glBegin(GL_TRIANGLES)
glVertex2f(10.0, 10.0)
glVertex2f(10.0, 100.0)
glVertex2f(100.0, 100.0)
glEnd()
glFlush()
if __name__ == '__main__':
glutInit()
glutInitWindowSize(400,400)
glutCreateWindow("GL test")
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutDisplayFunc(displayFunc)
initFunc()
os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
# prevent GL window from appearing behind other applications
glutMainLoop()