1
1
#!/usr/bin/env python3
2
- from abc import ABCMeta , abstractmethod
3
- from qtpy .QtWidgets import QWidget , QApplication
4
2
import sys
5
- from WebGPUWidget import WebGPUWidget
3
+
4
+ import numpy as np
6
5
from qtpy .QtCore import Qt
6
+ from qtpy .QtWidgets import QApplication
7
+ from WebGPUWidget import WebGPUWidget
7
8
8
9
9
10
class WebGPUScene (WebGPUWidget ):
@@ -21,16 +22,19 @@ def initializeWebGPU(self) -> None:
21
22
This method sets up the WebGPU context for the scene.
22
23
"""
23
24
print ("initializeWebGPU" )
25
+ self .startTimer (100 )
24
26
25
27
def paintWebGPU (self ) -> None :
26
28
"""
27
29
Paint the WebGPU content.
28
30
29
31
This method renders the WebGPU content for the scene.
30
32
"""
31
- print ("paintWebGPU" )
32
33
self .render_text (10 , 20 , "PaintGPU Test" , size = 20 , colour = Qt .yellow )
33
34
35
+ # going to randomly generate an np buff to fill the screen
36
+ self .buffer = np .random .randint (0 , 255 , (1024 , 720 , 4 ), dtype = np .uint8 )
37
+
34
38
def resizeWebGPU (self , width : int , height : int ) -> None :
35
39
"""
36
40
Resize the WebGPU context.
@@ -43,6 +47,9 @@ def resizeWebGPU(self, width: int, height: int) -> None:
43
47
"""
44
48
print (f"resizeWebGPU { width } { height } " )
45
49
50
+ def timerEvent (self , event ):
51
+ self .update ()
52
+
46
53
47
54
app = QApplication (sys .argv )
48
55
win = WebGPUScene ()
0 commit comments