Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 46 additions & 44 deletions packages/webgl/upm/Runtime/Plugins/WebGL/puerts.jslib
Original file line number Diff line number Diff line change
@@ -1,44 +1,4 @@
var exportDLL = {
InitPuertsWebGL: function () {
var global = typeof global != 'undefined' ? global : window;
if (!global.PuertsWebGL) {
throw new Error('cannot found PuertsWebGL script. please find some way to load puerts-runtime.js');
}
let oldUpdateGlobalBufferAndViews = updateGlobalBufferAndViews;
updateGlobalBufferAndViews = function (buf) {
oldUpdateGlobalBufferAndViews(buf);
global.PuertsWebGL.updateGlobalBufferAndViews(
HEAP8,
HEAPU8,
HEAP32,
HEAPF32,
HEAPF64
);
}
global.PuertsWebGL.Init({
UTF8ToString,
_malloc,
_free,
_setTempRet0,
stringToUTF8,
lengthBytesUTF8,
stackAlloc,
stackSave,
stackRestore,
_CallCSharpFunctionCallback: Module._CallCSharpFunctionCallback,
_CallCSharpConstructorCallback: Module._CallCSharpConstructorCallback,
_CallCSharpDestructorCallback: Module._CallCSharpDestructorCallback,

HEAP8,
HEAPU8,
HEAP32,
HEAPF32,
HEAPF64,
});
global.PuertsWebGL.inited = true;
},
};

var exportDLL = {};

[
"GetLibVersion",
Expand Down Expand Up @@ -132,14 +92,56 @@ var exportDLL = {
"LogicTick",
"SetLogCallback",
].forEach(function (methodName) {

exportDLL[methodName] = new Function(
"var global = typeof global != 'undefined' ? global : window; " +
"if (!global.PuertsWebGL) throw new Error('cannot found PuertsWebGL script. please find some way to load puerts-runtime.js');" +
"if (!global.PuertsWebGL.inited) throw new Error('please use Puerts.WebGL.MainEnv.Get() to create JsEnv'); " +
"if (global.PuertsWebGL.debug) console.log('WebGL DLL:" + methodName + "'); "+
"return global.PuertsWebGL['" + methodName + "'].apply(this, arguments)"
);
})

mergeInto(LibraryManager.library, exportDLL);
mergeInto(LibraryManager.library, exportDLL);

mergeInto(LibraryManager.library, {
GetApiLevel__postset: `
addOnInit(function () {
var global = typeof global != "undefined" ? global : window;
if (!global.PuertsWebGL) {
throw new Error(
"cannot found PuertsWebGL script. please find some way to load puerts-runtime.js"
);
}
let oldUpdateGlobalBufferAndViews = updateGlobalBufferAndViews;
updateGlobalBufferAndViews = function (buf) {
oldUpdateGlobalBufferAndViews(buf);
global.PuertsWebGL.updateGlobalBufferAndViews(
HEAP8,
HEAPU8,
HEAP32,
HEAPF32,
HEAPF64
);
};
global.PuertsWebGL.Init({
UTF8ToString,
_malloc,
_free,
_setTempRet0,
stringToUTF8,
lengthBytesUTF8,
stackAlloc,
stackSave,
stackRestore,
_CallCSharpFunctionCallback: Module._CallCSharpFunctionCallback,
_CallCSharpConstructorCallback: Module._CallCSharpConstructorCallback,
_CallCSharpDestructorCallback: Module._CallCSharpDestructorCallback,

HEAP8,
HEAPU8,
HEAP32,
HEAPF32,
HEAPF64,
});
global.PuertsWebGL.inited = true;
});`,
});
42 changes: 0 additions & 42 deletions packages/webgl/upm/Runtime/WebGL.cs

This file was deleted.

11 changes: 0 additions & 11 deletions packages/webgl/upm/Runtime/WebGL.cs.meta

This file was deleted.

2 changes: 1 addition & 1 deletion projects/8_UnitTest/Assets/Test/PuertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void Awake()

void Start()
{
var jsEnv = Puerts.WebGL.MainEnv.Get(new TSLoader());
var jsEnv = new JsEnv(new TSLoader());

// var jsEnv = new Puerts.JsEnv(new DefaultLoader(), 8080);
// jsEnv.WaitDebugger();
Expand Down