Skip to content

Commit 8b3eb5f

Browse files
add more features to the example
1 parent a592976 commit 8b3eb5f

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

basic.odin

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import gl "vendor:OpenGL"
66

77
running := true
88

9+
icon := []u8{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};
10+
911
main :: proc() {
1012
win := RGFW.createWindow("RGFW Example Window", {500, 500, 500, 500}, RGFW.ALLOW_DND | RGFW.CENTER);
1113
RGFW.window_makeCurrent(win);
1214

1315
gl.load_up_to(3, 3, RGFW.gl_set_proc_address)
1416

1517
RGFW.window_swapInterval(win, 1);
16-
17-
i : u32;
18+
RGFW.window_setIcon(win, raw_data(icon), {3, 3}, 4);
1819

1920
gl.ClearColor(0, 0, 0, 0);
2021

@@ -30,16 +31,36 @@ main :: proc() {
3031
running = false;
3132
break;
3233
}
33-
34+
if (RGFW.isPressedI(win, .Up)) {
35+
str := RGFW.readClipboard(nil);
36+
fmt.printf("Pasted : %s\n", str);
37+
RGFW.clipboardFree(str);
38+
}
39+
else if (RGFW.isPressedI(win, .Down)) {
40+
RGFW.writeClipboard("DOWN", 4);
41+
}
42+
else if (RGFW.isPressedI(win, .Space)) {
43+
fmt.printf("fps : %i\n", win.event.fps);
44+
}
45+
else if (RGFW.isPressedI(win, .w)) {
46+
RGFW.window_setMouseDefault(win);
47+
}
48+
else if (RGFW.isPressedI(win, .q)) {
49+
RGFW.window_showMouse(win, 0);
50+
}
51+
else if (RGFW.isPressedI(win, .t)) {
52+
RGFW.window_setMouse(win, raw_data(icon), {3, 3}, 4);
53+
}
54+
3455
if (win.event.type == RGFW.dnd) {
35-
for i = 0; i < win.event.droppedFilesCount; i+=1 {
56+
for i := u32(0); i < win.event.droppedFilesCount; i += 1 {
3657
fmt.printf("dropped : %s\n", win.event.droppedFiles[i]);
3758
}
3859
}
3960
else if (win.event.type == RGFW.jsButtonPressed) {
4061
fmt.printf("pressed %i\n", win.event.button);
4162
}
42-
else if (win.event.type == RGFW.jsAxisMove && win.event.button != 0) {
63+
else if (win.event.type == RGFW.jsAxisMove && !bool(win.event.button)) {
4364
fmt.printf("{%i, %i}\n", win.event.axis[0].x, win.event.axis[0].y);
4465
}
4566
}
@@ -53,7 +74,7 @@ main :: proc() {
5374
drawLoop :: proc(w: ^RGFW.window) {
5475
RGFW.window_makeCurrent(w);
5576

56-
gl.ClearColor(255, 255, 255, 255);
77+
gl.ClearColor(0.35, 0, 0.25, 255);
5778

5879
gl.Clear(gl.COLOR_BUFFER_BIT);
5980

0 commit comments

Comments
 (0)