私はMacでPyOpenGLを使用しています。デフォルトでは、OpenGL 2.1が使用されています。しかし、私の研究とOpenGL Extension Viewerによると、私はOpenGL 4.1を使用できるはずです。 私はQGLFormatをQGLWidgetに渡そうとしていますが、ここでは多くのスレッドで行われていますが、コンテキストのバージョンは変更されません。私がそれを強制しようとすると、コンテキストが有効でないことがわかります。 - 私は多くのことを試してきた ここでは私の問題を示して非常に単純な例である:ここではMacOS上でQGLFormatを使ってOpenGLのバージョンを変更するには?
from PyQt4 import QtGui, QtCore, QtOpenGL
import sys
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
glFormat = QtOpenGL.QGLFormat()
glFormat.setVersion(4,1)
glFormat.setProfile(QtOpenGL.QGLFormat.CoreProfile)
glFormat.setSampleBuffers(True)
glFormat.setDefaultFormat(glFormat)
print("Format version: " + str(glFormat.majorVersion()))
myW = QtOpenGL.QGLWidget(glFormat)
print ("Widget context valid: " + str(myW.context().isValid()))
print ("Widget format version: " + str(myW.format().majorVersion()))
print ("Widget context format version: " + str(myW.context().format().majorVersion()))
myW.context().setFormat(glFormat)
print ("Forced format valid: " + str(myW.context().isValid()))
print ("Forced format version: " + str(myW.format().majorVersion()))
myW.show()
sys.exit(app.exec_())
出力されます:
Format version: 4
Widget context valid: True
Widget format version: 1
Widget context format version: 1
Forced format valid: False
Forced format version: 4
私の問題がある任意のアイデア?私は何か間違っているのですか? 私はmacOS Sierraバージョン10.12.6を使用しています。 Qtバージョン4.8.7、sipバージョン4.19.3、pyqtバージョン4.12を使用します。 こちらはwhat OpenGL Extension Viewer tells meです。
ご協力いただければ幸いです!
編集:
私はここにC++と同様の問題がどのように見えるかを発見しました。ソリューションをPyQtに翻訳する方法がわかりませんが、私はこれを調べます: Changing the OpenGL Context Version for QGLWidgets in Qt 4.8.6 on OS X。
編集3:(第二版)@ekhumoroが提供するパッチをしようとしたとき、私は次の出力を得る
:
正しくパッチが適用されqpyopengl.propatching file qpy/QtOpenGL/core_profile_attributes.mm
patching file qpy/QtOpenGL/qpyopengl.pro
patching file sip/QtOpenGL/qgl.sip
patch unexpectedly ends in middle of line
Hunk #3 FAILED at 493.
1 out of 3 hunks FAILED -- saving rejects to file sip/QtOpenGL/qgl.sip.rej
、それqgl.sipではまだ失敗します。
更新:ここ
がqgl.sipため拒否ファイルの内容です:好奇心のうち
***************
*** 478,481 ****
%ModuleHeaderCode
#include <qpyopengl_api.h>
--- 493,498 ----
%ModuleHeaderCode
#include <qpyopengl_api.h>
+ typedef struct GDevice** GDHandle;
+ void* select_3_2_mac_visual();
、私はconfigure-ng.py走ってコンパイルしてみました。私は次のエラーを取得する:
[...]/PyQt4_gpl_mac-4.12.1/sip/QtOpenGL/qgl.sip:269:5: error: 'virtual' can only appear on non-static member functions
virtual void* chooseMacVisual(GDHandle handle)
^
[...]/PyQt4_gpl_mac-4.12.1/sip/QtOpenGL/qgl.sip:271:16: error: use of undeclared identifier 'select_3_2_mac_visual'
return select_3_2_mac_visual();
^
[...]/PyQt4_gpl_mac-4.12.1/sip/QtOpenGL/qgl.sip:269:44: warning: unused parameter 'handle' [-Wunused-parameter]
virtual void* chooseMacVisual(GDHandle handle)
あなたはOSX上_forward-compatible_コンテキストを作成する必要があります。 – derhass
@derhass:あなたはもっと具体的になりますか? – Elensil