我有一些代碼在超過窗口中使用PyOpenGL顯示圖形。在視網膜Macbook Pro上,此窗口以低分辨率模式顯示,其中一個OpenGL像素由四個物理像素表示。如果它能夠以完整的原始分辨率顯示,會更好。MacOne視網膜顯示屏上的PyOpenGL
我的問題
有什麼辦法獲得Python中的Retina顯示屏的原始分辨率OpenGL上下文,使用過剩或以其他方式?
問題示例
下面是一個PyOpenGL程序的最小工作示例。沒有什麼特別的 - 這個問題將通過任何工作的PyOpenGL代碼展現出來。這是一個截圖的放大細節。請注意,構成白色三角形的像素是OS X小部件像素大小的四倍。這是不是專門爲Retina設備設計的程序的默認設置。我想知道如何關閉PyOpenGL程序。
下面是代碼:
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()
你或許應該張貼一些代碼。 – djc 2013-02-11 10:06:01
你以後在https://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Introduction/Introduction.html在http://developer.apple.com證明什麼,更直接/library/mac/#documentation/graphicsimaging/conceptual/opengl-macprogguide/EnablingOpenGLforHighResolution/EnablingOpenGLforHighResolution.html。現在你需要將它映射到Python。 – mmgp 2013-02-14 14:29:18
@Nathaniel所以問題是另一回事。它似乎並不像你都知道是需要什麼的,現在你做的僅僅是知道如何使用'所獲得NSOpenGLView'的事'從AppKit的進口NSOpenGLView'。 – mmgp 2013-02-14 14:47:31