koffi 0.9.15 → 0.9.16
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/README.md +15 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ This section assumes you know how to build C shared libraries.
|
|
|
66
66
|
This examples illustrates how to use Koffi with a Raylib shared library:
|
|
67
67
|
|
|
68
68
|
```js
|
|
69
|
-
const koffi = require('
|
|
69
|
+
const koffi = require('koffi');
|
|
70
70
|
|
|
71
71
|
const Color = koffi.struct('Color', {
|
|
72
72
|
r: 'uchar',
|
|
@@ -120,20 +120,20 @@ const Font = koffi.struct('Font', {
|
|
|
120
120
|
glyphs: koffi.pointer(GlyphInfo)
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
// Fix the path to Raylib DLL
|
|
124
|
-
let lib = koffi.load('
|
|
125
|
-
|
|
126
|
-
const InitWindow = lib.func('InitWindow',
|
|
127
|
-
const SetTargetFPS = lib.func('SetTargetFPS',
|
|
128
|
-
const GetScreenWidth = lib.func('GetScreenWidth',
|
|
129
|
-
const GetScreenHeight = lib.func('GetScreenHeight',
|
|
130
|
-
const ClearBackground = lib.func('ClearBackground',
|
|
131
|
-
const BeginDrawing = lib.func('BeginDrawing',
|
|
132
|
-
const EndDrawing = lib.func('EndDrawing',
|
|
133
|
-
const WindowShouldClose = lib.func('WindowShouldClose',
|
|
134
|
-
const GetFontDefault = lib.func('GetFontDefault',
|
|
135
|
-
const MeasureTextEx = lib.func('MeasureTextEx',
|
|
136
|
-
const DrawTextEx = lib.func('DrawTextEx',
|
|
123
|
+
// Fix the path to Raylib DLL if needed
|
|
124
|
+
let lib = koffi.load('build/raylib' + (process.platform == 'win32' ? '.dll' : '.so'));
|
|
125
|
+
|
|
126
|
+
const InitWindow = lib.func('InitWindow', 'void', ['int', 'int', 'string']);
|
|
127
|
+
const SetTargetFPS = lib.func('SetTargetFPS', 'void', ['int']);
|
|
128
|
+
const GetScreenWidth = lib.func('GetScreenWidth', 'int', []);
|
|
129
|
+
const GetScreenHeight = lib.func('GetScreenHeight', 'int', []);
|
|
130
|
+
const ClearBackground = lib.func('ClearBackground', 'void', [Color]);
|
|
131
|
+
const BeginDrawing = lib.func('BeginDrawing', 'void', []);
|
|
132
|
+
const EndDrawing = lib.func('EndDrawing', 'void', []);
|
|
133
|
+
const WindowShouldClose = lib.func('WindowShouldClose', 'bool', []);
|
|
134
|
+
const GetFontDefault = lib.func('GetFontDefault', Font, []);
|
|
135
|
+
const MeasureTextEx = lib.func('MeasureTextEx', Vector2, [Font, 'string', 'float', 'float']);
|
|
136
|
+
const DrawTextEx = lib.func('DrawTextEx', 'void', [Font, 'string', Vector2, 'float', 'float', Color]);
|
|
137
137
|
|
|
138
138
|
InitWindow(800, 600, 'Test Raylib');
|
|
139
139
|
SetTargetFPS(60);
|