Skip to content

Commit 26caed3

Browse files
committed
Modify worker and move C code (for C++ migration) remove wasm builds
1 parent 4044a2c commit 26caed3

File tree

14 files changed

+23
-38
lines changed

14 files changed

+23
-38
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC = emcc
22
SRCS = main.c
33

4-
FILES = $(addprefix src/, $(SRCS)) # Add 'src/' to each source
4+
FILES = $(addprefix src/c/, $(SRCS)) # Add 'src/' to each source
55
OBJS = $(FILES:.c=.o) # Modify file extensions of FILES
66
EOPT = USE_WEBGL2=1 FULL_ES3=1 USE_GLFW=3 # Emscripten specific options
77
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
@@ -11,8 +11,8 @@ build: $(OBJS)
1111
mkdir build
1212
mkdir app/wasm
1313
$(CC) $(FILES) -O3 $(EOPTS) -o app/wasm/module.js -s WASM=1 -Wall -s MODULARIZE=1
14-
$(CC) src/counter.c -O3 $(EOPTS) -s SIDE_MODULE=1 -s WASM=1 -o app/wasm/counter.wasm
15-
emcc src/engine.c -O3 -o app/wasm/engine.js -s WASM=1 -Wall -s MODULARIZE=1
14+
$(CC) src/c/counter.c -O3 $(EOPTS) -s SIDE_MODULE=1 -s WASM=1 -o app/wasm/counter.wasm
15+
emcc src/c/engine.c -O3 -o app/wasm/engine.js -s WASM=1 -Wall -s MODULARIZE=1
1616

1717
# O3 is is a optimization setting
1818
# WASM=1 means set web assembly to ture
@@ -21,7 +21,7 @@ build: $(OBJS)
2121

2222
# Test run
2323
test:
24-
emcc src/main.c -O3 $(EOPTS) -o build/index.html -s WASM=1
24+
emcc src/c/main.c -O3 $(EOPTS) -o build/index.html -s WASM=1
2525

2626
# Removes object files, but leaves build for serving
2727
dist: build

app/engine.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Module from './wasm/engine.js'
2+
3+
export class Engine {
4+
5+
module;
6+
7+
constructor() {
8+
this.loadDemoWasm();
9+
}
10+
11+
loadDemoWasm() {
12+
this.module = Module({
13+
wasmBinaryFile: '/wasm/engine.wasm',
14+
});
15+
}
16+
17+
}
18+

app/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import './style.scss';
22
import { Counter } from './counter';
33
import { OpenGLDemo } from "./opengl-demo";
4-
import Module from './wasm/engine.js'
54

65
// Get Worker Thread
76
// const WorkerThread = require('worker-loader!./worker.js');
@@ -10,7 +9,6 @@ function main() {
109
addHeader();
1110
const counter = new Counter();
1211
const demo = new OpenGLDemo();
13-
let module = Module({wasmBinaryFile: '/wasm/engine.wasm'});
1412
// const worker = new WorkerThread();
1513
// handleWorkerThread(worker);
1614
}

app/wasm/counter.wasm

-294 Bytes
Binary file not shown.

app/wasm/engine.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/wasm/engine.wasm

-13.5 KB
Binary file not shown.

app/wasm/module.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/wasm/module.wasm

-33.5 KB
Binary file not shown.

app/worker.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { OpenGLDemo } from './opengl-demo';
2-
31
// Post data to parent thread
42
postMessage({foo: 'foo'});
53

@@ -8,7 +6,6 @@ onmessage = (event) => {
86
};
97

108
function main() {
11-
const demo = new OpenGLDemo();
129
}
1310

1411
main();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "git+https://github.com/1337programming/WebAssemblyOpenGL.git"
1717
},
18-
"author": "Patrick Opie <opiepj@plu.edu>",
18+
"author": "Patrick Opie <opiepat@gmail.com>",
1919
"license": "ISC",
2020
"bugs": {
2121
"url": "https://github.com/1337programming/WebAssemblyOpenGL/issues"
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/main.c renamed to src/c/main.c

File renamed without changes.

0 commit comments

Comments
 (0)