@gtkx/ffi 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cairo/cairo.d.ts +30 -0
- package/dist/cairo/cairo.js +171 -0
- package/dist/cairo/index.d.ts +2 -0
- package/dist/cairo/index.js +2 -0
- package/dist/codegen/ffi-generator.js +4 -0
- package/dist/generated/gtk/drawing-area.d.ts +1 -1
- package/dist/generated/gtk/drawing-area.js +11 -10
- package/dist/gl/constants.d.ts +45 -0
- package/dist/gl/constants.js +45 -0
- package/dist/gl/gl.d.ts +42 -0
- package/dist/gl/gl.js +263 -0
- package/dist/gl/index.d.ts +2 -0
- package/dist/gl/index.js +2 -0
- package/package.json +13 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function moveTo(cr: unknown, x: number, y: number): void;
|
|
2
|
+
export declare function lineTo(cr: unknown, x: number, y: number): void;
|
|
3
|
+
export declare function curveTo(cr: unknown, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
|
|
4
|
+
export declare function arc(cr: unknown, xc: number, yc: number, radius: number, angle1: number, angle2: number): void;
|
|
5
|
+
export declare function arcNegative(cr: unknown, xc: number, yc: number, radius: number, angle1: number, angle2: number): void;
|
|
6
|
+
export declare function rectangle(cr: unknown, x: number, y: number, width: number, height: number): void;
|
|
7
|
+
export declare function closePath(cr: unknown): void;
|
|
8
|
+
export declare function newPath(cr: unknown): void;
|
|
9
|
+
export declare function newSubPath(cr: unknown): void;
|
|
10
|
+
export declare function stroke(cr: unknown): void;
|
|
11
|
+
export declare function strokePreserve(cr: unknown): void;
|
|
12
|
+
export declare function fill(cr: unknown): void;
|
|
13
|
+
export declare function fillPreserve(cr: unknown): void;
|
|
14
|
+
export declare function paint(cr: unknown): void;
|
|
15
|
+
export declare function paintWithAlpha(cr: unknown, alpha: number): void;
|
|
16
|
+
export declare function setSourceRgb(cr: unknown, red: number, green: number, blue: number): void;
|
|
17
|
+
export declare function setSourceRgba(cr: unknown, red: number, green: number, blue: number, alpha: number): void;
|
|
18
|
+
export declare function setLineWidth(cr: unknown, width: number): void;
|
|
19
|
+
export declare function setLineCap(cr: unknown, lineCap: number): void;
|
|
20
|
+
export declare function setLineJoin(cr: unknown, lineJoin: number): void;
|
|
21
|
+
export declare function setDash(cr: unknown, dashes: number[], offset: number): void;
|
|
22
|
+
export declare function save(cr: unknown): void;
|
|
23
|
+
export declare function restore(cr: unknown): void;
|
|
24
|
+
export declare function translate(cr: unknown, tx: number, ty: number): void;
|
|
25
|
+
export declare function scale(cr: unknown, sx: number, sy: number): void;
|
|
26
|
+
export declare function rotate(cr: unknown, angle: number): void;
|
|
27
|
+
export declare function clip(cr: unknown): void;
|
|
28
|
+
export declare function clipPreserve(cr: unknown): void;
|
|
29
|
+
export declare function resetClip(cr: unknown): void;
|
|
30
|
+
export declare function setOperator(cr: unknown, op: number): void;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { call } from "@gtkx/native";
|
|
2
|
+
const LIB = "libcairo.so.2";
|
|
3
|
+
const CAIRO_T = { type: "int", size: 64, unsigned: true };
|
|
4
|
+
export function moveTo(cr, x, y) {
|
|
5
|
+
call(LIB, "cairo_move_to", [
|
|
6
|
+
{ type: CAIRO_T, value: cr },
|
|
7
|
+
{ type: { type: "float", size: 64 }, value: x },
|
|
8
|
+
{ type: { type: "float", size: 64 }, value: y },
|
|
9
|
+
], { type: "undefined" });
|
|
10
|
+
}
|
|
11
|
+
export function lineTo(cr, x, y) {
|
|
12
|
+
call(LIB, "cairo_line_to", [
|
|
13
|
+
{ type: CAIRO_T, value: cr },
|
|
14
|
+
{ type: { type: "float", size: 64 }, value: x },
|
|
15
|
+
{ type: { type: "float", size: 64 }, value: y },
|
|
16
|
+
], { type: "undefined" });
|
|
17
|
+
}
|
|
18
|
+
export function curveTo(cr, x1, y1, x2, y2, x3, y3) {
|
|
19
|
+
call(LIB, "cairo_curve_to", [
|
|
20
|
+
{ type: CAIRO_T, value: cr },
|
|
21
|
+
{ type: { type: "float", size: 64 }, value: x1 },
|
|
22
|
+
{ type: { type: "float", size: 64 }, value: y1 },
|
|
23
|
+
{ type: { type: "float", size: 64 }, value: x2 },
|
|
24
|
+
{ type: { type: "float", size: 64 }, value: y2 },
|
|
25
|
+
{ type: { type: "float", size: 64 }, value: x3 },
|
|
26
|
+
{ type: { type: "float", size: 64 }, value: y3 },
|
|
27
|
+
], { type: "undefined" });
|
|
28
|
+
}
|
|
29
|
+
export function arc(cr, xc, yc, radius, angle1, angle2) {
|
|
30
|
+
call(LIB, "cairo_arc", [
|
|
31
|
+
{ type: CAIRO_T, value: cr },
|
|
32
|
+
{ type: { type: "float", size: 64 }, value: xc },
|
|
33
|
+
{ type: { type: "float", size: 64 }, value: yc },
|
|
34
|
+
{ type: { type: "float", size: 64 }, value: radius },
|
|
35
|
+
{ type: { type: "float", size: 64 }, value: angle1 },
|
|
36
|
+
{ type: { type: "float", size: 64 }, value: angle2 },
|
|
37
|
+
], { type: "undefined" });
|
|
38
|
+
}
|
|
39
|
+
export function arcNegative(cr, xc, yc, radius, angle1, angle2) {
|
|
40
|
+
call(LIB, "cairo_arc_negative", [
|
|
41
|
+
{ type: CAIRO_T, value: cr },
|
|
42
|
+
{ type: { type: "float", size: 64 }, value: xc },
|
|
43
|
+
{ type: { type: "float", size: 64 }, value: yc },
|
|
44
|
+
{ type: { type: "float", size: 64 }, value: radius },
|
|
45
|
+
{ type: { type: "float", size: 64 }, value: angle1 },
|
|
46
|
+
{ type: { type: "float", size: 64 }, value: angle2 },
|
|
47
|
+
], { type: "undefined" });
|
|
48
|
+
}
|
|
49
|
+
export function rectangle(cr, x, y, width, height) {
|
|
50
|
+
call(LIB, "cairo_rectangle", [
|
|
51
|
+
{ type: CAIRO_T, value: cr },
|
|
52
|
+
{ type: { type: "float", size: 64 }, value: x },
|
|
53
|
+
{ type: { type: "float", size: 64 }, value: y },
|
|
54
|
+
{ type: { type: "float", size: 64 }, value: width },
|
|
55
|
+
{ type: { type: "float", size: 64 }, value: height },
|
|
56
|
+
], { type: "undefined" });
|
|
57
|
+
}
|
|
58
|
+
export function closePath(cr) {
|
|
59
|
+
call(LIB, "cairo_close_path", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
60
|
+
}
|
|
61
|
+
export function newPath(cr) {
|
|
62
|
+
call(LIB, "cairo_new_path", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
63
|
+
}
|
|
64
|
+
export function newSubPath(cr) {
|
|
65
|
+
call(LIB, "cairo_new_sub_path", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
66
|
+
}
|
|
67
|
+
export function stroke(cr) {
|
|
68
|
+
call(LIB, "cairo_stroke", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
69
|
+
}
|
|
70
|
+
export function strokePreserve(cr) {
|
|
71
|
+
call(LIB, "cairo_stroke_preserve", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
72
|
+
}
|
|
73
|
+
export function fill(cr) {
|
|
74
|
+
call(LIB, "cairo_fill", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
75
|
+
}
|
|
76
|
+
export function fillPreserve(cr) {
|
|
77
|
+
call(LIB, "cairo_fill_preserve", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
78
|
+
}
|
|
79
|
+
export function paint(cr) {
|
|
80
|
+
call(LIB, "cairo_paint", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
81
|
+
}
|
|
82
|
+
export function paintWithAlpha(cr, alpha) {
|
|
83
|
+
call(LIB, "cairo_paint_with_alpha", [
|
|
84
|
+
{ type: CAIRO_T, value: cr },
|
|
85
|
+
{ type: { type: "float", size: 64 }, value: alpha },
|
|
86
|
+
], { type: "undefined" });
|
|
87
|
+
}
|
|
88
|
+
export function setSourceRgb(cr, red, green, blue) {
|
|
89
|
+
call(LIB, "cairo_set_source_rgb", [
|
|
90
|
+
{ type: CAIRO_T, value: cr },
|
|
91
|
+
{ type: { type: "float", size: 64 }, value: red },
|
|
92
|
+
{ type: { type: "float", size: 64 }, value: green },
|
|
93
|
+
{ type: { type: "float", size: 64 }, value: blue },
|
|
94
|
+
], { type: "undefined" });
|
|
95
|
+
}
|
|
96
|
+
export function setSourceRgba(cr, red, green, blue, alpha) {
|
|
97
|
+
call(LIB, "cairo_set_source_rgba", [
|
|
98
|
+
{ type: CAIRO_T, value: cr },
|
|
99
|
+
{ type: { type: "float", size: 64 }, value: red },
|
|
100
|
+
{ type: { type: "float", size: 64 }, value: green },
|
|
101
|
+
{ type: { type: "float", size: 64 }, value: blue },
|
|
102
|
+
{ type: { type: "float", size: 64 }, value: alpha },
|
|
103
|
+
], { type: "undefined" });
|
|
104
|
+
}
|
|
105
|
+
export function setLineWidth(cr, width) {
|
|
106
|
+
call(LIB, "cairo_set_line_width", [
|
|
107
|
+
{ type: CAIRO_T, value: cr },
|
|
108
|
+
{ type: { type: "float", size: 64 }, value: width },
|
|
109
|
+
], { type: "undefined" });
|
|
110
|
+
}
|
|
111
|
+
export function setLineCap(cr, lineCap) {
|
|
112
|
+
call(LIB, "cairo_set_line_cap", [
|
|
113
|
+
{ type: CAIRO_T, value: cr },
|
|
114
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: lineCap },
|
|
115
|
+
], { type: "undefined" });
|
|
116
|
+
}
|
|
117
|
+
export function setLineJoin(cr, lineJoin) {
|
|
118
|
+
call(LIB, "cairo_set_line_join", [
|
|
119
|
+
{ type: CAIRO_T, value: cr },
|
|
120
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: lineJoin },
|
|
121
|
+
], { type: "undefined" });
|
|
122
|
+
}
|
|
123
|
+
export function setDash(cr, dashes, offset) {
|
|
124
|
+
call(LIB, "cairo_set_dash", [
|
|
125
|
+
{ type: CAIRO_T, value: cr },
|
|
126
|
+
{ type: { type: "array", itemType: { type: "float", size: 64 } }, value: dashes },
|
|
127
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: dashes.length },
|
|
128
|
+
{ type: { type: "float", size: 64 }, value: offset },
|
|
129
|
+
], { type: "undefined" });
|
|
130
|
+
}
|
|
131
|
+
export function save(cr) {
|
|
132
|
+
call(LIB, "cairo_save", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
133
|
+
}
|
|
134
|
+
export function restore(cr) {
|
|
135
|
+
call(LIB, "cairo_restore", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
136
|
+
}
|
|
137
|
+
export function translate(cr, tx, ty) {
|
|
138
|
+
call(LIB, "cairo_translate", [
|
|
139
|
+
{ type: CAIRO_T, value: cr },
|
|
140
|
+
{ type: { type: "float", size: 64 }, value: tx },
|
|
141
|
+
{ type: { type: "float", size: 64 }, value: ty },
|
|
142
|
+
], { type: "undefined" });
|
|
143
|
+
}
|
|
144
|
+
export function scale(cr, sx, sy) {
|
|
145
|
+
call(LIB, "cairo_scale", [
|
|
146
|
+
{ type: CAIRO_T, value: cr },
|
|
147
|
+
{ type: { type: "float", size: 64 }, value: sx },
|
|
148
|
+
{ type: { type: "float", size: 64 }, value: sy },
|
|
149
|
+
], { type: "undefined" });
|
|
150
|
+
}
|
|
151
|
+
export function rotate(cr, angle) {
|
|
152
|
+
call(LIB, "cairo_rotate", [
|
|
153
|
+
{ type: CAIRO_T, value: cr },
|
|
154
|
+
{ type: { type: "float", size: 64 }, value: angle },
|
|
155
|
+
], { type: "undefined" });
|
|
156
|
+
}
|
|
157
|
+
export function clip(cr) {
|
|
158
|
+
call(LIB, "cairo_clip", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
159
|
+
}
|
|
160
|
+
export function clipPreserve(cr) {
|
|
161
|
+
call(LIB, "cairo_clip_preserve", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
162
|
+
}
|
|
163
|
+
export function resetClip(cr) {
|
|
164
|
+
call(LIB, "cairo_reset_clip", [{ type: CAIRO_T, value: cr }], { type: "undefined" });
|
|
165
|
+
}
|
|
166
|
+
export function setOperator(cr, op) {
|
|
167
|
+
call(LIB, "cairo_set_operator", [
|
|
168
|
+
{ type: CAIRO_T, value: cr },
|
|
169
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: op },
|
|
170
|
+
], { type: "undefined" });
|
|
171
|
+
}
|
|
@@ -1771,6 +1771,10 @@ ${indent} }`;
|
|
|
1771
1771
|
if (type.trampoline) {
|
|
1772
1772
|
parts.push(`trampoline: "${type.trampoline}"`);
|
|
1773
1773
|
}
|
|
1774
|
+
if (type.argTypes) {
|
|
1775
|
+
const argTypesStr = type.argTypes.map((t) => this.generateTypeDescriptor(t)).join(", ");
|
|
1776
|
+
parts.push(`argTypes: [${argTypesStr}]`);
|
|
1777
|
+
}
|
|
1774
1778
|
if (type.sourceType) {
|
|
1775
1779
|
parts.push(`sourceType: ${this.generateTypeDescriptor(type.sourceType)}`);
|
|
1776
1780
|
}
|
|
@@ -7,7 +7,7 @@ export declare class DrawingArea extends Widget {
|
|
|
7
7
|
getContentWidth(): number;
|
|
8
8
|
setContentHeight(height: number): void;
|
|
9
9
|
setContentWidth(width: number): void;
|
|
10
|
-
setDrawFunc(
|
|
10
|
+
setDrawFunc(drawFunc?: (self: unknown, cr: unknown, width: number, height: number) => void | null): void;
|
|
11
11
|
connect(signal: "resize", handler: (self: DrawingArea, width: number, height: number) => void, after?: boolean): number;
|
|
12
12
|
connect(signal: "notify", handler: (self: DrawingArea, pspec: GObject.ParamSpec) => void, after?: boolean): number;
|
|
13
13
|
connect(signal: string, handler: (...args: any[]) => any, after?: boolean): number;
|
|
@@ -57,24 +57,25 @@ export class DrawingArea extends Widget {
|
|
|
57
57
|
},
|
|
58
58
|
], { type: "undefined" });
|
|
59
59
|
}
|
|
60
|
-
setDrawFunc(
|
|
60
|
+
setDrawFunc(drawFunc) {
|
|
61
61
|
call("libgtk-4.so.1", "gtk_drawing_area_set_draw_func", [
|
|
62
62
|
{
|
|
63
63
|
type: { type: "gobject" },
|
|
64
64
|
value: this.ptr,
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
type: {
|
|
67
|
+
type: {
|
|
68
|
+
type: "callback",
|
|
69
|
+
trampoline: "drawFunc",
|
|
70
|
+
argTypes: [
|
|
71
|
+
{ type: "gobject", borrowed: true },
|
|
72
|
+
{ type: "int", size: 64, unsigned: true },
|
|
73
|
+
{ type: "int", size: 32, unsigned: false },
|
|
74
|
+
{ type: "int", size: 32, unsigned: false },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
68
77
|
value: drawFunc,
|
|
69
78
|
},
|
|
70
|
-
{
|
|
71
|
-
type: { type: "int", size: 64, unsigned: true },
|
|
72
|
-
value: userData,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
type: { type: "callback", trampoline: "destroy" },
|
|
76
|
-
value: destroy,
|
|
77
|
-
},
|
|
78
79
|
], { type: "undefined" });
|
|
79
80
|
}
|
|
80
81
|
connect(signal, handler, after = false) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const GL_DEPTH_BUFFER_BIT = 256;
|
|
2
|
+
export declare const GL_STENCIL_BUFFER_BIT = 1024;
|
|
3
|
+
export declare const GL_COLOR_BUFFER_BIT = 16384;
|
|
4
|
+
export declare const GL_POINTS = 0;
|
|
5
|
+
export declare const GL_LINES = 1;
|
|
6
|
+
export declare const GL_LINE_LOOP = 2;
|
|
7
|
+
export declare const GL_LINE_STRIP = 3;
|
|
8
|
+
export declare const GL_TRIANGLES = 4;
|
|
9
|
+
export declare const GL_TRIANGLE_STRIP = 5;
|
|
10
|
+
export declare const GL_TRIANGLE_FAN = 6;
|
|
11
|
+
export declare const GL_FRAGMENT_SHADER = 35632;
|
|
12
|
+
export declare const GL_VERTEX_SHADER = 35633;
|
|
13
|
+
export declare const GL_COMPILE_STATUS = 35713;
|
|
14
|
+
export declare const GL_LINK_STATUS = 35714;
|
|
15
|
+
export declare const GL_INFO_LOG_LENGTH = 35716;
|
|
16
|
+
export declare const GL_ARRAY_BUFFER = 34962;
|
|
17
|
+
export declare const GL_ELEMENT_ARRAY_BUFFER = 34963;
|
|
18
|
+
export declare const GL_STREAM_DRAW = 35040;
|
|
19
|
+
export declare const GL_STATIC_DRAW = 35044;
|
|
20
|
+
export declare const GL_DYNAMIC_DRAW = 35048;
|
|
21
|
+
export declare const GL_BYTE = 5120;
|
|
22
|
+
export declare const GL_UNSIGNED_BYTE = 5121;
|
|
23
|
+
export declare const GL_SHORT = 5122;
|
|
24
|
+
export declare const GL_UNSIGNED_SHORT = 5123;
|
|
25
|
+
export declare const GL_INT = 5124;
|
|
26
|
+
export declare const GL_UNSIGNED_INT = 5125;
|
|
27
|
+
export declare const GL_FLOAT = 5126;
|
|
28
|
+
export declare const GL_CULL_FACE = 2884;
|
|
29
|
+
export declare const GL_DEPTH_TEST = 2929;
|
|
30
|
+
export declare const GL_BLEND = 3042;
|
|
31
|
+
export declare const GL_FALSE = 0;
|
|
32
|
+
export declare const GL_TRUE = 1;
|
|
33
|
+
export declare const GL_NO_ERROR = 0;
|
|
34
|
+
export declare const GL_INVALID_ENUM = 1280;
|
|
35
|
+
export declare const GL_INVALID_VALUE = 1281;
|
|
36
|
+
export declare const GL_INVALID_OPERATION = 1282;
|
|
37
|
+
export declare const GL_OUT_OF_MEMORY = 1285;
|
|
38
|
+
export declare const GL_SRC_ALPHA = 770;
|
|
39
|
+
export declare const GL_ONE_MINUS_SRC_ALPHA = 771;
|
|
40
|
+
export declare const GL_FRONT = 1028;
|
|
41
|
+
export declare const GL_BACK = 1029;
|
|
42
|
+
export declare const GL_FRONT_AND_BACK = 1032;
|
|
43
|
+
export declare const GL_LESS = 513;
|
|
44
|
+
export declare const GL_LEQUAL = 515;
|
|
45
|
+
export declare const GL_FRAMEBUFFER_BINDING = 36006;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
2
|
+
export const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
3
|
+
export const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
4
|
+
export const GL_POINTS = 0x0000;
|
|
5
|
+
export const GL_LINES = 0x0001;
|
|
6
|
+
export const GL_LINE_LOOP = 0x0002;
|
|
7
|
+
export const GL_LINE_STRIP = 0x0003;
|
|
8
|
+
export const GL_TRIANGLES = 0x0004;
|
|
9
|
+
export const GL_TRIANGLE_STRIP = 0x0005;
|
|
10
|
+
export const GL_TRIANGLE_FAN = 0x0006;
|
|
11
|
+
export const GL_FRAGMENT_SHADER = 0x8b30;
|
|
12
|
+
export const GL_VERTEX_SHADER = 0x8b31;
|
|
13
|
+
export const GL_COMPILE_STATUS = 0x8b81;
|
|
14
|
+
export const GL_LINK_STATUS = 0x8b82;
|
|
15
|
+
export const GL_INFO_LOG_LENGTH = 0x8b84;
|
|
16
|
+
export const GL_ARRAY_BUFFER = 0x8892;
|
|
17
|
+
export const GL_ELEMENT_ARRAY_BUFFER = 0x8893;
|
|
18
|
+
export const GL_STREAM_DRAW = 0x88e0;
|
|
19
|
+
export const GL_STATIC_DRAW = 0x88e4;
|
|
20
|
+
export const GL_DYNAMIC_DRAW = 0x88e8;
|
|
21
|
+
export const GL_BYTE = 0x1400;
|
|
22
|
+
export const GL_UNSIGNED_BYTE = 0x1401;
|
|
23
|
+
export const GL_SHORT = 0x1402;
|
|
24
|
+
export const GL_UNSIGNED_SHORT = 0x1403;
|
|
25
|
+
export const GL_INT = 0x1404;
|
|
26
|
+
export const GL_UNSIGNED_INT = 0x1405;
|
|
27
|
+
export const GL_FLOAT = 0x1406;
|
|
28
|
+
export const GL_CULL_FACE = 0x0b44;
|
|
29
|
+
export const GL_DEPTH_TEST = 0x0b71;
|
|
30
|
+
export const GL_BLEND = 0x0be2;
|
|
31
|
+
export const GL_FALSE = 0;
|
|
32
|
+
export const GL_TRUE = 1;
|
|
33
|
+
export const GL_NO_ERROR = 0;
|
|
34
|
+
export const GL_INVALID_ENUM = 0x0500;
|
|
35
|
+
export const GL_INVALID_VALUE = 0x0501;
|
|
36
|
+
export const GL_INVALID_OPERATION = 0x0502;
|
|
37
|
+
export const GL_OUT_OF_MEMORY = 0x0505;
|
|
38
|
+
export const GL_SRC_ALPHA = 0x0302;
|
|
39
|
+
export const GL_ONE_MINUS_SRC_ALPHA = 0x0303;
|
|
40
|
+
export const GL_FRONT = 0x0404;
|
|
41
|
+
export const GL_BACK = 0x0405;
|
|
42
|
+
export const GL_FRONT_AND_BACK = 0x0408;
|
|
43
|
+
export const GL_LESS = 0x0201;
|
|
44
|
+
export const GL_LEQUAL = 0x0203;
|
|
45
|
+
export const GL_FRAMEBUFFER_BINDING = 0x8ca6;
|
package/dist/gl/gl.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare function glClear(mask: number): void;
|
|
2
|
+
export declare function glClearColor(red: number, green: number, blue: number, alpha: number): void;
|
|
3
|
+
export declare function glViewport(x: number, y: number, width: number, height: number): void;
|
|
4
|
+
export declare function glEnable(cap: number): void;
|
|
5
|
+
export declare function glDisable(cap: number): void;
|
|
6
|
+
export declare function glClearDepth(depth: number): void;
|
|
7
|
+
export declare function glDepthFunc(func: number): void;
|
|
8
|
+
export declare function glCreateShader(type: number): number;
|
|
9
|
+
export declare function glShaderSource(shader: number, source: string): void;
|
|
10
|
+
export declare function glCompileShader(shader: number): void;
|
|
11
|
+
export declare function glGetShaderiv(shader: number, pname: number): number;
|
|
12
|
+
export declare function glGetShaderInfoLog(shader: number, _maxLength: number): string;
|
|
13
|
+
export declare function glDeleteShader(shader: number): void;
|
|
14
|
+
export declare function glCreateProgram(): number;
|
|
15
|
+
export declare function glAttachShader(program: number, shader: number): void;
|
|
16
|
+
export declare function glLinkProgram(program: number): void;
|
|
17
|
+
export declare function glUseProgram(program: number): void;
|
|
18
|
+
export declare function glGetProgramiv(program: number, pname: number): number;
|
|
19
|
+
export declare function glGetProgramInfoLog(program: number, _maxLength: number): string;
|
|
20
|
+
export declare function glDeleteProgram(program: number): void;
|
|
21
|
+
export declare function glGetUniformLocation(program: number, name: string): number;
|
|
22
|
+
export declare function glUniform1f(location: number, v0: number): void;
|
|
23
|
+
export declare function glUniform2f(location: number, v0: number, v1: number): void;
|
|
24
|
+
export declare function glUniform3f(location: number, v0: number, v1: number, v2: number): void;
|
|
25
|
+
export declare function glUniform4f(location: number, v0: number, v1: number, v2: number, v3: number): void;
|
|
26
|
+
export declare function glUniform1i(location: number, v0: number): void;
|
|
27
|
+
export declare function glUniformMatrix4fv(location: number, count: number, transpose: boolean, value: number[]): void;
|
|
28
|
+
export declare function glGenVertexArray(): number;
|
|
29
|
+
export declare function glBindVertexArray(array: number): void;
|
|
30
|
+
export declare function glDeleteVertexArray(array: number): void;
|
|
31
|
+
export declare function glGenBuffer(): number;
|
|
32
|
+
export declare function glBindBuffer(target: number, buffer: number): void;
|
|
33
|
+
export declare function glDeleteBuffer(buffer: number): void;
|
|
34
|
+
export declare function glBufferData(target: number, data: number[], usage: number): void;
|
|
35
|
+
export declare function glVertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void;
|
|
36
|
+
export declare function glEnableVertexAttribArray(index: number): void;
|
|
37
|
+
export declare function glDisableVertexAttribArray(index: number): void;
|
|
38
|
+
export declare function glDrawArrays(mode: number, first: number, count: number): void;
|
|
39
|
+
export declare function glDrawElements(mode: number, count: number, type: number, offset: number): void;
|
|
40
|
+
export declare function glGetAttribLocation(program: number, name: string): number;
|
|
41
|
+
export declare function glBindAttribLocation(program: number, index: number, name: string): void;
|
|
42
|
+
export declare function glGetError(): number;
|
package/dist/gl/gl.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { call, createRef } from "@gtkx/native";
|
|
2
|
+
const LIB = "libGL.so.1";
|
|
3
|
+
export function glClear(mask) {
|
|
4
|
+
call(LIB, "glClear", [{ type: { type: "int", size: 32, unsigned: true }, value: mask }], { type: "undefined" });
|
|
5
|
+
}
|
|
6
|
+
export function glClearColor(red, green, blue, alpha) {
|
|
7
|
+
call(LIB, "glClearColor", [
|
|
8
|
+
{ type: { type: "float", size: 32 }, value: red },
|
|
9
|
+
{ type: { type: "float", size: 32 }, value: green },
|
|
10
|
+
{ type: { type: "float", size: 32 }, value: blue },
|
|
11
|
+
{ type: { type: "float", size: 32 }, value: alpha },
|
|
12
|
+
], { type: "undefined" });
|
|
13
|
+
}
|
|
14
|
+
export function glViewport(x, y, width, height) {
|
|
15
|
+
call(LIB, "glViewport", [
|
|
16
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: x },
|
|
17
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: y },
|
|
18
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: width },
|
|
19
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: height },
|
|
20
|
+
], { type: "undefined" });
|
|
21
|
+
}
|
|
22
|
+
export function glEnable(cap) {
|
|
23
|
+
call(LIB, "glEnable", [{ type: { type: "int", size: 32, unsigned: true }, value: cap }], { type: "undefined" });
|
|
24
|
+
}
|
|
25
|
+
export function glDisable(cap) {
|
|
26
|
+
call(LIB, "glDisable", [{ type: { type: "int", size: 32, unsigned: true }, value: cap }], { type: "undefined" });
|
|
27
|
+
}
|
|
28
|
+
export function glClearDepth(depth) {
|
|
29
|
+
call(LIB, "glClearDepth", [{ type: { type: "float", size: 64 }, value: depth }], { type: "undefined" });
|
|
30
|
+
}
|
|
31
|
+
export function glDepthFunc(func) {
|
|
32
|
+
call(LIB, "glDepthFunc", [{ type: { type: "int", size: 32, unsigned: true }, value: func }], { type: "undefined" });
|
|
33
|
+
}
|
|
34
|
+
export function glCreateShader(type) {
|
|
35
|
+
return call(LIB, "glCreateShader", [{ type: { type: "int", size: 32, unsigned: true }, value: type }], {
|
|
36
|
+
type: "int",
|
|
37
|
+
size: 32,
|
|
38
|
+
unsigned: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function glShaderSource(shader, source) {
|
|
42
|
+
call(LIB, "glShaderSource", [
|
|
43
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: shader },
|
|
44
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: 1 },
|
|
45
|
+
{ type: { type: "array", itemType: { type: "string" } }, value: [source] },
|
|
46
|
+
{ type: { type: "int", size: 64, unsigned: true }, value: 0 },
|
|
47
|
+
], { type: "undefined" });
|
|
48
|
+
}
|
|
49
|
+
export function glCompileShader(shader) {
|
|
50
|
+
call(LIB, "glCompileShader", [{ type: { type: "int", size: 32, unsigned: true }, value: shader }], {
|
|
51
|
+
type: "undefined",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function glGetShaderiv(shader, pname) {
|
|
55
|
+
const params = createRef(0);
|
|
56
|
+
call(LIB, "glGetShaderiv", [
|
|
57
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: shader },
|
|
58
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: pname },
|
|
59
|
+
{ type: { type: "ref", innerType: { type: "int", size: 32, unsigned: false } }, value: params },
|
|
60
|
+
], { type: "undefined" });
|
|
61
|
+
return params.value;
|
|
62
|
+
}
|
|
63
|
+
export function glGetShaderInfoLog(shader, _maxLength) {
|
|
64
|
+
const logLength = glGetShaderiv(shader, 0x8b84);
|
|
65
|
+
if (logLength <= 0) {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
return `Shader info log length: ${logLength} (use console.error for details)`;
|
|
69
|
+
}
|
|
70
|
+
export function glDeleteShader(shader) {
|
|
71
|
+
call(LIB, "glDeleteShader", [{ type: { type: "int", size: 32, unsigned: true }, value: shader }], {
|
|
72
|
+
type: "undefined",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function glCreateProgram() {
|
|
76
|
+
return call(LIB, "glCreateProgram", [], { type: "int", size: 32, unsigned: true });
|
|
77
|
+
}
|
|
78
|
+
export function glAttachShader(program, shader) {
|
|
79
|
+
call(LIB, "glAttachShader", [
|
|
80
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: program },
|
|
81
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: shader },
|
|
82
|
+
], { type: "undefined" });
|
|
83
|
+
}
|
|
84
|
+
export function glLinkProgram(program) {
|
|
85
|
+
call(LIB, "glLinkProgram", [{ type: { type: "int", size: 32, unsigned: true }, value: program }], {
|
|
86
|
+
type: "undefined",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function glUseProgram(program) {
|
|
90
|
+
call(LIB, "glUseProgram", [{ type: { type: "int", size: 32, unsigned: true }, value: program }], {
|
|
91
|
+
type: "undefined",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function glGetProgramiv(program, pname) {
|
|
95
|
+
const params = createRef(0);
|
|
96
|
+
call(LIB, "glGetProgramiv", [
|
|
97
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: program },
|
|
98
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: pname },
|
|
99
|
+
{ type: { type: "ref", innerType: { type: "int", size: 32, unsigned: false } }, value: params },
|
|
100
|
+
], { type: "undefined" });
|
|
101
|
+
return params.value;
|
|
102
|
+
}
|
|
103
|
+
export function glGetProgramInfoLog(program, _maxLength) {
|
|
104
|
+
const logLength = glGetProgramiv(program, 0x8b84);
|
|
105
|
+
if (logLength <= 0) {
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
return `Program info log length: ${logLength} (use console.error for details)`;
|
|
109
|
+
}
|
|
110
|
+
export function glDeleteProgram(program) {
|
|
111
|
+
call(LIB, "glDeleteProgram", [{ type: { type: "int", size: 32, unsigned: true }, value: program }], {
|
|
112
|
+
type: "undefined",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function glGetUniformLocation(program, name) {
|
|
116
|
+
return call(LIB, "glGetUniformLocation", [
|
|
117
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: program },
|
|
118
|
+
{ type: { type: "string" }, value: name },
|
|
119
|
+
], { type: "int", size: 32, unsigned: false });
|
|
120
|
+
}
|
|
121
|
+
export function glUniform1f(location, v0) {
|
|
122
|
+
call(LIB, "glUniform1f", [
|
|
123
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
124
|
+
{ type: { type: "float", size: 32 }, value: v0 },
|
|
125
|
+
], { type: "undefined" });
|
|
126
|
+
}
|
|
127
|
+
export function glUniform2f(location, v0, v1) {
|
|
128
|
+
call(LIB, "glUniform2f", [
|
|
129
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
130
|
+
{ type: { type: "float", size: 32 }, value: v0 },
|
|
131
|
+
{ type: { type: "float", size: 32 }, value: v1 },
|
|
132
|
+
], { type: "undefined" });
|
|
133
|
+
}
|
|
134
|
+
export function glUniform3f(location, v0, v1, v2) {
|
|
135
|
+
call(LIB, "glUniform3f", [
|
|
136
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
137
|
+
{ type: { type: "float", size: 32 }, value: v0 },
|
|
138
|
+
{ type: { type: "float", size: 32 }, value: v1 },
|
|
139
|
+
{ type: { type: "float", size: 32 }, value: v2 },
|
|
140
|
+
], { type: "undefined" });
|
|
141
|
+
}
|
|
142
|
+
export function glUniform4f(location, v0, v1, v2, v3) {
|
|
143
|
+
call(LIB, "glUniform4f", [
|
|
144
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
145
|
+
{ type: { type: "float", size: 32 }, value: v0 },
|
|
146
|
+
{ type: { type: "float", size: 32 }, value: v1 },
|
|
147
|
+
{ type: { type: "float", size: 32 }, value: v2 },
|
|
148
|
+
{ type: { type: "float", size: 32 }, value: v3 },
|
|
149
|
+
], { type: "undefined" });
|
|
150
|
+
}
|
|
151
|
+
export function glUniform1i(location, v0) {
|
|
152
|
+
call(LIB, "glUniform1i", [
|
|
153
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
154
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: v0 },
|
|
155
|
+
], { type: "undefined" });
|
|
156
|
+
}
|
|
157
|
+
export function glUniformMatrix4fv(location, count, transpose, value) {
|
|
158
|
+
call(LIB, "glUniformMatrix4fv", [
|
|
159
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: location },
|
|
160
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: count },
|
|
161
|
+
{ type: { type: "boolean" }, value: transpose },
|
|
162
|
+
{ type: { type: "array", itemType: { type: "float", size: 32 } }, value },
|
|
163
|
+
], { type: "undefined" });
|
|
164
|
+
}
|
|
165
|
+
export function glGenVertexArray() {
|
|
166
|
+
const array = createRef(0);
|
|
167
|
+
call(LIB, "glGenVertexArrays", [
|
|
168
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: 1 },
|
|
169
|
+
{ type: { type: "ref", innerType: { type: "int", size: 32, unsigned: true } }, value: array },
|
|
170
|
+
], { type: "undefined" });
|
|
171
|
+
return array.value;
|
|
172
|
+
}
|
|
173
|
+
export function glBindVertexArray(array) {
|
|
174
|
+
call(LIB, "glBindVertexArray", [{ type: { type: "int", size: 32, unsigned: true }, value: array }], {
|
|
175
|
+
type: "undefined",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
export function glDeleteVertexArray(array) {
|
|
179
|
+
call(LIB, "glDeleteVertexArrays", [
|
|
180
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: 1 },
|
|
181
|
+
{ type: { type: "array", itemType: { type: "int", size: 32, unsigned: true } }, value: [array] },
|
|
182
|
+
], { type: "undefined" });
|
|
183
|
+
}
|
|
184
|
+
export function glGenBuffer() {
|
|
185
|
+
const buffer = createRef(0);
|
|
186
|
+
call(LIB, "glGenBuffers", [
|
|
187
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: 1 },
|
|
188
|
+
{ type: { type: "ref", innerType: { type: "int", size: 32, unsigned: true } }, value: buffer },
|
|
189
|
+
], { type: "undefined" });
|
|
190
|
+
return buffer.value;
|
|
191
|
+
}
|
|
192
|
+
export function glBindBuffer(target, buffer) {
|
|
193
|
+
call(LIB, "glBindBuffer", [
|
|
194
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: target },
|
|
195
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: buffer },
|
|
196
|
+
], { type: "undefined" });
|
|
197
|
+
}
|
|
198
|
+
export function glDeleteBuffer(buffer) {
|
|
199
|
+
call(LIB, "glDeleteBuffers", [
|
|
200
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: 1 },
|
|
201
|
+
{ type: { type: "array", itemType: { type: "int", size: 32, unsigned: true } }, value: [buffer] },
|
|
202
|
+
], { type: "undefined" });
|
|
203
|
+
}
|
|
204
|
+
export function glBufferData(target, data, usage) {
|
|
205
|
+
const size = data.length * 4;
|
|
206
|
+
call(LIB, "glBufferData", [
|
|
207
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: target },
|
|
208
|
+
{ type: { type: "int", size: 64, unsigned: false }, value: size },
|
|
209
|
+
{ type: { type: "array", itemType: { type: "float", size: 32 } }, value: data },
|
|
210
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: usage },
|
|
211
|
+
], { type: "undefined" });
|
|
212
|
+
}
|
|
213
|
+
export function glVertexAttribPointer(index, size, type, normalized, stride, offset) {
|
|
214
|
+
call(LIB, "glVertexAttribPointer", [
|
|
215
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: index },
|
|
216
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: size },
|
|
217
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: type },
|
|
218
|
+
{ type: { type: "boolean" }, value: normalized },
|
|
219
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: stride },
|
|
220
|
+
{ type: { type: "int", size: 64, unsigned: true }, value: offset },
|
|
221
|
+
], { type: "undefined" });
|
|
222
|
+
}
|
|
223
|
+
export function glEnableVertexAttribArray(index) {
|
|
224
|
+
call(LIB, "glEnableVertexAttribArray", [{ type: { type: "int", size: 32, unsigned: true }, value: index }], {
|
|
225
|
+
type: "undefined",
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
export function glDisableVertexAttribArray(index) {
|
|
229
|
+
call(LIB, "glDisableVertexAttribArray", [{ type: { type: "int", size: 32, unsigned: true }, value: index }], {
|
|
230
|
+
type: "undefined",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export function glDrawArrays(mode, first, count) {
|
|
234
|
+
call(LIB, "glDrawArrays", [
|
|
235
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: mode },
|
|
236
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: first },
|
|
237
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: count },
|
|
238
|
+
], { type: "undefined" });
|
|
239
|
+
}
|
|
240
|
+
export function glDrawElements(mode, count, type, offset) {
|
|
241
|
+
call(LIB, "glDrawElements", [
|
|
242
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: mode },
|
|
243
|
+
{ type: { type: "int", size: 32, unsigned: false }, value: count },
|
|
244
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: type },
|
|
245
|
+
{ type: { type: "int", size: 64, unsigned: true }, value: offset },
|
|
246
|
+
], { type: "undefined" });
|
|
247
|
+
}
|
|
248
|
+
export function glGetAttribLocation(program, name) {
|
|
249
|
+
return call(LIB, "glGetAttribLocation", [
|
|
250
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: program },
|
|
251
|
+
{ type: { type: "string" }, value: name },
|
|
252
|
+
], { type: "int", size: 32, unsigned: false });
|
|
253
|
+
}
|
|
254
|
+
export function glBindAttribLocation(program, index, name) {
|
|
255
|
+
call(LIB, "glBindAttribLocation", [
|
|
256
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: program },
|
|
257
|
+
{ type: { type: "int", size: 32, unsigned: true }, value: index },
|
|
258
|
+
{ type: { type: "string" }, value: name },
|
|
259
|
+
], { type: "undefined" });
|
|
260
|
+
}
|
|
261
|
+
export function glGetError() {
|
|
262
|
+
return call(LIB, "glGetError", [], { type: "int", size: 32, unsigned: true });
|
|
263
|
+
}
|
package/dist/gl/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/ffi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Generated TypeScript FFI bindings for GTK4 libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -30,6 +30,16 @@
|
|
|
30
30
|
"development": "./src/index.ts",
|
|
31
31
|
"default": "./dist/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./gl": {
|
|
34
|
+
"types": "./dist/gl/index.d.ts",
|
|
35
|
+
"development": "./src/gl/index.ts",
|
|
36
|
+
"default": "./dist/gl/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./cairo": {
|
|
39
|
+
"types": "./dist/cairo/index.d.ts",
|
|
40
|
+
"development": "./src/cairo/index.ts",
|
|
41
|
+
"default": "./dist/cairo/index.js"
|
|
42
|
+
},
|
|
33
43
|
"./*": {
|
|
34
44
|
"types": "./dist/generated/*/index.d.ts",
|
|
35
45
|
"development": "./src/generated/*/index.ts",
|
|
@@ -40,10 +50,10 @@
|
|
|
40
50
|
"dist"
|
|
41
51
|
],
|
|
42
52
|
"dependencies": {
|
|
43
|
-
"@gtkx/native": "0.1.
|
|
53
|
+
"@gtkx/native": "0.1.18"
|
|
44
54
|
},
|
|
45
55
|
"devDependencies": {
|
|
46
|
-
"@gtkx/gir": "0.1.
|
|
56
|
+
"@gtkx/gir": "0.1.18"
|
|
47
57
|
},
|
|
48
58
|
"scripts": {
|
|
49
59
|
"build": "tsc -b",
|