forked from revery-ui/revery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenGLExample.re
78 lines (70 loc) · 1.79 KB
/
OpenGLExample.re
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
open Sdl2;
open Revery;
/* open Revery.Draw; */
open Revery.UI;
let containerStyle =
Style.[
position(`Absolute),
top(0),
bottom(0),
left(0),
right(0),
alignItems(`Center),
justifyContent(`Center),
flexDirection(`Column),
];
let outerBox =
Style.[width(450), height(450), backgroundColor(Colors.black)];
module Sample = {
let component = React.component("OpenGLSample");
let createElement = (~children as _, ()) =>
component(hooks =>
(
hooks,
<View style=containerStyle>
<OpenGL
style=outerBox
render={(transform, _pctx) => {
Gl.glClearColor(1.0, 0.0, 0.0, 1.0);
Revery.Draw.Text.drawString(
~transform,
~backgroundColor=Colors.red,
~color=Colors.white,
~fontFamily="Roboto-Regular.ttf",
~fontSize=20,
~x=25.,
~y=25.,
"Hello!",
);
Revery.Draw.Shapes.drawRect(
~transform,
~color=Colors.green,
~x=25.,
~y=50.,
~width=10.,
~height=20.,
(),
);
}}
/* STRESS TEST:
let iterations = 50000;
let i = ref(0);
while (i^ < iterations) {
Revery.Draw.Shapes.drawRect(
~transform,
~color=Colors.green,
~x=25.,
~y=50.,
~width=10.,
~height=20.,
(),
);
incr(i);
};
*/
/>
</View>,
)
);
};
let render = () => <Sample />;