Seite 1 von 1

PyQt5: OpenGL-Hallo-Welt

Verfasst: Sonntag 13. August 2017, 21:46
von wadi
Hallo,

mein hallo-welt-programm in python3 und PyQt will nicht gelingen:

Code: Alles auswählen

import sys
from PyQt5 import QtWidgets, QtGui, QtOpenGL
import OpenGL
from OpenGL.GL import *
#from OpenGL.GLU import *
import OpenGL.GL as gl

gl.glClearColor(0.0, 0.0, 0.0, 0.0)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0.0, 1, 0.0, 1.0, -1.0, 1.0)

gl.glClear(GL_COLOR_BUFFER_BIT)
gl.glColor3f(1.0, 1.0, 1.0)
gl.glBegin(GL_LINES)
gl.glVertex2f(-1.0, -1.0)
gl.glVertex2f(0.0, 0.0)
gl.glEnd()
gl.glFlush()

app = QtWidgets.QApplication(sys.argv)
w = QtOpenGL.QGLWidget()
w.show()

app.exec()

Es sollte eine Linie gezeichnet werden. Aber das Fenster bleibt schwarz.

Re: PyQt5: OpenGL-Hallo-Welt

Verfasst: Sonntag 13. August 2017, 22:03
von __deets__
Bevor das Widget da ist, wird es auch keinen GL-Kontext geben, in den deine Befehle laufen. Schau dir mal OpenGL Beispiele auf der Qt Seite an & Bau die nach.