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