Skip to content

Commit 35e3209

Browse files
committed
Correcting mistakes from Copilot
PyQt5.QtOpenGL's widget is called "QGLWidget" (QOpenGLWidget is QT6). We don't currently expose GrGLMakeNativeInterface() in skia-python. And, defaultFramebufferObject() is not a method in "QGLWidget". skia.GrGLMakeNativeInterface() exists, but is behind a "#if !defined(SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE)" and probably should not be used directly.
1 parent 3d45ffb commit 35e3209

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

SkiaPyQt5Example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import sys
22
from PyQt5 import QtWidgets, QtCore, QtGui
33
from PyQt5.QtWidgets import QApplication, QMainWindow
4-
from PyQt5.QtOpenGL import QOpenGLWidget
4+
from PyQt5.QtOpenGL import QGLWidget
55
import skia
66
import OpenGL.GL as gl
77

8-
class SkiaGLWidget(QOpenGLWidget):
8+
class SkiaGLWidget(QGLWidget):
99
def __init__(self, parent=None):
1010
super().__init__(parent)
1111
self.setMouseTracking(True)
@@ -16,7 +16,7 @@ def __init__(self, parent=None):
1616

1717
def initializeGL(self):
1818
# Set up Skia with the current OpenGL context
19-
interface = skia.GrGLMakeNativeInterface()
19+
interface = skia.GrGLInterface()
2020
self.gr_context = skia.GrDirectContext.MakeGL(interface)
2121
self._create_surface()
2222

@@ -46,7 +46,8 @@ def mouseMoveEvent(self, event):
4646
def _create_surface(self):
4747
# Called in initializeGL and resizeGL to (re)create the Skia surface
4848
w, h = self.width(), self.height()
49-
fb_id = self.defaultFramebufferObject()
49+
#fb_id = self.defaultFramebufferObject()
50+
fb_id = 0
5051
if w == 0 or h == 0:
5152
self.surface = None
5253
return

0 commit comments

Comments
 (0)