mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-08 11:34:20 +00:00
Add WebGL runtime into the js/runtime.mjs; Allow for multiple WebGL contexts
This commit is contained in:
1034
vendor/wasm/WebGL/runtime.mjs
vendored
1034
vendor/wasm/WebGL/runtime.mjs
vendored
File diff suppressed because it is too large
Load Diff
1
vendor/wasm/WebGL/webgl.odin
vendored
1
vendor/wasm/WebGL/webgl.odin
vendored
@@ -15,6 +15,7 @@ Texture :: distinct u32
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign webgl {
|
||||
SetCurrentContextById :: proc(name: string) -> bool ---
|
||||
DrawingBufferWidth :: proc() -> i32 ---
|
||||
DrawingBufferHeight :: proc() -> i32 ---
|
||||
|
||||
|
||||
1057
vendor/wasm/js/runtime.mjs
vendored
1057
vendor/wasm/js/runtime.mjs
vendored
File diff suppressed because it is too large
Load Diff
26
vendor/wasm/loader/loader.mjs
vendored
26
vendor/wasm/loader/loader.mjs
vendored
@@ -1,24 +1,18 @@
|
||||
import {WasmMemoryInterface, odinSetupDefaultImports} from "../js/runtime.mjs";
|
||||
import {WebGLInterface} from "../WebGL/runtime.mjs";
|
||||
import {WasmMemoryInterface, odinSetupDefaultImports, WebGLInterface} from "./runtime.mjs";
|
||||
|
||||
export async function runWasmCanvas(wasmPath, webglCanvasElement, consoleElement, extraForeignImports) {
|
||||
export async function runWasmCanvas(wasmPath, consoleElement, extraForeignImports) {
|
||||
let wasmMemoryInterface = new WasmMemoryInterface();
|
||||
|
||||
let imports = odinSetupDefaultImports(wasmMemoryInterface, consoleElement);
|
||||
let exports = {};
|
||||
|
||||
if (webglCanvasElement !== undefined) {
|
||||
let gl_context = new WebGLInterface(
|
||||
wasmMemoryInterface,
|
||||
webglCanvasElement,
|
||||
{antialias: false},
|
||||
);
|
||||
if (!gl_context.ctx) {
|
||||
return "WebGL is not available.";
|
||||
}
|
||||
imports["webgl"] = gl_context.getWebGL1Interface();
|
||||
imports["webgl2"] = gl_context.getWebGL2Interface();
|
||||
}
|
||||
let gl_context = new WebGLInterface(
|
||||
wasmMemoryInterface,
|
||||
null,
|
||||
{antialias: false},
|
||||
);
|
||||
imports["webgl"] = gl_context.getWebGL1Interface();
|
||||
imports["webgl2"] = gl_context.getWebGL2Interface();
|
||||
|
||||
if (extraForeignImports !== undefined) {
|
||||
imports = {
|
||||
@@ -60,4 +54,4 @@ export async function runWasmCanvas(wasmPath, webglCanvasElement, consoleElement
|
||||
};
|
||||
|
||||
|
||||
export {runWasmCanvas};
|
||||
export {runWasmCanvas};
|
||||
Reference in New Issue
Block a user