-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.py
More file actions
96 lines (66 loc) · 2.72 KB
/
basic.py
File metadata and controls
96 lines (66 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import RGFW
from OpenGL.GL import *
icon = [0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF]
running = 1
def focus(win, focus):
if (focus):
print("window in focus")
else:
print("window out of focus")
def main():
global win2
global running
win = RGFW.createWindow("RGFW Example Window", RGFW.rect(500, 500, 500, 500), RGFW.ALLOW_DND | RGFW.CENTER)
win.makeCurrent()
win.setIcon(icon, RGFW.area(3, 3), 4)
win.swapInterval(1)
win.buffer[0] = 1
win2 = RGFW.createWindow("subwindow", RGFW.rect(200, 200, 200, 200), 0)
glEnable(GL_BLEND)
glEnable(GL_BLEND)
glClearColor(0, 0, 0, 0)
while (RGFW.window.shouldClose(win) == False):
win2.checkEvent()
while (win.checkEvent()):
if (win.event.type == RGFW.windowMoved):
print("window moved")
elif (win.event.type == RGFW.windowResized):
print("window resized")
if (win.event.type == RGFW.quit):
running = 0
break
if (RGFW.isPressed(win, RGFW.Up)):
string = RGFW.readClipboard(None)
print("Pasted : ", RGFW.cstrToStr(string))
elif (RGFW.isPressed(win, RGFW.Down)):
RGFW.writeClipboard("DOWN")
elif (RGFW.isPressed(win, RGFW.w)):
win.setMouseDefault()
elif (RGFW.isPressed(win, RGFW.q)):
win.showMouse(0)
elif (RGFW.isPressed(win, RGFW.t)):
win.setMouse(icon, RGFW.area(3, 3), 4)
if (win.event.type == RGFW.dnd):
for i in range(win.event.droppedFilesCount):
print("dropped :", RGFW.cstrToStr(win.event.droppedFiles[i]))
elif (win.event.type == RGFW.gpButtonPressed):
print("pressed :", win.event.button)
elif (win.event.type == RGFW.gpAxisMove and not win.event.button):
print("{", win.event.axis[0].x, "} {", win.event.axis[0].y, "}")
drawLoop(win)
drawLoop(win2)
win.close()
def drawLoop(w):
w.makeCurrent()
glClearColor(255, 255, 255, 255)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glBegin(GL_TRIANGLES)
glColor3f(1, 0, 0)
glVertex2f(-0.6, -0.75)
glColor3f(0, 1, 0)
glVertex2f(0.6, -0.75)
glColor3f(0, 0, 1)
glVertex2f(0, 0.75)
glEnd()
w.swapBuffers()
main()